Page 1 of 1
Inserter issue
Posted: Wed Oct 09, 2013 8:33 am
by Nirahiel
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 ?
Re: Inserter issue
Posted: Wed Oct 09, 2013 10:53 am
by kovarex
Hello, I'm sorry the documentation was off, it is called heldstack, I corrected it on the wiki.
Re: Inserter issue
Posted: Wed Oct 09, 2013 11:19 am
by Nirahiel
kovarex wrote:Hello, I'm sorry the documentation was off, it is called heldstack, I corrected it on the wiki.
Ok !
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
Posted: Wed Oct 09, 2013 11:27 am
by kovarex
Did you specify non zero count?
Re: Inserter issue
Posted: Wed Oct 09, 2013 11:31 am
by Nirahiel
Yep, here is my code :
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
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 :
Code: Select all
i.entity.heldstack = {name = "raw-fish", count = 1}
works, where the code
Code: Select all
if not i.entity.heldstack then
i.entity.heldstack = {name = "raw-fish", count = 1}
end
does not !
Re: Inserter issue
Posted: Wed Oct 09, 2013 1:39 pm
by ficolas
Maybe there is allways an stack, try checking for the stack to be 0 instead?
Re: Inserter issue
Posted: Wed Oct 09, 2013 2:03 pm
by Nirahiel
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...