Inserter issue

Place to get help with not working mods / modding interface.
Post Reply
Nirahiel
Filter Inserter
Filter Inserter
Posts: 351
Joined: Mon Sep 23, 2013 2:18 pm
Contact:

Inserter issue

Post 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 ?

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Inserter issue

Post by kovarex »

Hello, I'm sorry the documentation was off, it is called heldstack, I corrected it on the wiki.

Nirahiel
Filter Inserter
Filter Inserter
Posts: 351
Joined: Mon Sep 23, 2013 2:18 pm
Contact:

Re: Inserter issue

Post 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.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Inserter issue

Post by kovarex »

Did you specify non zero count?

Nirahiel
Filter Inserter
Filter Inserter
Posts: 351
Joined: Mon Sep 23, 2013 2:18 pm
Contact:

Re: Inserter issue

Post 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 !

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Inserter issue

Post by ficolas »

Maybe there is allways an stack, try checking for the stack to be 0 instead?

Nirahiel
Filter Inserter
Filter Inserter
Posts: 351
Joined: Mon Sep 23, 2013 2:18 pm
Contact:

Re: Inserter issue

Post 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...

Post Reply

Return to “Modding help”