When I try this in game, here's what I get :
game.player.print(game.player.selected.name) >> basic-inserter
game.player.print(game.player.selected.helditem) >> ... unknown key helditem
Am I doing something wrong ?
Inserter issue
Re: Inserter issue
Hello, I'm sorry the documentation was off, it is called heldstack, I corrected it on the wiki.
Re: Inserter issue
Ok !kovarex wrote:Hello, I'm sorry the documentation was off, it is called heldstack, I corrected it on the wiki.
It works when I use it directly in the console, now in the control.lua, it tells me the stack has been set to what I want, but the inserter's hand looks still empty, like it doesn't update.
Re: Inserter issue
Did you specify non zero count?
Re: Inserter issue
Yep, here is my code :
First time it says the stack has been set, 2nd it says inserter still contains item, yet the inserter doesn't move.
EDIT : Oooooooh, i think I know where my error is, and if I'm right, then I'm an idiot, give me a sec !
EDIT 2 : Yeah, the problem was that i needed to use i.entity.heldstack, and not i.heldstack, i was a custom container with the actual insertor inside i.entity.
It does something now ! A good ol' crash.
Still trying to find why...
EDIT 3 : Looks like it doesn't like the entity.heldstack after all ..
EDIT 4 : Found out ! Looks like heldstack is a write only ?
The code : works, where the code does not !
Code: Select all
if i.heldstack == nil then
i.heldstack = { name = "raw-fish", count = 1}
game.player.print("Stack has been set to " .. i.heldstack.name .. " with an amount of " .. i.heldstack.count)
else
game.player.print("Inserter still containing " .. i.heldstack.name .. " with an amount of " .. i.heldstack.count)
end
EDIT : Oooooooh, i think I know where my error is, and if I'm right, then I'm an idiot, give me a sec !
EDIT 2 : Yeah, the problem was that i needed to use i.entity.heldstack, and not i.heldstack, i was a custom container with the actual insertor inside i.entity.
It does something now ! A good ol' crash.
Still trying to find why...
EDIT 3 : Looks like it doesn't like the entity.heldstack after all ..
EDIT 4 : Found out ! Looks like heldstack is a write only ?
The code :
Code: Select all
i.entity.heldstack = {name = "raw-fish", count = 1}
Code: Select all
if not i.entity.heldstack then
i.entity.heldstack = {name = "raw-fish", count = 1}
end
Re: Inserter issue
Maybe there is allways an stack, try checking for the stack to be 0 instead?
Re: Inserter issue
No it's not the case, wiki says to set it at nil to remove the stack.
And if the stack is 0, what item is it ?
Tried to just print the i.entity.heldstack, didnt get a nil or a "table" or anything, crash too...
And if the stack is 0, what item is it ?
Tried to just print the i.entity.heldstack, didnt get a nil or a "table" or anything, crash too...