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
Changing position of entity
Changing position of entity
- Attachments
-
- Screen Shot 2016-07-20 at 4.40.46 pm.png (346.21 KiB) Viewed 2147 times
- DedlySpyder
- Filter Inserter
- Posts: 254
- Joined: Fri Jun 20, 2014 11:42 am
- Contact:
Re: Changing position of entity
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
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
Re: Changing position of entity
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: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
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.Stoosh wrote:Tried to call event.created_entity.teleport but it after reading the documentation is appears teleport only works for the player entity
If you want to get ahold of me I'm almost always on Discord.
Re: Changing position of entity
Looks like it was a red herring with the on_built_item event, seems to be working now. Thanks!