
Code: Select all
local snail_id = "my_snail_01"; -- This is just storing the ID string of your snail.
local snail = findEntity(snail_id); -- This is storing a pointer to the snail, which might be 'nil' if it's not found.
-- You have to check if the snail has been found or not, otherwise, calling snail.level might cause a crash.
if ( snail ~= nil ) then
hudPrint("Found the Snail");
local snail_level = snail.level;
end
Code: Select all
local snail = findEntity("my_snail_01");
if ( snail ~= nil ) then
-- Do something with snail.level
end
This one can. That's why it is so scary.Ixnatifual wrote:Guys, snails can't speak.
Code: Select all
onMove = function(monster, direction)
local myScript = findEntity("my_level_script")
If myScript then
myScript:notifyMonsterMoved(monster)
end
end
Code: Select all
function notifyMonsterMoved(sender, monster)
print("monster now at "..monster.x..", "..monster.y.."")
end