Creating Assembly machine with integrated Electric pole

Place to get help with not working mods / modding interface.
Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

Thanks Julius :)
I was ready to update my mod with the german translation you provided, and a different thumbnail... but I don't see any button on mods.factorio.com to upload the next version.... Am I blind ? Should I upload it as a new mod ?

Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

I have spotted an error that generates a crash (on_entity_died, I though it would be the same as on_entity_mine, but there is no "player_index")

It's corrected on my side, but I must update my released mod.
For now, I just marked it as depreciated

julius1701
Inserter
Inserter
Posts: 33
Joined: Sun Dec 17, 2017 8:33 pm
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by julius1701 »

For updating a Mod click on 'my mods' select your mod, go to 'downloads' and click edit

Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

julius1701 wrote:
Tue Oct 29, 2019 9:29 am
For updating a Mod click on 'my mods' select your mod, go to 'downloads' and click edit
Thank you again

julius1701
Inserter
Inserter
Posts: 33
Joined: Sun Dec 17, 2017 8:33 pm
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by julius1701 »

Just ask if you need help

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

Re: Creating Assembly machine with integrated Electric pole

Post by eradicator »

regarding viewtopic.php?p=463562#p463562

1a) You can't.
1b) You can't.
1c) You can't.

Basically the overlay image "build preview" shown in the mouse cursor before building anything is not part of the game state and so mods have no control over it whatsoever. The only way you can change it is by hacking around with proxy-placement items like you already do.

Not sure if any of the events is early enough to fetch the info you'd need in a fast_replaceable_group scenario.

For the "pole graphic should be above machine" you can simply position the pole 1/256's tile south of the assembling machine.

2) Don't fucking drop stacks. I think it's the worst mechanic in the game and won't have any part in it. Items on the floor have shitty visibility and can contaminate belts etcpp. It's a mess. You should put excess items directly into the players inventory and fail if it's full. Use LuaInventory.can_insert().

For wire selectability you can make the fake pole selection_priority = 51. Assembling machines can not have wire connections.
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.

Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

1a) You can't.
1b) You can't.
1c) You can't.
:(. If it's really not manageable, this will always suck in my mod :(
For the "pole graphic should be above machine" you can simply position the pole 1/256's tile south of the assembling machine.
I remember you told so and I tried. but "position.x-0.1" doesn't work, it's concidered as "position.x-1"
moreover, it doesn't look necessary anymore
2) Don't fucking drop stacks. I think it's the worst mechanic in the game and won't have any part in it. Items on the floor have shitty visibility and can contaminate belts etcpp. It's a mess. You should put excess items directly into the players inventory and fail if it's full. Use LuaInventory.can_insert().
This is the current behaviour.
But regarding how pissed you are with this feature, and concidering how much you helped, I will put this "don't drop on floor" as an option in mod settings ;).
«Nothing is lost, everything is transformed, except if this option is checked » ^^

For wire selectability you can make the fake pole selection_priority = 51. Assembling machines can not have wire connections.
I will check that


I have an additional question:
Where can I put that, so my tables are initialized early enough to be modified by other mods, and still accessible in control.lua?
(I will provide a better function to feed those tables)

Code: Select all

local correspondancyTableMachineToProxy={}
local correspondancyTableProxyToMachine={}

local function initCorrespondancyTables()
	correspondancyTableMachineToProxy={}
	correspondancyTableMachineToProxy["assembling-machine-1"]="proxy-assembling-machine-pole-1"
	correspondancyTableMachineToProxy["assembling-machine-2"]="proxy-assembling-machine-pole-2"
	correspondancyTableMachineToProxy["assembling-machine-3"]="proxy-assembling-machine-pole-3"
	
	correspondancyTableProxyToMachine={}
	correspondancyTableProxyToMachine["proxy-assembling-machine-pole-1"]="assembling-machine-1"
	correspondancyTableProxyToMachine["proxy-assembling-machine-pole-2"]="assembling-machine-2"
	correspondancyTableProxyToMachine["proxy-assembling-machine-pole-3"]="assembling-machine-3"
end

Thank you !

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

Re: Creating Assembly machine with integrated Electric pole

Post by eradicator »

The "click a pole to upgrade in place" is an interesting idea, but yea. Mod api support is limited and simply adding crafting recipes to make pre-combined items is much easier.

South is "position.y+1/256" not x minus. Factorio uses screen coordinates where top is negative y.

Control stage is not a shared state like data/settings. If you want to allow other mods to add more combinations you'll have to use remote.add_interface() to expose access to the corresponding functions.
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.

Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

eradicator wrote:
Tue Oct 29, 2019 5:03 pm
The "click a pole to upgrade in place" is an interesting idea, but yea. Mod api support is limited and simply adding crafting recipes to make pre-combined items is much easier.
It would have been uncomplete without this feature. I'm happy that both mecanismes work fine... to bad it's not reflected on-mouse_over, but it's not a blocking issue
eradicator wrote:
Tue Oct 29, 2019 5:03 pm
South is "position.y+1/256" not x minus. Factorio uses screen coordinates where top is negative y.
:D correct. but it's the same for x and y, at least when using it in "surface.create_entity({name = newMachineName, position = position, ...}"
but earlier I have seen something about that : https://lua-api.factorio.com/latest/Con ... oundingBox
Position VS chunkPosition VS TilePosition.
TilePosition uses the same format as Position except it rounds any x/y down to whole numbers. I guess create_entity expect a TilePosition in parameter "position".
eradicator wrote:
Tue Oct 29, 2019 5:03 pm
Control stage is not a shared state like data/settings. If you want to allow other mods to add more combinations you'll have to use remote.add_interface() to expose access to the corresponding functions.
ok, thanks

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Bilka »

Alex33 wrote:
Tue Oct 29, 2019 5:26 pm
but earlier I have seen something about that : https://lua-api.factorio.com/latest/Con ... oundingBox
Position VS chunkPosition VS TilePosition.
TilePosition uses the same format as Position except it rounds any x/y down to whole numbers. I guess create_entity expect a TilePosition in parameter "position".
Create entity uses position. Entities may be grid aligned, meaning that they are placed either at integer or .5 coordinates (depending on entity size). Entities may be non-grid aligned, meaning that they are placed exactly where you put them. Examples for grid aligned entities: Assemblers, belts, power poles. Examples for non-grid aligned entities: Trees, landmines, cars. You can change whether an entity is grid aligned using the "placeable-off-grid" entity prototype flag.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

Bilka wrote:
Tue Oct 29, 2019 5:43 pm
Alex33 wrote:
Tue Oct 29, 2019 5:26 pm
but earlier I have seen something about that : https://lua-api.factorio.com/latest/Con ... oundingBox
Position VS chunkPosition VS TilePosition.
TilePosition uses the same format as Position except it rounds any x/y down to whole numbers. I guess create_entity expect a TilePosition in parameter "position".
Create entity uses position. Entities may be grid aligned, meaning that they are placed either at integer or .5 coordinates (depending on entity size). Entities may be non-grid aligned, meaning that they are placed exactly where you put them. Examples for grid aligned entities: Assemblers, belts, power poles. Examples for non-grid aligned entities: Trees, landmines, cars. You can change whether an entity is grid aligned using the "placeable-off-grid" entity prototype flag.
Ok, thanks you
Actually, Eradicator already mentioned the "placeable-off-grid" flag, and I tried to apply it, unsuccessfully. it worked when positioning the pylon alone or the proxy, but not when applying the pylon on existing machine, using my current mecanisme.
Anyway, I trust your judgment/knowledge, I made a mistake somewhere.
As another modification made it unnecessary and I stopped investigation, but maybe I will have to come back to it to extend the mod for the [2x2] entities.


I'm currently investigating about blueprint usage:
here is an unconvenient notice on (defines.events.)on_player_setup_blueprint, property mapping:
mapping :: LazyLoadedValue (dictionary uint → LuaEntity): The blueprint entity index to source entity mapping. Note: if any mod changes the blueprint this will be incorrect.
When player creates a blueprint, the proxy is not recognized (probably because the pylon is not selectable), so only the assembling machine is registered in event.mapping. I wanted to edit this mapping: for each assembling-machine, check if it's paired with a pylon, and if it is, change the registered entity.name. (defines.events.on_player_setup_blueprint,UpdateBlueprint).
it went well until the replace name part.
In case you think it's still manageable despite the warning, let me know, I can show you my tests...
otherwise, what do you think can be done to manage proxys in blueprints ? Is there a way to create and store some tables "LazyLoadedValue" (1 table per blueprint that contains proxy), and to retrieve it later, event if the player loads a saved game?

As usual, thank you very much !

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

Re: Creating Assembly machine with integrated Electric pole

Post by eradicator »

Actually i assumed that you don't need to manipulate blueprints. And why is the *proxy* even in a blueprint. And how does the player attach wires if the pole isn't selectable? Maybe i'm missing something

My assumption:
Proxy item is used to build real_asm + real_pole.
When player creates uses bp tool they get a bp that contains real_asm + real_pole.
Pole connections and recipe are thus automatically stored in bp.
Bots can then build both of them as they see fit, or you can make only the real_asm buildable and call .revive() on the pole in on_robot_built.

You'd only have to handle removal of ghosts (by mining or deconstruction) and make sure that removal of real_asm or real_pole ghost also removes it's counterpart.
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.

Alex33
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 24, 2019 11:56 am
Contact:

Re: Creating Assembly machine with integrated Electric pole

Post by Alex33 »

eradicator wrote:
Wed Oct 30, 2019 5:15 pm
Actually i assumed that you don't need to manipulate blueprints. And why is the *proxy* even in a blueprint.
The proxy currently not in the blueprint, there is only the machine.
I wanted to replace it by the proxy, so it's handled as a "build_proxy" feature by robots, with the actual build_proxy mechanisme
eradicator wrote:
Wed Oct 30, 2019 5:15 pm
And how does the player attach wires if the pole isn't selectable? Maybe i'm missing something
You're not missing anything... currently the player can't attach wires to the pole... it's one done automatically when placing it near an existing pole, or by adding an electric pole near it.

I will try to manage regarding your assumption, and check what happens if pole is selectable. I fear it will piss people off (including me) when they try to select the assembling machine, but hit the pole instead...

Then, I will try to manage blueprints as you explained.
Thank you Eradicator

Post Reply

Return to “Modding help”