Page 1 of 1

Undergroud belt input/output belt_to_ground_type

Posted: Fri Nov 03, 2017 5:44 pm
by hreintke
Hi,'

Trying to create underground belts in a mod.

Right at the first I ran into the problem of setting the belt_to_ground_type of a belt.

For testing I run the following code

Code: Select all

/c
local p = {game.player.selected.position.x+1,game.player.selected.position.y+1}
local ne = game.player.surface.create_entity({name="underground-belt", force = "player", position=p , direction = 4, belt_to_ground_type = "output"})
game.player.print("ok..".. ne.name.." "..ne.belt_to_ground_type)
But when running this I try to create an "output" belt but the result is an "input".
For completeness.. Using belt_to_ground_type = "input" also creates an input.

Any hints on solving this ?

Re: Undergroud belt input/output belt_to_ground_type

Posted: Fri Nov 03, 2017 6:26 pm
by prg
LuaSurface.create_entity

It's just type, not belt_to_ground_type.

Re: Undergroud belt input/output belt_to_ground_type

Posted: Fri Nov 03, 2017 10:20 pm
by hreintke
Thanks.

Working now. Assuming to quickly. Expected to be able to set all properties of an entity at creation time. Need to read docs more carefully.

Also want to connect two underground belts that I create. Do you know how to achieve that ?

Re: Undergroud belt input/output belt_to_ground_type

Posted: Fri Nov 03, 2017 11:05 pm
by prg
If you create underground belts of the right type not too far apart and facing the right way, they should connect automatically.

Re: Undergroud belt input/output belt_to_ground_type

Posted: Fri Nov 03, 2017 11:35 pm
by hreintke
Hi,

Thanks again, Works like a charm.

Much easier than expected

Re: Undergroud belt input/output belt_to_ground_type

Posted: Sat Nov 04, 2017 11:10 pm
by darkfrei
hreintke wrote:Hi,

Thanks again, Works like a charm.

Much easier than expected
See also this autoreplacement mod
viewtopic.php?f=49&t=53580&start=20#p314979 (AutoUnderground_0.0.1.zip in attach)

Re: Undergroud belt input/output belt_to_ground_type

Posted: Sun Nov 05, 2017 10:29 am
by hreintke
Not (yet) in a mod but as a command to upgrade all underground-belts to fast-underground-belts.
Making use of the fast-replaceble possibility.

Code: Select all

/c
local surface = game.player.surface
local ent = "underground-belt"
local rep = "fast-underground-belt"
for c in surface.get_chunks() do
   for key, entity in pairs(surface.find_entities_filtered({area={{c.x * 32, c.y * 32}, {c.x * 32 + 32, c.y * 32 + 32}}, force = "player", name=ent})) do
			local d = entity.direction
			local p = entity.position
			local b = entity.belt_to_ground_type
			surface.create_entity({name=rep, force = "player", direction = d,  type = b, position=p, fast_replace=true, spill = false})
	end
end