Changing position of entity

Place to get help with not working mods / modding interface.
Stoosh
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jul 20, 2016 2:35 pm
Contact:

Changing position of entity

Post by Stoosh »

Hey all,

First time trying to mod factorio, I'm trying to build a mod which when placing certain items (belts, walls etc) and holding a modifier (not sure if that's possible yet), it will pin the x or y position depending on the direction of the placement. See attachment, trying to avoid the top example

I've tried to approach it a few different ways but don't seem to be able to get it

- Hooked into on_put_item and tried to change event.position values (not great anyway because mutating the event)
- Hooked into on_built_entity and tried to create another entity at +1 of the event.created_entity.position.x|y but appeared to cause an infinite loop
- Tried to call event.created_entity.teleport but it after reading the documentation is appears teleport only works for the player entity

Any ideas on another approach I could try?

Thanks!
Stoosh
Attachments
Screen Shot 2016-07-20 at 4.40.46 pm.png
Screen Shot 2016-07-20 at 4.40.46 pm.png (346.21 KiB) Viewed 2147 times
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 254
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Changing position of entity

Post by DedlySpyder »

You can't capture the player holding down a button, but you can make it a toggle.

As for moving it, you could just spawn a new one at the correct location and destroy the wrong one.

I'm not sure how on_built_entity caused an infinite loop tbh, because it shouldn't trigger on itself, AFAIK
Rseding91
Factorio Staff
Factorio Staff
Posts: 15965
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Changing position of entity

Post by Rseding91 »

Stoosh wrote:Hooked into on_built_entity and tried to create another entity at +1 of the event.created_entity.position.x|y but appeared to cause an infinite loop
Unless you did something wrong in your code and called some method in an infinite loop building entities in the on_built_entity event is fine. Script built entities don't trigger that event.

Stoosh wrote:Tried to call event.created_entity.teleport but it after reading the documentation is appears teleport only works for the player entity
Yes you can, you read the docs wrong. You however can't teleport belts, walls, pipes, and a few other things that use position logic to connect to other entities.
If you want to get ahold of me I'm almost always on Discord.
Stoosh
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jul 20, 2016 2:35 pm
Contact:

Re: Changing position of entity

Post by Stoosh »

Looks like it was a red herring with the on_built_item event, seems to be working now. Thanks!
Post Reply

Return to “Modding help”