[0.16.51] Do not detect invalid/empty state inventory cell

Bugs that are actually features.
Post Reply
User avatar
regedit2000
Inserter
Inserter
Posts: 20
Joined: Mon May 23, 2016 4:00 pm
Contact:

[0.16.51] Do not detect invalid/empty state inventory cell

Post by regedit2000 »

Bug report

construction

Code: Select all

direct_driver=vehicle.get_inventory(defines.inventory.fuel) 
	if direct_driver[i] and direct_driver[i].valid

do not detect invalid/empty state inventory cell


1467.307 Script @__aai-programmable-vehicles__/control.lua:1824: inventory:: defines.inventory.fuel is present in [3] cells
1467.307 Script @__aai-programmable-vehicles__/control.lua:1825: inventory:: Index =1
1467.307 Script @__aai-programmable-vehicles__/control.lua:1828: inventory::containing:
1467.307 Script @__aai-programmable-vehicles__/control.lua:1830: y-infused-uca2=5
1467.307 Script @__aai-programmable-vehicles__/control.lua:1836: inventory::List:
1467.307 Script @__aai-programmable-vehicles__/control.lua:1840: cedll[1]=5 X y-infused-uca2
1467.764 Error MainLoop.cpp:1035: Exception at tick 4300: Error while running event aai-programmable-vehicles::on_tick (ID 0)
LuaItemStack API call when LuaItemStack was invalid.
stack traceback:
__aai-programmable-vehicles__/control.lua:1840: in function 'select_weapon'
__aai-programmable-vehicles__/control.lua:1898: in function 'unit_update_gun'
__aai-programmable-vehicles__/control.lua:2838: in function 'unit_update_state'
__aai-programmable-vehicles__/control.lua:4980: in function 'unit_tick'
__aai-programmable-vehicles__/control.lua:5017: in function <__aai-programmable-vehicles__/control.lua:4987

Code: Select all

local direct_driver=vehicle.get_inventory(def) -- get inventory from vehicle (iterate over all defines of inventory)
log("inventory::List: " )
				 for i=1, #direct_driver ,1 do

					 local s="false"
					 if direct_driver[i] and direct_driver[i].valid then -->> line :__aai-programmable-vehicles__/control.lua:18439:
						 log ("cell["..i.."]="..direct_driver[i].count.." X "..direct_driver[i].name) -->> 1467.764 Error MainLoop.cpp:1035: Exception at tick 4300: Error while running event aai-programmable-vehicles::on_tick (ID 0) LuaItemStack API call when LuaItemStack was invalid.

					 else
						 log ("cedll["..i.."]=".." empty ")
					 end
				 end
			log("direct_driver:: "..serpent.block(direct_driver.selected_gun_index) )
Plus:
[en]
the purpose of the modification: access to the management of weapons of transport from the program code (analog LuaPlayer.selected_gun_index)
guess: select the current weapon when you use different characters/players of the transport is preserved (in the transport)
goal: is not achieved

[ru]
цель модификации: доступ к управлению оружием транспорта из программного кода (аналог LuaPlayer.selected_gun_index)
предпосылки: выбор текущего оружия транспорта при использовании разными персонажами/игроками сохраняется (в самом транспорте)
цель: не достигнута

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [0.16.51] Do not detect invalid/empty state inventory cell

Post by Bilka »

I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
regedit2000
Inserter
Inserter
Posts: 20
Joined: Mon May 23, 2016 4:00 pm
Contact:

Re: [0.16.51] Do not detect invalid/empty state inventory cell

Post by regedit2000 »

Yes, sorry - I overlooked it :oops: . But is it possible to access the transport weapon switch as "selected_gun_index" :?: . "Guess" the current weapon can be read inventory with ammunition, which is also not very convenient :?

Post Reply

Return to “Not a bug”