[Solved]cancel_crafting error 'invalid crafting queqe index'

Place to get help with not working mods / modding interface.
Post Reply
User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

[Solved]cancel_crafting error 'invalid crafting queqe index'

Post by WIZ4 »

I'm trying to undo the player craft using this command:

Code: Select all

/c for i, option  in pairs(game.player.crafting_queue) do game.player.cancel_crafting({index=1,count=option['count']}) end
Craft is canceled, but I get an error.
before:
Screenshot_12.jpg
Screenshot_12.jpg (131.26 KiB) Viewed 848 times
after:
Screenshot_13.jpg
Screenshot_13.jpg (309.4 KiB) Viewed 848 times
This is probably due to the fact that if the intermediate product is canceled(blue slot), the main product is also canceled, and as a result, the main product index becomes invalid.
If in the crafting queue no intermediate products, the error does not appear.
I also tried using these indexes.But the result is even worse:

Code: Select all

/c for i, option  in pairs(game.player.crafting_queue) do game.player.cancel_crafting({index=option['index'],count=option['count']}) end
/c for i, option  in pairs(game.player.crafting_queue) do game.player.cancel_crafting({index=i,count=option['count']}) end
Screenshot_12.jpg
Screenshot_12.jpg (169.67 KiB) Viewed 848 times
Screenshot_14.jpg
Screenshot_14.jpg (340.93 KiB) Viewed 848 times
What should I do?
Last edited by WIZ4 on Thu Mar 21, 2019 11:41 am, edited 1 time in total.
My native language is russian. Sorry if my messages are difficult to read.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: cancel_crafting error 'invalid crafting queqe index'

Post by DaveMcW »

Code: Select all

/c
while game.player.crafting_queue do
  game.player.cancel_crafting{index=1, count=game.player.crafting_queue[1].count}
end

User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

Re: cancel_crafting error 'invalid crafting queqe index'

Post by WIZ4 »

Nice that worked! Thanks for your help
My native language is russian. Sorry if my messages are difficult to read.

Post Reply

Return to “Modding help”