[0.12.3]Automatic Building Placement Code

Tools which are useful for mod development.
Post Reply
jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

[0.12.3]Automatic Building Placement Code

Post by jorgenRe »

This little code i wrote for my mod The Underground is a way for you to create for example ruins that you want to spawn randomly around the map.
The building can be created in singleplayer and then copied to a file by using a command.
Lisence: Free :D!
But don't claim it's yours. Ok ^_^?

What does it let you do?
--Copy tiles
--Copy entities
--Easily changable to have it set certain entities as part of the player's force so the player can use it

How to add this functionality to your mod?
add to your mod
The first step is what i call uploading the building. It is basically when you have created a building you want to have later be spawned in the world.
And you now want to turn it into files that can be later read!
uploading building
8. Add this to the beginning of your control.lua file: (PS buildings.lab1 is an example location)

Code: Select all

readNames = require "buildings.lab1.names"
readPosX = require "buildings.lab1.positionsx"
readPosY = require "buildings.lab1.positionsy"
readTileNames = require "buildings.lab1.tileNames"
readTilePosX = require "buildings.lab1.tilePositionsx"
readTilePosY = require "buildings.lab1.tilePositionsy"
Then to place down the building where you want it you have to run the download functino
downloading
Upcoming
--Add in functionality for having more than one building. THough it is very easy to add, but time is running out and i can hint at it being a single extra if statement when downloading ;)!)
--Add in possibility for adding random loot to it. Should be possible with not too much changes though. ;)!
If ent.type == container then create entity, add loot code end
--Soon also i will trye and see if i can register the orientation of an object(i think i've seen that)
--Suggestions :D!
changelog
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

Post Reply

Return to “Development tools”