Undergroud belt input/output belt_to_ground_type

Place to get help with not working mods / modding interface.
hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Undergroud belt input/output belt_to_ground_type

Post 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 ?
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Undergroud belt input/output belt_to_ground_type

Post by prg »

LuaSurface.create_entity

It's just type, not belt_to_ground_type.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Re: Undergroud belt input/output belt_to_ground_type

Post 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 ?
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Undergroud belt input/output belt_to_ground_type

Post by prg »

If you create underground belts of the right type not too far apart and facing the right way, they should connect automatically.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Re: Undergroud belt input/output belt_to_ground_type

Post by hreintke »

Hi,

Thanks again, Works like a charm.

Much easier than expected
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Undergroud belt input/output belt_to_ground_type

Post 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)
hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Re: Undergroud belt input/output belt_to_ground_type

Post 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
Post Reply

Return to “Modding help”