Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 5 6 7 8 9 … 18 Next »
Problem with "input" hook
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Problem with "input" hook
28-05-2018, 11:50 PM, (This post was last modified: 28-05-2018, 11:53 PM by SharpOB. Edited 3 times in total.)
#1
SharpOB Offline
TSCM Member
***
Posts: 37
Threads: 8
Joined: Apr 2017
Problem with "input" hook
When using
Code:
hook.add("input","a",a)
it seems that
Code:
a()
is not called when something is spawned already wired (think duping or updating/reloading) or when a wire is removed.

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.
Find
Reply
29-05-2018, 01:09 AM,
#2
Red The Blue Color Offline
TSCM Super Donating Member
****
Posts: 422
Threads: 34
Joined: Feb 2015
RE: Problem with "input" hook
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.

"with it's superior software, i have no doubt it will succeed in finding fuck all" - T-17, 2016

[Super Member] [ENCOM] т-ѕсм.Red The Blue Color™: server do you support Hitler?
[Server] srcds_linux: The probabilty is about 99.99%, so interpret that how you want to.
Find
Reply
29-05-2018, 06:35 PM,
#3
SharpOB Offline
TSCM Member
***
Posts: 37
Threads: 8
Joined: Apr 2017
RE: Problem with "input" hook
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.
Find
Reply
30-05-2018, 09:47 AM,
#4
Kosmos Offline
GMod Admin
Posts: 180
Threads: 3
Joined: Dec 2013
RE: Problem with "input" hook
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]) end
If you add a wire or remove it, the hook will get triggered.
Find
Reply
30-05-2018, 01:04 PM,
#5
SharpOB Offline
TSCM Member
***
Posts: 37
Threads: 8
Joined: Apr 2017
RE: Problem with "input" hook
Thanks!
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.