Request API Help: Cursor_Stack set/reset

Place to get help with not working mods / modding interface.
Post Reply
Ecconia
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu May 10, 2018 5:26 am
Contact:

Request API Help: Cursor_Stack set/reset

Post by Ecconia »

Main issues (summary):
- Putting item from cursor back into inventory (exactly like 'q').
- Setting rotation of the cursor_stack (workaround "blueprint").

Problems:

- Putting item from cursor back into inventory:
-> Apparently there is a "clear()" function on the "cursor_stack" but it deletes anything in the cursor. There are also other functions, which I kind of am not sure how to use them. The desired functionality is the same as when someone presses 'q' in game. However can someone just get the count and put the item back into inventory, what if its a blueprint item, and not a Copy-Paste mode item, which is not present in the inventory... Has anyone dealt with this issue before?

- Setting rotation of the cursor_stack:
-> I want to set the current item with rotation which the player is hovering into the cursor_stack (just like pipette in game).
I read its not possible to set the rotation of the cursor_stack, since the cursor_stack is just the stack and not the actual cursor :/
There however is a way to set the cursor_stack to a blueprint and then add the desired item as entity in the blueprint, this does indeed allow rotation. But when doing that, one needs the exact location of the entity in the blueprint, which is not the global position, but the position relative to the cursor. Factorio itself has this feature built-in (using "Control+C" in game). But the API does not seem to have this feature as automatic service. So one has to generate the position by oneself.

- Removing the custom item/blueprint from the cursor:
-> This issue is not much of an issue, since when the mode is enabled, one can listen to changes of the cursor_stack and abort properly then. However if I am right, it should be possible to modify the cursor, by crafting that very item, or by building it (requires custom handling). And if its a blueprint I don't know how the game interacts with that. My desire of aborting are only two conditions pressing 'q' and on placing (if valid place).

Why/Mod:
My Mod: https://mods.factorio.com/mod/BuildMoveKeepWires with Github URL given.
The Mod basically has the goal of selecting an item (with keyboard-shortcut) and then placing that item. The effect should be the same of "moving" the entity. While it not only copies settings, but also reconnects wires. Basically the same as a pipette selection of a block with effect of putting the item into the cursor as if copied with 'Control+C' and on place it shall place that entity and remove the old entity. Inventory should stay unchanged.

Expected API functions:
I expected following functions in the API to make this baby-easy:
- Using 'pipette' on a location/entity via API.
- Creating blueprint items via API on global locations.
- Moving anything in the cursor_stack back to inventory like the 'q' press in game.

If anyone has tried something similar, or knows how to deal with this kind of issues, please help me :)
If someone knows the proper way to use the API to archive what I am trying to, please correct/tell me.
If its a developer who reads this, I am interested, if there are proper solutions for this, if not - worth implementing/adding?

Best regards, Ecconia
Factorio API doc is my sworn enemy who keeps me raging! One day I will delete/defeat you!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Request API Help: Cursor_Stack set/reset

Post by eradicator »

Ecconia wrote:
Sat Nov 23, 2019 4:18 pm
- Putting item from cursor back into inventory (exactly like 'q').
LuaPlayer.clean_cursor()
Ecconia wrote:
Sat Nov 23, 2019 4:18 pm
- Setting rotation of the cursor_stack (workaround "blueprint").
Impossible. Cursor rotation is not part of the game-state.

If you're just trying to move entities LuaEntity.teleport() might be a better approach. Also Picker Extended Dolly (name from memory) has a similar feature. Also moving script-controlled modded entities has a good chance that the other mod crashes if you mess up their entities.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”