![]() |
|
Problem with "input" hook - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: Problem with "input" hook (/thread-2705.html) |
Problem with "input" hook - SharpOB - 28-05-2018 When using Code: hook.add("input","a",a)Code: a()Is this intentional behaviour and is there a way around this? I'd like my server to sent a net message to the client whenever any wire anything is changed - and the "input" hook looks like the right one for this but doesn't seem to work. I tried manually calling toClient() to send a net message to the client in my code - for when duped/updated - but for some odd reason the client recieved the correct new value which promptly changed to 0 - which is not correct. RE: Problem with "input" hook - Red The Blue Color - 29-05-2018 The input hook is only called when things are written to an input on the chip, not when things are wired to it. Just check the values when you start the chip, I don't think there is any bug here. RE: Problem with "input" hook - SharpOB - 29-05-2018 Right. Checking the values when I start my chip causes a really weird problem, but that might just be my code. What about when something is unwired and returned to nil? It didn't trigger the input hook - but i'd like my screens to act as if unwired in that case. Should I run a timer on them alongside the hook? I feel this might solve my problems but it doesn't sound very elegant. RE: Problem with "input" hook - Kosmos - 30-05-2018 The only time the hook is not triggered is when a duped or restarted, as the update happens before you can register your hook. You can compensate for that using Code: for _, v in pairs(wire.self():inputs()) do hook.run("input", v, wire.ports[v]) endRE: Problem with "input" hook - SharpOB - 30-05-2018 Thanks! |