Access variable from c#

Announcements, support questions, and discussion for the Dialogue System.
hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post 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..

hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post by hrohibil »

Got it sorted out...

Looked at the documentation again :-)
hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post 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
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Access variable from c#

Post 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)
hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post 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.
hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post 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
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Access variable from c#

Post 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)
hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post by hrohibil »

Thank you Tony :D
hrohibil
Posts: 369
Joined: Thu Nov 04, 2021 12:50 pm

Re: Access variable from c#

Post 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
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Access variable from c#

Post 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.
Post Reply