• Help-Wiremod + lua
    4 replies, posted
Is there any way to send a wire value to a value in lua script? Say I have a wired button, that when pressed, sends out 1. In a lua script, if the value equals one, it performs a function. But how would I retrieve the value? Also, how do I edit player respawn points?
You can make your entity have wire inputs by using the following code in ENT:Initialize [lua] self.Inputs = Wire_CreateInputs(self.Entity, {"NameOfFirstInput", "NameOfSecondInput", "NameOfThirdInput"}) [/lua] You can have any number of inputs, this is just an example with three. Then you need an ENT:TriggerInput function: [lua] function ENT:TriggerInput(name, value) if name == "NameOfFirstInput" then -- do stuff with value elseif name == "NameOfSecondInput" then -- do stuff with value elseif name == "NameOfThirdInput" then -- do stuff with value end end [/lua] Note that Wiremod will only call that function when the input changes. If you need to access the input more often than that you can use something like: [lua] -- in ENT:Initialize self.FirstInput = 0 -- in ENT:TriggerInput if name == "NameOfFirstInput" then self.FirstInput = value end -- somewhere else Msg("The value of the input is " .. tostring(self.FirstInput) .. "\n") [/lua]
[QUOTE=immibis;27699385]You can make your entity have wire inputs by using the following code in ENT:Initialize [lua] self.Inputs = Wire_CreateInputs(self.Entity, {"NameOfFirstInput", "NameOfSecondInput", "NameOfThirdInput"}) [/lua] You can have any number of inputs, this is just an example with three. Then you need an ENT:TriggerInput function: [lua] function ENT:TriggerInput(name, value) if name == "NameOfFirstInput" then -- do stuff with value elseif name == "NameOfSecondInput" then -- do stuff with value elseif name == "NameOfThirdInput" then -- do stuff with value end end [/lua] Note that Wiremod will only call that function when the input changes. If you need to access the input more often than that you can use something like: [lua] -- in ENT:Initialize self.FirstInput = 0 -- in ENT:TriggerInput if name == "NameOfFirstInput" then self.FirstInput = value end -- somewhere else Msg("The value of the input is " .. tostring(self.FirstInput) .. "\n") [/lua][/QUOTE] Thanks, this really helps, but how do I specify a specific entity?
What do you mean, a specific entity?
[QUOTE=immibis;27700244]What do you mean, a specific entity?[/QUOTE] nvm i figured out what i need to do
Sorry, you need to Log In to post a reply to this thread.