• Error in entity.lua
    4 replies, posted
Having an issue with money printers, here is the error: [code] [ERROR] lua/includes/extensions/entity.lua:157: bad argument #3 to 'SetFunc' (number expected, got nil) 1. SetFunc - [C]:-1 2. __newindex - lua/includes/extensions/entity.lua:157 3. DarkRPCreateMoneyBag - gamemodes/darkrp/entities/entities/spawned_money/init.lua:32 4. CreateMoneybag - gamemodes/darkrp/entities/entities/money_printer/init.lua:93 5. unknown - gamemodes/darkrp/entities/entities/money_printer/init.lua:77 [/code] It's referencing SetFunc, line 157 in entity.lua, so that can be found here: [code] meta.__newindex = function( ent, key, value ) local dt = datatable[ key ] if ( dt == nil ) then return end dt.SetFunc( self, dt.index, value ) <---- LINE 157 end [/code] Full entity.lua file can be found [URL="http://anyup.me/v/fplc"]here[/URL] I'm using the base DarkRP money printer code... Nothing changed. You can find that [URL="https://github.com/FPtje/DarkRP/tree/master/entities/entities/money_printer"]Here[/URL]. The money printers attempt to print money, but do not print anything and simply sit there and spark. Video of what happens can be found here: [video=youtube_share;j2O0KNZO7F4]http://youtu.be/j2O0KNZO7F4[/video]
The problem is dt.index not having a number .. I peeked at the script but it seems like dt.index isn't given a number at any point. I only saw this: "index = index" but since index isn't defined yet it sets it to nil. There are two ways you can fix this problem: - Defined index in the beginning of the script, like: dt.index = 0 Will define index as a number. - Change "if ( dt == nil ) then return end" to "if ( !dt or dt.index == nil ) then return end" Will block the rest of the script if index isn't defended yet. or both .. up to you :P
It is now saying this: [code] [ERROR] lua/includes/extensions/entity.lua:156: bad argument #3 to 'SetFunc' (number expected, got nil) 1. SetFunc - [C]:-1 2. __newindex - lua/includes/extensions/entity.lua:156 3. DarkRPCreateMoneyBag - gamemodes/darkrp/entities/entities/spawned_money/init.lua:32 4. CreateMoneybag - gamemodes/darkrp/entities/entities/money_printer/init.lua:93 5. unknown - gamemodes/darkrp/entities/entities/money_printer/init.lua:77 Timer Failed! [Simple][@gamemodes/darkrp/entities/entities/money_printer/init.lua (line 75)] [/code]
"if ( !dt or dt.index == nil or value ==nil ) then return end"
[QUOTE=Nak;39576951]"if ( !dt or dt.index == nil or value ==nil ) then return end"[/QUOTE] That fixed it! Thanks!! [editline]13th February 2013[/editline] So they print, but only in amounts of $0... interesting
Sorry, you need to Log In to post a reply to this thread.