I've been having an issue with, originally my script was on a variable named ticker that would add every time think would run, it's much better to use CurTime() so I'm trying to swap over to that but now when I try and run the same code block (that was originally in the ENT:Think() function, it doesn't like the fact i'm using self in the code.
Keep in mind the self that its referencing is the first of many self's in the block (I don't necessarily want to post that code)
Any help would be appreciated!
function SearchPrinters()
~code~here~
end
hook.Add( "Think", "na_HopperSearchDelay", function()
if CurTime() < delay then return end
SearchPrinters()
delay = (CurTime() + SearchTimer) -- SearchTimer is a config variable, set to 1
end )
[ERROR] addons/darkrpmodification/lua/entities/na_hopper/init.lua:97: attempt to index global 'self' (a nil value)
1. SearchPrinters - addons/darkrpmodification/lua/entities/na_hopper/init.lua:97
2. v - addons/darkrpmodification/lua/entities/na_hopper/init.lua:233
3. unknown - lua/includes/modules/hook.lua:84
I believe that the function SearchPrinters should be something like ENT:SearchPrinters in order to make it a function of the entity itself.
After doing that I'm getting this error, i tried to swap it with ENT:SearchPrinters() in the hook but no luck
[ERROR] addons/darkrpmodification/lua/entities/na_hopper/init.lua:233: attempt to call global 'SearchPrinters' (a nil value)
1. v - addons/darkrpmodification/lua/entities/na_hopper/init.lua:233
2. unknown - lua/includes/modules/hook.lua:84
I don't really know what is your code about nor it's structure, but you've mentioned that the code you have now in that Think function was originally in ENT:Think, right? Try to put it back there.
The code still works if that's what information you wanted from asking that
I just needed some time to process what you posted to see that I didn't need any more info about the code, sorry about that.
Anyways, have you tried what I suggested?
I fixed it, I just put the stuff inside of the hook into the think function.
Good, glad to hear that.
Sorry, you need to Log In to post a reply to this thread.