I want to create a tutorial for the Logistic Train Network mod that goes a few iteration going from simple setups to complex ones. For that a lot of infrastructure should be pre-set by the tutorial for each iteration.
I've already discovered that I can create a map in the map editor and copy the blueprints.zip to get an initial landscape. But how do I best add stuff as the user makes progress?
I saw that the base tutorials (eg the train one) have a table of ghost rails that they want to place and then a section in the story script places that table. Is that the best way to do this? And if so how do I create such a table without having to type it all out by hand? Is there a blueprint -> table tool or something? I need a lot of entities with circuit connections and programming. I really don't want to hand write that.
What if I want to change the terrain? Add some ore deposits for example. Or make the map larger?
Help creating a tutorial (creating maps/entities for each step)
Re: Help creating a tutorial (creating maps/entities for each step)
Take a look at the NPE map expansions. Afaik it has a "template" surface and just clones the chunks to the playing surface when the map expands. That way you can have even complex structures without writing long lua code to place them.
If you still want to go the table way, have a look at using some external script to decode blueprint strings and generating code for entities from there.
If you still want to go the table way, have a look at using some external script to decode blueprint strings and generating code for entities from there.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Help creating a tutorial (creating maps/entities for each step)
LuaItemStack.import_stack(blueprint_string)
LuaItemStack.build_blueprint{}
Works for machines, etc.
Not sure if you can (or should) abuse that to place whole regions of tiles for map extension.
And it definetly won't work for resources.
LuaItemStack.build_blueprint{}
Works for machines, etc.
Not sure if you can (or should) abuse that to place whole regions of tiles for map extension.
And it definetly won't work for resources.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Help creating a tutorial (creating maps/entities for each step)
Code: Select all
local blueprint_string = "0eNqVkcsKwjAQRf/lrlOIqVjJr4hIH0MdaNOSpGIp+XfTFETQRV3OzL1nXguqbqLRsvHQC7gejIO+LHDcmrJbc34eCRrsqYeAKfs1siV3CAJsGnpCH8JVgIxnz7T5UzDfzNRXZKPg7XQ+etu7zxJCYBxcdA1mbRVJUmCGzlQI4gui9kIylSgyDtiwpXorqR/IfC9yN/H436Zx0Xi6dFz98QuBB1mXxEUuD4U6KXnOQ3gBvbGPPQ=="
local chest = game.surfaces[1].create_entity{
name = "wooden-chest",
position = {0,0},
force = game.forces.player,
}
local inventory = chest.get_inventory(defines.inventory.chest)
inventory.insert("blueprint")
local blueprint = inventory.find_item_stack("blueprint")
blueprint.import_stack(blueprint_string)
local ghosts = blueprint.build_blueprint{
surface = game.surfaces[1],
force = game.forces.player,
position = {0,0},
force_build = true,
}
for _, ghost in pairs(ghosts) do
ghost.revive()
end
chest.destroy()
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Help creating a tutorial (creating maps/entities for each step)
Code: Select all
local function build_blueprint_string(blueprint_string,surface,position,force)
local bp = surface.create_entity{
name="item-on-ground",
position=position,
stack='blueprint'}.stack
if bp.import_stack(blueprint_string) ~= 0 then
error('Invalid or outdated blueprint string')
end
for _,entity in pairs(bp.build_blueprint{
surface = surface,
force = force,
position = position,
skip_fog_of_war = false,
force_build = true,
}) do
entity.silent_revive()
if entity.valid then entity.destroy() end
end
bp.clear()
end
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Help creating a tutorial (creating maps/entities for each step)
I just had a thought. Can't I create a map with multiple surfaces in the map editor and then teleport the player to each surface as needed?