"PrintName" of a nil value (bytecode local variable)
2 replies, posted
Hi,
Files:
loadouts.lua
cl_init.lua
loadouts.lua:
LOCKER_PRIMARY = {}
LOCKER_PRIMARY.AK47 = {
entity = "tfa_ak47",
name = weapons.Get(entity).PrintName,
model = "weapons.Get(entity).WorldModel",
}
cl_init.lua:
include("loadouts.lua")
print(LOCKER_PRIMARY.AK47.name)
Error:
[</DLib>] addons/weaponlocker/lua/entities/weaponlocker/loadouts.lua:9: attempt to index field "PrintName" of a nil value (bytecode local variable)
1. error - [C]:-1
2. __index - lua/dlib/core/funclib.lua:46
3. unknown - addons/weaponlocker/lua/entities/weaponlocker/loadouts.lua:9
4. include - [C]:-1
5. unknown - addons/weaponlocker/lua/entities/weaponlocker/cl_init.lua:2
I am also doing AddCSLuaFile("loadouts.lua") in the init.lua file.
When i change the name to a string, it works. However I want the model/name to get selected so all i have to fill out is the class of the weapon. I used weapons.Get().PrintName in another addon ive made and it worked fine so im not sure whats happening here.
Any help will be appreciated,
Thanks
weapons.Get is returning nil. In the code above you're passing the variable entity which you never define.
The print is called after the table is created, i have a button i press to print it. I have also tried
name = weapons.Get("tfa_ak47").PrintName,
so the variable entity shouldn't be the problem anymore, but i still get the same error.
The code I provided is not all of the code, just the relevant parts.
Sorry, you need to Log In to post a reply to this thread.