Page 2 of 3

Re: Access variable from c#

Posted: Thu Jul 28, 2022 4:35 am
by hrohibil
I inserted this in the dialogue conversation, I placed it on the node where i want the NPC to give key to player.
Or where should i write this LUA? In a system trigger?

Becasue i only want him to recieve the key during a specific node in a conversation..


Re: Access variable from c#

Posted: Thu Jul 28, 2022 4:45 am
by hrohibil
Got it sorted out...

Looked at the documentation again :-)

Re: Access variable from c#

Posted: Thu Jul 28, 2022 1:46 pm
by hrohibil
Hey Tony.

Can we also remove items with Invector ?

So let’s I get the and it’s added my inventory.
But let’s pretend that this key would be giving to an NPC during a conversation, how can I remove the item?
Thank you

Re: Access variable from c#

Posted: Thu Jul 28, 2022 1:51 pm
by Tony Li
Use the Invector Lua Functions. For example, to remove 1 of item ID 15, put this in the Script field of a dialogue entry node:

Code: Select all

vRemoveItemByID(15, 1)

Re: Access variable from c#

Posted: Thu Jul 28, 2022 1:58 pm
by hrohibil
Thanks.

I will check it out asap.
This whole LUA seems really powerful.
I think they use it to program ROBLOX. My son keep telling me make a character in blender and import into Unity.

Re: Access variable from c#

Posted: Thu Aug 04, 2022 3:55 pm
by hrohibil
Hey Tony

What approach should I do when inside a node tree I have a node where i set a variable to true.
That's easy.
My issue, how can I when that variable is true, execute a public void function i have on a script?

Thank you

Re: Access variable from c#

Posted: Thu Aug 04, 2022 7:14 pm
by Tony Li
You can make your C# method available to Lua, or set up a scene event, or use the SendMessage() sequencer command. For example, say the public method is named OpenDoor() and it's on a GameObject named "Front Door". Then use this sequence:

Code: Select all

SendMessage(OpenDoor, , Front Door)

Re: Access variable from c#

Posted: Fri Aug 05, 2022 3:57 am
by hrohibil
Thank you Tony :D

Re: Access variable from c#

Posted: Sat Aug 06, 2022 10:00 am
by hrohibil
Hey Tony

One last thing on this subject..
What approach should I do when I want to start a conversation based on a variable true/false?

So meaning I have script which looks for enemy killed. When enemies are killed, the script goes in and set a variable from false to true.

Now when this is true, I want to fire of a conversation I have created with cutscene. Right now I just have a system trigger to initiate the conversation, but none of the available options in system trigger lets me starts the conversation based of a variable..

Hope you understand..



Thank you

Re: Access variable from c#

Posted: Sat Aug 06, 2022 8:19 pm
by Tony Li
Hi,

Take a look at the kill quest in DemoScene2. This post explains how it's set up. You can do the same but also make the Dialogue System Trigger start a conversation.