[0.12.8] can_insert always gives false.

Bugs that are actually features.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

[0.12.8] can_insert always gives false.

Post by matjojo »

EDIT: please read the second page from top, the first on on the second page explains my mistake

whilst working on EE2 I tried checking if there was space in the player's inventory. I did this this way:

Code: Select all

if game.player.can_insert{name = game.player.gui.left.EE_energy_condenser.EE_flow_item_selector.EE_label_item_selector.caption, count = 1} == true then
The caption is an always assigned item ID and well, the count is always 1.
I Always seem to get a return that was not true, these are the tested cases:

* player has space in main inventory and belt.
* player has space in main inventory but not in belt.
* player does not have space in main inventory but does have space in belt.
* player does not have space in main inventory and not in belt.

all the cases did not result in can_insert actually returning true. attached are the save and the mod files.

instructions to create a scenario in which the inv is not full and the command thinks it is.
1: give yourself an Energy condenser either with test mode (the pic is a wooden chest for now) or with the command(item name= energy-condenser)
2: grab two different items from somewhere, It can be every item
3: open the Energy condenser and click the "select item" button with an item of choice in hand.
4: grab the other item in your hand
5: press the button with this item in hand
6: see as the game prints the message "the player inventory seems to be full" (I made the mod give this message as the inv was full to check this bug's existence)
7: AFTER THIS THE GAME MIGHT CRASH DUE TO EE2 THIS IS JUST A PROBLEM IN THE MOD AND IS NOT ASSOCIATED WITH THIS BUG-REPORT
8: see as the game actually should not have detected a full inventory.

instructions for creating a scenario in which the command seems to work.
1: give yourself an Energy condenser either with test mode (the pic is a wooden chest for now) or with the command(item name= energy-condenser)
2: grab two different items from somewhere, It can be every item
3: open the Energy condenser and click the "select item" button with an item of choice in hand.
4: do this command: "/c game.player.cursor_stack.set_stack{name = "iron-plate", count= "5000000"}" (make sure to do this inside of the energy condenser)
5: place this stack in the Energy condenser inventory.
6: ctrl click this stack to fill the whole player inventory.
7: manually fill the whole player-belt. (clicking the 5mil stack will give you a full stack)
8: press the select item button with another item as that you have currently selected it with. (make sure to fill the spot it had in the player's inventory/belt (if you had it there))
9: see as the game prints the message "the player inventory seems to be full" (I made the mod give this message as the inv was full to check this bug's existence)
10: AFTER THIS THE GAME MIGHT CRASH DUE TO EE2 THIS IS JUST A PROBLEM IN THE MOD AND IS NOT ASSOCIATED WITH THIS BUG-REPORT
11: see as this worked, the inv was full and the command detected this.

other instructions you can probably think of yourself.
Laptop specs:
CPU: Intel Core i3-4005U 1.7GHZ
IGPU: Intel HD 4400
Motherboard: Unknown Laptop Motherboard
Disclaimer: I do have a second screen attached, it is attached thru HDMI. (unknown type)

I hope this post gave enough information. As always I'll gladly give omr information of necessary.
Attachments
Equivalent-Exchange_2.0.0.zip
EE2 mod files (you need to de-zip it first)
(5.47 KiB) Downloaded 147 times
modtesten.zip
the save file
(125.78 KiB) Downloaded 141 times
Last edited by matjojo on Fri Oct 02, 2015 4:14 pm, edited 1 time in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15896
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.12.8] can_insert always gives false.

Post by Rseding91 »

GuiElement::caption returns a localized string. Are you setting the button.caption to a literal string: "iron-ore" or the localized string name of iron-ore?
If you want to get ahold of me I'm almost always on Discord.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: [0.12.8] can_insert always gives false.

Post by matjojo »

Rseding91 wrote:GuiElement::caption returns a localized string. Are you setting the button.caption to a literal string: "iron-ore" or the localized string name of iron-ore?

currently I have it set to display the literal string, not the localised. is this wrong?

I mean should I insert the Localised string to can_insert? not if it's wrong on the button.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15896
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.12.8] can_insert always gives false.

Post by Rseding91 »

The literal string is what you want in this instance.

Have you tried printing the name of the caption where it would run in code to make sure the name is what you think it is?
If you want to get ahold of me I'm almost always on Discord.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: [0.12.8] can_insert always gives false.

Post by matjojo »

Rseding91 wrote:The literal string is what you want in this instance.

Have you tried printing the name of the caption where it would run in code to make sure the name is what you think it is?
well, assuming I also give the Item back according to the caption, Yes. The caption is good. this is the piece of the code defining the caption:

Code: Select all

game.player.gui.left.EE_energy_condenser.EE_flow_item_selector.EE_label_item_selector.caption = game.player.cursor_stack.name
this works.
and game.player.cursor_stack.name gives the literal name.
I don't need to print it because it actually is displayed on the label next to the button. So I know what it is.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.12.8] can_insert always gives false.

Post by Choumiko »

From your attached zip:

Code: Select all

if game.player.can_insert{name = game.player.gui.left.EE_energy_condenser.EE_flow_item_selector.EE_label_item_selector.caption, count = 1} == "true"
No "" around true :D
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: [0.12.8] can_insert always gives false.

Post by DaveMcW »

You don't need to compare == true, the value is already a boolean.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: [0.12.8] can_insert always gives false.

Post by matjojo »

Choumiko wrote:From your attached zip:

Code: Select all

if game.player.can_insert{name = game.player.gui.left.EE_energy_condenser.EE_flow_item_selector.EE_label_item_selector.caption, count = 1} == "true"
No "" around true :D
I tried both, I first just like you assumed it would be without "" but that didn't work, so I was like: "well, that's weird, it might be with "" then."
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: [0.12.8] can_insert always gives false.

Post by matjojo »

DaveMcW wrote:You don't need to compare == true, the value is already a boolean.

so it should be?:

Code: Select all

if game.player.can_insert{name = game.player.gui.left.EE_energy_condenser.EE_flow_item_selector.EE_label_item_selector.caption, count = 1} then
    --what to do when there is space
else
    --what to do if there's no space
end
I'll try this evening when I have time.
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.8] can_insert always gives false.

Post by kovarex »

Yes, and for the sake of the test, you should also try just

Code: Select all

if game.player.can_insert{name = "iron-plate", count = 1} then
    --what to do when there is space
else
    --what to
to find out where the error is.

I will put it to pending until it is clear it is a Factorio error.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: [0.12.8] can_insert always gives false. [not a bug]

Post by matjojo »

kovarex wrote:Yes, and for the sake of the test, you should also try just
--snip--
I will put it to pending until it is clear it is a Factorio error.
It indeed was a mistake at my side, not testing if == true did work.

My apologies for potentially taking some time and maybe even a little scare.
Post Reply

Return to “Not a bug”