[1.1.6] LuaPlayer.hand_location does not account for blueprint book inventories

Things that we don't consider worth fixing at this moment.
Post Reply
Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

[1.1.6] LuaPlayer.hand_location does not account for blueprint book inventories

Post by Xorimuth »

player.hand_location returns

inventory :: defines.inventory
slot :: uint

If you access hand_location whilst holding a blueprint in the 3rd slot of a blueprint book in the players inventory then it will have inventory = 1, slot = 3. If you then write that same information back to player.hand_location it will not behave as expected (and crash if there is already an item in the 3rd slot of the player's inventory).

This means that in certain situations

Code: Select all

player.hand_location = player.hand_location
will cause the mod to crash.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Rseding91
Factorio Staff
Factorio Staff
Posts: 13219
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.6] LuaPlayer.hand_location does not account for blueprint book inventories

Post by Rseding91 »

I'm not sure if this will get fixed. Adding read/write support for the hand location to the mod API was a "well I guess; if it works" but it has always been a super iffy thing to allow mods to touch.

The "fix" might be to just remove writing from the mod API.
If you want to get ahold of me I'm almost always on Discord.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: [1.1.6] LuaPlayer.hand_location does not account for blueprint book inventories

Post by Xorimuth »

Rseding91 wrote:
Fri Dec 18, 2020 5:03 pm
The "fix" might be to just remove writing from the mod API.
Please don't do that! I don't actually need to access the hand inside of blueprint books, it just came up because my mod was running a piece of code when it wasn't supposed to and I thought that it should be reported. Just a simple warning in the docs would be sufficient :)
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Post Reply

Return to “Won't fix.”