To begin with, this issue does not affect the game play at all and everything works. It is just an annoying warning.
I have this code on a different map.
When I leave the map and go to a different map, I get a warning from the previous map: (I checked and "bookcase" does not exist on the new map.)
Please note: I did not remove the bookcase and it does the same thing when I tested it with a chest entity.
I get around the warning by using a save variable.
I have this code on a different map.
Code ( lua) Select
function slime:on_removed()
bookcase:set_enabled(false)
end
When I leave the map and go to a different map, I get a warning from the previous map: (I checked and "bookcase" does not exist on the new map.)
Code Select
Error: In on_removed: [string "maps/chain_village/zark_house.lua"]:17: attempt to index global 'bookcase' (a nil value)
Please note: I did not remove the bookcase and it does the same thing when I tested it with a chest entity.
Code ( lua) Select
function slime:on_removed()
if not chest:is_open() then
sol.audio.play_sound("secret")
end
end
Code Select
Error: In on_removed: [string "maps/chain_village/zark_house.lua"]:21: attempt to index global 'chest' (a nil value)
I get around the warning by using a save variable.
Code ( lua) Select
function slime:on_removed()
if not game:get_value("zark_house_enemy_defeated") == true then
bookcase:set_enabled(false)
end
if not game:get_value("zark_house_enemy_defeated") == true then
if not chest:is_open() then
sol.audio.play_sound("secret")
end
end
game:set_value("zark_house_enemy_defeated",true)
end