AEROGP'S PROFILE

Search

Filter

More on Learning RGSS2

"unknown method > for nil(nilclass)" means that the variable hp_damage had not been declared. By default, undeclared variables are registered as "nil" when used before declaration; however, nil cannot be used for comparison operations, hence the error.

case @actual_code_written

when "if hp_damage > 0"
Change hp_damage to "target.hp_damage". Don't forget to break from the method when there is no target! ("target.nil?" / "target == nil")

when "if target.hp_damage > 0"
Are you sure the error wasn't "unknown method hp_damage for nil(nilclass)"? That would mean that target was nil, and you can't reference anything from nilclass. Check that the target is correct, then use target.hp_damage. It could be, also, that hp_damage itself is nil, but then transferring nil to hpdmg wouldn't make any sense... what a peculiar bug.

end
Pages: 1