Determining type of transport belt to ground

Place to get help with not working mods / modding interface.
Post Reply
kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Determining type of transport belt to ground

Post by kds71 »

When you create a transport belt to ground, you can specify whether it is input or output - wiki says:
createentity
Parameters:
...
Additional Entity-specific parameters
...
TransportBeltToGround
type ("output" or "input", defaults to "input")
Is there any way to read this property from a transport belt entity placed on the map? Obviously, entity.type property value is "transport-belt-to-ground". I can't find anything like that on wiki, but perhaps it exists in the game and is simply not listed there? Or is it not exposed to the LUA at all?

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Determining type of transport belt to ground

Post by Klonan »

I think something like

Code: Select all

game.onevent(defines.events.onbuiltentity, function(event)
if event.createdentity.name == "transport-belt-to-ground" then
game.player.print event.createdentity.type 
If you wanted to do something with it you could do like

Code: Select all

if event.createdentity.type == input
 then do stuff
else other stuff 

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: Determining type of transport belt to ground

Post by kds71 »

Alas, event.createdentity.type value is also "transport-belt-to-ground", there is no indication whether it is input or output.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Determining type of transport belt to ground

Post by Choumiko »

i guess you'll have to work with entity.direction. Find a belt to ground, get the direction, search for another belt to ground up to 4 tiles away and see if this has a direction that connects to the first one. Kind of messy :?

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: Determining type of transport belt to ground

Post by kds71 »

Thank you, that kind of workaround should work (in most cases :)), I'll try. Perhaps I should write about it in Modding Interface Requests subforum.

EDIT: While experimenting, I found another workaround - position of input and output belts to ground is slightly different, i.e. input belt with direction = east for tile -10, -10 will have position -10.25, -10.5, while output belt with same direction on same tile will have position -10.75, -10.5 - I guess I will use that :)

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Determining type of transport belt to ground

Post by Choumiko »

kds71 wrote:EDIT: While experimenting, I found another workaround - position of input and output belts to ground is slightly different, i.e. input belt with direction = east for tile -10, -10 will have position -10.25, -10.5, while output belt with same direction on same tile will have position -10.75, -10.5 - I guess I will use that :)
Ha, and there i was, looking at your code and wondering where the hell you're searching for the other belt to ground :D

Post Reply

Return to “Modding help”