• Loading a function locally?
    0 replies, posted
ok, here's my problem i have a folder containing lua files for all my different items for example: base_weapon.lua base_somethingelse.lua w_rock.lua w_log.lua These contain the information for sweps, and the inventory item in them, in tables w_rock.lua might look something like this SWEP={ primarydelay=something, secondarydelay=something, pdelaytimer=0, sdelaytimer=0, viewmodel="something", Think= function() if self.pdelaytimer<=0 then self.primaryattack() self.pdelaytimer=self.primarydelay end, primaryattack= function() end } thats just an example, function names would be correct to match with the ones in a swep, and would have to play around with the self.variablenames etc to get it to work but thats not the problem atm anyway it would be loaded into a swep something like this function SWEP:Initialize() for k,v in pairs(items[2].SWEP) do self[k]=v end end << the variables load fine, but the functions are loaded to be called from the original script The problem is, the functions are being treated as if it's still inside of the original item file (EG w_rock.lua) and not inside of the SWEP, meaning it cant use the variables inside of the SWEP, or inside of the original file for that matter because it is structured to be like it would be once it is inside of the swep my question is how can i set a function A to function B, and not just set function A to the address of function B, meaning function B is being called inside of another script i realise this is the way LUA is meant to work, i was just hoping there would be a method to get it working the way i want it to thanks
Sorry, you need to Log In to post a reply to this thread.