Jump to content

Flowgraph : pass variables


YouGroove
 Share

Recommended Posts

I was wandering, it is possible to pass variables between FlowGraphs ?

 

Or must we just search for the object pivot having the flowgraph, and read it's script parameters (this is what i done as i don't know if we can pass variables)

 

It would be great to be able to define general variables used in Flowgraph components.only and that they could share and use.

Stop toying and make games

Link to comment
Share on other sites

If you define an input as having some parameters, the connector line will show dots on it. One for each parameter in order form left to right. Then in the script that has the variable you want, make a getter function and put --arg at the end of the function name like:

 

function Script:GetHealth()--arg
return self.health
end

 

This getter will show up in the node and you can drag it to one of the parameters on the connector line. When the input is raised, the engine will call every getter function hooked up to each parameter for the input function.

 

So for an example, let's say the above function is part of your Player script, and that your Player script raises an OnHurt event. Let's also say you have a HUD.lua file that has an Input called UpdateHealth(value), where you want value to be the players health. You would hook up the Players OnHurt event to the HUD's UpdateHealth(), and 1 dot would show up in the middle of that connector line (because it has 1 parameter), where you would hook up Players:GetHealth() getter to this dot. Now when OnHurt is fired, it'll call GetHealth() and pass that value to UpdateHealth() and now your HUD can display that value for the players health. You've just passed the health variable from the Player script to the HUD script!

 

 

 

I agree, it would be pretty cool to have variables in the flowgraph as well, but again we can simulate this using this method. Each variable would just be node, and we'd make a script for the variable.

 

Variable script

Script.value = 0

function Script:GetValue()--arg
return self.value
end

 

It's not ideal but it could work.

 

 

I was playing around with an idea of making a script called GetProperty, where it has an exposed text property which would be the variable name you are after from a given script. It's a little confusing and is just easier to make a getter in the given script and make it --arg.

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...