So I have found sometimes I get a blank error message when editing scripts. I assume it means "you messed up so bad even the engine doesn't know what's wrong":
(https://i.imgur.com/ZQOyYry.png)
But I'm curious if there is actually an explanation? It generally makes troubleshooting a bear unless I've paid attention to the changes I've made. Is it related to the stack?
I noticed I've seen it appear with events most often, but this current case is related to gaining EXP at the end of battle, and I believe it may be a recursion issue.
Also, the problem script, if someone would like to help. I am trying to figure out how EXP is calculated with this battle script, it seems to be completely wrong--my actor is gaining way more exp than the enemy provides--so I was trying to fix it, rather unsuccessfully:
The phase 5 calls "gain_exp" after battle like so:
And gain_exp
def gain_exp
exp = exp_gained
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
return exp
end
#--------------------------------------------------------------------------
def exp_gained
# For each enemy in the troop
for enemy in $game_troop.enemies
# Add their exp to the pool
exp += enemy.exp
# Old line: exp = exp.nil? ? enemy.exp : exp + enemy.exp
end
if EXP_SHARE
actor_number = 0
for actor in $game_party.actors
actor_number += 1 unless actor.cant_get_exp?
end
exp = exp / [actor_number, 1].max
#exp = exp / [actor_number, 1].max
end
return exp
end
It's actually a character limit in how much the message window can say when an error is raised. Found this out a couple weeks ago. I'm going to make a change to XPA in that it will output the traceback into a text file if it gets too large.
At the bottom of Main, replace it to this
rescue SyntaxError
$!.message.sub!($!.message, traceback_report)
File.open('error.log', 'w') { |f| f.write($!.message) }
raise "Check error.log"
rescue
$!.message.sub!($!.message, traceback_report)
File.open('error.log', 'w') { |f| f.write($!.message) }
raise "Check error.log"
end
Regarding the exp script, what happens after
Does it add
exp to the actors? Which would be pointless since it already adds it to them in
gain_exp.
QuoteDoes it add exp to the actors? Which would be pointless since it already adds it to them in gain_exp.
Ah-ha! There it is. Thanks.
And the error log thing is super helpful, thanks for that, too. Makes me feel a little less bad about my mistakes, knowing I can actually see them, heh.
QuoteDoes it add exp to the actors? Which would be pointless since it already adds it to them in gain_exp.
Actually, looking back, it isn't supposed to add exp to the actors, only display exp gained in the results window.
It seems now I am gaining exactly x2 EXP. I did knock it down to one method, since "EXP_SHARE" is pointless and I'm not implementing it. It seems like it's counting two troops, even though there's only one.
def gain_exp
# Initilize EXP
exp = 0
# For each enemy in the troop
for enemy in $game_troop.enemies
# Add their exp to the pool
exp += enemy.exp
end
# Check each actor in the party
for i in 0...$game_party.actors.size
# Set actor
actor = $game_party.actors[i]
# Check if they can receive EXP
if actor.cant_get_exp? == false
# Get the previous level
last_level = actor.level
# Add enemy exp to the actor
actor.exp += exp
# Check for level up
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# Return total gained EXP
return exp
end
Add some print statements and see where the fault is at. I'd place them after the total EXP is calculated and checking the actor's EXP before and after the EXP is added. If all looks good, then the error lies outside of gain_exp.
QuoteAdd some print statements and see where the fault is at.
Everything is looking good in gain_exp, based on the prints. It's outside gain_exp for sure. At least the math there is right. The hunt continues.
I think it may be the Summons battle add-on you have.
alias gain_exp_summon_n01 gain_exp
def gain_exp
return_party(true) if $game_temp.summon_active
exp = gain_exp_summon_n01
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false and not $game_party.removed_actors.include?(actor)
last_level = actor.level
actor.exp += exp
@status_window.level_up(i) if actor.level > last_level
elsif actor.cant_get_exp? == false and $game_party.removed_actors.include?(actor)
last_level = actor.level
actor.exp += ((exp * Removed_Actors_exp_rate) / 100).to_i
@status_window.level_up(i) if actor.level > last_level
end
end
for summon in $game_party.summons
if summon.cant_get_exp? == false and $game_party.summoned.include?(summon.id)
last_level = summon.level
summon.exp += ((exp * Summoned_exp_rate) / 100).to_i
@status_window.level_up(i) if actor.level > last_level
elsif summon.cant_get_exp? == false and not $game_party.summoned.include?(summon.id)
last_level = summon.level
summon.exp += ((exp * Not_Summoned_exp_rate) / 100).to_i
@status_window.level_up(i) if actor.level > last_level
end
end
$game_party.removed_actors.clear
$game_party.summoned.clear
return exp
end
It was exactly that! I actually found this and forgot to update the topic. Removing it solved the problem. I'll have to fix it if I want to use it.
Side note: logging runtime errors to a file has changed my world. It's so much more convenient than trying to remember what the damn error was and where. So thanks again for that one.