Where did findEntity(), entitiesAt() and allEntities() go?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Where did findEntity(), entitiesAt() and allEntities() go?

Post by MrChoke »

These entity-based global functions were in Grim Rock 1 but I cannot seem to get them to work in 2. Does anybody know what happened to them?
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Where did findEntity(), entitiesAt() and allEntities() g

Post by Prozail »

theyre still here...

atleast this works for me.

Code: Select all

function test()
	print ("findentity")
	local x = findEntity("altar_1")
	if x then 
		print(x.id)
	end
	
	print ("allentities")
	for e in self.go.map:allEntities() do
		if e.monster then
			print (e.id)
		end
	end
		
	print ("entitiesat")
	for i in self.go.map:entitiesAt(11,15) do
		print (i.id)
	end
end
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Where did findEntity(), entitiesAt() and allEntities() g

Post by NutJob »

I have used them all myself without problems; well some problems but programmer errors. =)
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Where did findEntity(), entitiesAt() and allEntities() g

Post by MrChoke »

Yes, your code works. Ugh, I am so new to this stuff. So what keeps throwing me is when script reference "go". As in this code:

for i in self.go.map:entitiesAt(14,14) do
print (i.id)
end

So I know "self" would be the object this function is called on. I called it globally so not sure what exactly "self" in this case. But was is "go"?
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Where did findEntity(), entitiesAt() and allEntities() g

Post by Prozail »

"go" i think is GameObject

Seems like sometimes they wrap a gameobject inside a messageobject of some kind (just me guessing)
So for instance with "self" and the "sender" parameter in a function, you have to grab the object with ".go"

ie.

Code: Select all

function somefunction(sender)
  print (sender.go.id)
end
Post Reply