And I tested and the ( ) are not necessary, but maybe Lark has a - perhaps wise/good - habit of including them even if they sometimes are redundant, because other times they are needed.
so now it basically boils down to:
Code: Select all
totalMonsters = 0
function countMonsters()
for i=1,13 do
for j in allEntities(i) do
if j["setAIState"] ~= nil then
j:setLevel(2)
totalMonsters = totalMonsters + 1
end
end
end
print("there are "..totalMonsters.." monsters")
endwith the key to it all being the line:
if j["setAIState"] ~= nil then
which says "in the table of properties/info for entity j, if there is an item with the string "setAIState" then do something"
Is there a way to "print" all the properties of an entity, to print all its table values?
I tried:
for i in findEntity("spider_shock_1") do print(i) end and
for i in findEntity("spider_shock_1") do print(spider_shock_1) end and
for i in spider_shock_1 do print(i) end
but I got ":1: attempt to call a table value" error message or ":1: attempt to call a nil value"
