Page 1 of 1
Is it true that triggers/buttons no longer give a "self" ref
Posted: Sun Nov 30, 2014 12:13 pm
by Isaac
It used to be that a plate or button could be identified in the function it called; is this no longer the case? ~Or did just the method for this change?
For example:
Code: Select all
function aboutFace(caller)
print(caller.name, caller.id, caller.x, caller.y)
end
Re: Is it true that triggers/buttons no longer give a "self"
Posted: Sun Nov 30, 2014 12:22 pm
by NutJob
caller.go.id, caller.go.name, etc
Re: Is it true that triggers/buttons no longer give a "self"
Posted: Sun Nov 30, 2014 12:37 pm
by Isaac
NutJob wrote:caller.go.id, caller.go.name, etc
Yep; it would be so simple ~after I asked.
Thanks.
* .go is still so unfamiliar... too often forgotten about.
Re: Is it true that triggers/buttons no longer give a "self"
Posted: Sun Nov 30, 2014 12:54 pm
by NutJob
Not a problem, it got me too a few weeks ago. Don't really understand the reason why it's required but it becomes easy to remember once ya recognize when it's needed, or not needed.
Re: Is it true that triggers/buttons no longer give a "self"
Posted: Sun Nov 30, 2014 8:06 pm
by minmay
It's required because buttons are entities in Grimrock 1, but components in Grimrock 2. So when a button is passed to a script in Grimrock 1, it's an entity with an id, position, etc. When a button is passed to a script in Grimrock 2, it's a component belonging to a game object, so it doesn't have a position or the like; you need to get that from the parent game object with .go.
Passing the component is much better than passing the game object for several reasons (example: consider having a game object with multiple components that connect to the same function).