Set belt_to_ground_type?

Place to get help with not working mods / modding interface.
LithDev
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 24, 2016 2:48 am
Contact:

Set belt_to_ground_type?

Post by LithDev »

So I am trying to make a new item (extraction-belt), implemented as a transport-belt-to-ground.
I have this in my Entity.lua:

Code: Select all

belt_to_ground_type = "output",
and this in my control.lua (where I am creating the extraction-belt entity):

Code: Select all

script.on_event(defines.events.on_built_entity, function(event)
	if event.created_entity.name == "extraction-belt" then
		table.insert(global.belt_extractors, event.created_entity)
		game.get_player(1).print("belt to ground type: " .. event.created_entity.belt_to_ground_type)
	end
end)
every time I place one in game, it outputs" belt to ground type: input".

Is there any way to set it up as an input, or do I need a work-around?
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Set belt_to_ground_type?

Post by Choumiko »

Try setting the type to output instead of printing the type. I think it's not intended for underground belts to only have an output.
LithDev
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 24, 2016 2:48 am
Contact:

Re: Set belt_to_ground_type?

Post by LithDev »

no dice, belt_to_ground_type is Read-Only
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Set belt_to_ground_type?

Post by Choumiko »

Oh right, try this one:

Code: Select all

script.on_event(defines.events.on_built_entity, function(event)
   if event.created_entity.name == "extraction-belt" then
    local old_e = event.created_entity
    local new_e = {name=old_e.name, direction=old_e.direction, position=old_e.position, force=old_e.force, type="output"}
    local surface = old_e.surface
    old_e.destroy()
    local created_entity = surface.create_entity(new_e)
    table.insert(global.belt_extractors, created_entity)
   end
end)
This will destroy the created entity and create a new one in the same spot with output as type. At least it should, haven't tested it.
You might need to adjust the direction if the belt ends up facing the wrong way.
LithDev
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Mar 24, 2016 2:48 am
Contact:

Re: Set belt_to_ground_type?

Post by LithDev »

This is ALMOST perfect. It places the right entity and everything (it did need to be rotated), but the sprite for pre-placing it is still wrong.
http://imgur.com/JgyjWfe
It's subtle enough that I'm not going to worry about it too much
Post Reply

Return to “Modding help”