Page 1 of 1

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

Posted: Tue Oct 28, 2014 9:33 pm
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?

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

Posted: Tue Oct 28, 2014 9:52 pm
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

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

Posted: Tue Oct 28, 2014 10:04 pm
by NutJob
I have used them all myself without problems; well some problems but programmer errors. =)

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

Posted: Tue Oct 28, 2014 10:33 pm
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"?

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

Posted: Tue Oct 28, 2014 10:41 pm
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