Page 1 of 1

Determining type of transport belt to ground

Posted: Fri Apr 10, 2015 1:14 pm
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?

Re: Determining type of transport belt to ground

Posted: Fri Apr 10, 2015 1:31 pm
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 

Re: Determining type of transport belt to ground

Posted: Fri Apr 10, 2015 1:36 pm
by kds71
Alas, event.createdentity.type value is also "transport-belt-to-ground", there is no indication whether it is input or output.

Re: Determining type of transport belt to ground

Posted: Fri Apr 10, 2015 1:43 pm
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 :?

Re: Determining type of transport belt to ground

Posted: Fri Apr 10, 2015 1:49 pm
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 :)

Re: Determining type of transport belt to ground

Posted: Fri Apr 10, 2015 8:53 pm
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