Jump to content

How to send output to input?


CustomZ02
 Share

Recommended Posts

Still trying to understand how lua works. Im trying to create a script for an object to add health to the player. I created a USE that if enabled it would play a sound, but I also want it to output health to the receive health on the player script.

 

function Script:Use()
if self.enabled then
if self.sound then
self.entity:EmitSound(self.sound)
end
self.component:CallOutputs("Use")
end
end

 

Im assuming I want it inside the use function to then send to ReceiveHealth() im confused as to how that is done.

 

--Increase health
function Script:ReceiveHealth(healthPoints)--in
--Increase health
health = health + healthPoints;

--Health can not be more then maximum health
if health > maxHealth then
health = maxHealth
end

--Call Health received output
self.component:CallOutputs("HealthReceived")
end

Link to comment
Share on other sites

Inputs and outputs are used in the flowgraph. Open the flowgraph editor from the menu (Tools I think) and drag in any entity from your Scene tab that has a script attached and has input/output and they'll show up with little squares next to them. Click and hold these and drag outputs to inputs.

Link to comment
Share on other sites

Yeah I got that part here:

 

flo.PNG

 

What Im trying to figure out is how to tell the fpsplayer script how many healthpoints to receive from the healthpack. Cause I see the script in FPSPlayer is calculating health + healthpoints; but dont see how I send that value of healthpoints to FPSPlayer from the healthpack.

 

As you can tell im a bit confused, I tried to look up some other scripts to see how this would work but I couldnt find anything. Do I need to create a different output in my healthpack script named healthpoints?

Link to comment
Share on other sites

So we can pass parameters to inputs, and how we get those values are from get type functions. Let me see if I can remember how to do this.

 

Define a get type function in the script that holds the value you want like so:

 

function Script:GetHealth()--arg
end

 

Then define your input function to accept parameter(s) like:

 

function Script:UpdateHealth(health)--in
end

 

Then when you drag these into the flowgraph, the line should have a dot on it (1 dot for each input parameter). You should also see your get function now. Drag a line from the get to this dot. This means when your input is called, it'll also call the function(s) attached to each parameter to assign their value.

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