Registering methods for scripts that are attached to multiple game objects
Posted: Tue Aug 25, 2020 6:21 pm
Hello,
I was wondering about registering methods with Lua for scripts that are used in multiple gameobjects.
If, for example, I wanted to create a relationship system where the player's relationship with the NPC is associated only with that NPC and not with all NPCs, then I would also like to use that system in Lua.
The problem being that registering methods may not be that straightforward. I have registered a method for a script that only had one instance in the scene, but what if I had a script that was attached to multiple objects in the scene?
For example, if I create and register a method that returns the relationship value for a NPC, and in the conversation nodes I want to use it as a condition check(example- GetRelationship()<5), then how does the System know where to check for this, since the script is being used across multiple objects and the values of GetRelationship() will differ for each?
The second question I had was related to the "relationship type" parameter in the https://www.pixelcrushers.com/dialogue_ ... pFunctions that the dialogue system provides. Is this "relationship type" created by us or are there multiple relationship types already present and built-in?
I was wondering about registering methods with Lua for scripts that are used in multiple gameobjects.
If, for example, I wanted to create a relationship system where the player's relationship with the NPC is associated only with that NPC and not with all NPCs, then I would also like to use that system in Lua.
The problem being that registering methods may not be that straightforward. I have registered a method for a script that only had one instance in the scene, but what if I had a script that was attached to multiple objects in the scene?
For example, if I create and register a method that returns the relationship value for a NPC, and in the conversation nodes I want to use it as a condition check(example- GetRelationship()<5), then how does the System know where to check for this, since the script is being used across multiple objects and the values of GetRelationship() will differ for each?
The second question I had was related to the "relationship type" parameter in the https://www.pixelcrushers.com/dialogue_ ... pFunctions that the dialogue system provides. Is this "relationship type" created by us or are there multiple relationship types already present and built-in?