Error while placing an modded entity

Place to get help with not working mods / modding interface.
User avatar
archdruidardanos
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Apr 11, 2017 12:02 am
Contact:

Error while placing an modded entity

Post by archdruidardanos »

Hi all,

i'm new in this community - and board search didn't come up with a result for such a problem - but i got some issue with a mod i try to get up and running - i got some issues placing a modded entity and getting this error:
Error while running event on_built_entity(ID6) __TESTMOD__/control.lua:10:bab argument #-1 to '__newindex'(number expected, got nil)
here is the content of my control.lua - if i got the error right the origin of the error should be around line 10 and it seems to expect a kind of index or a integer not given. could not find out which one at the moment.

Code: Select all

require ("util")

script.on_event(defines.events.on_built_entity, function(event)
	if event.created_entity.name == "windtrap_mk1" then
		local windtrap_mk1 = event.created_entity
		if global.windtrap_mk1 == nil
			then global.windtrap_mk1 = {}
		end
		table.insert(global.windtrap_mk1, windtrap_mk1)
		windtrap_mk1.fluidbox[1] = {type="wind", ammount=100, temperature=40}
	end
end)

script.on_event(defines.events.on_tick, function(event)
	if (game.tick % 25000) == 0 then
		global.temperature = math.random(0,40)
		game.player.gui.top.add{type="label",name="Info", caption=global.temperature}
	end
	update_windtraps()
end)

function update_windtraps()
	if global.windtrap_mk1 ~= nil then
		for index, windtrap in pairs (global.windtrap_mk1) do
			if windtrap.fluidbox[1] ~= nil then
				local x = windtrap.fluidbox[1]
				x["ammount"] = 100
				x["temperature"] = global.temperature
				windtrap.fluidbox = x
			else table.remove(global.windtrap_mk1, index)
			end
		end
	end
end
	
Hope anyone have hint for me,

thanks and regards
archdruid
Never trust a grinning admin!
If you see me running you better have a backup!
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Error while placing an modded entity

Post by Nexela »

"ammount" should be "amount"
User avatar
archdruidardanos
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Apr 11, 2017 12:02 am
Contact:

Re: Error while placing an modded entity

Post by archdruidardanos »

@Nexela:

oh seems it was to late yesterday to see that typo - thanks to point that out
Never trust a grinning admin!
If you see me running you better have a backup!
Post Reply

Return to “Modding help”