Page 1 of 1

Help with find monster script please

Posted: Thu Nov 22, 2018 10:30 pm
by HypnoToad
I have this script that finds monsters on all levels but can't figure out how to change it to find monsters on the current level only.

for x = 1, getMaxLevels() do
for monster in allEntities(x) do
if monster.name == "ogre" then
print( monster.id..":", " on level "..monster.level,"@", "X:"..monster.x, "Y:"..monster.y )
end
end
end

I'm sure it's obvious but I have tried many changes but still comes back with an error, can anyone point me in the right direction?

Re: Help with find monster script please

Posted: Fri Nov 23, 2018 12:01 am
by Zo Kath Ra
Does this work?

Code: Select all

for monster in allEntities(party.level) do
	if monster.name == "ogre" then
		print( monster.id..":", " on level "..monster.level,"@", "X:"..monster.x, "Y:"..monster.y )
	end
end 
x

Re: Help with find monster script please

Posted: Fri Nov 23, 2018 12:38 am
by HypnoToad
Zo Kath Ra wrote: Fri Nov 23, 2018 12:01 am Does this work?

Code: Select all

for monster in allEntities(party.level) do
	if monster.name == "ogre" then
		print( monster.id..":", " on level "..monster.level,"@", "X:"..monster.x, "Y:"..monster.y )
	end
end 
x
Works fine, I thought I tried that but must have had some thing wrong as it came back with the old "global" error, thanks very much. :)

Oh silly me, I had "for monsters in .........", duh. :roll: