Jump to content

[TUTORIAL] Making a Custom SetPiece


JackSlender
 Share

Recommended Posts

Ah, I apologize for not including all of the information on this page to begin with.  It was supposed to be an extraordinarily basic tutorial for people who wanted to have their stuff appear in the world.  Using as few functions and installations as possible was my goal.  I was going to build on it, but I have not gotten the chance to do anything Don't Starve related in a long time.

 

@Mobbstar Oh yeah, that's fine.  It's good that you're making it more accessible, honestly.

Link to comment
Share on other sites

This code should go into your modworldgenmain, a file in the same location as your modmain. If you do all of that, you should get something like this:

 

Where is this exactly in the game files? My indexing doesn't want to work, and i've looked in all the spots I thought it could be.

Link to comment
Share on other sites

I have a similar question to one already asked in this thread, but there doesn't seem to be an answer for it and the other guide doesn't answer the question either... So here I go. I want to make a small island. I want it to repeat only once. I successfully used this guide to setup a very basic set piece, but the set repeats. I want it to not do that once I actually form the island I want. How do I make it appear only once?

 

Also, if I plop only one wormhole onto my tiny island, will it link to one on the main world space automatically or no? How might I go about making that work if not? See edit #2.

 

This is intended for DST, if it matters. The basic set I made worked fine when testing it, but maybe adding in other codes will hurt compatibility.

 

Edit: By pure luck only I got a world spawn where it only existed once, but the island was attached to the world and not out in the ocean like it's supposed to be... ><

 

Edit 2: Found a workaround to getting an island made (not ideal though so please tell me the best way to do so), but I can't get the wormhole to work, even by adding a 2nd off onto the next shore. Any ideas on how I can get wormholes to work or what else I can do to make it work?

Edited by ShadowGX
Link to comment
Share on other sites

Here is an updated method that is extremely simple, fast, efficient and will allow everyone to create set pieces without the need or worry of having insane amounts of them spawn in the world.

 

Instructions:

  • Download this file: setpiece.lua
  • Place it in your mod folder.
  • Edit the following 'modimport' function to point to the file. IE: modimport( "setpiece.lua") if the file is in the root folder of your mod.
-- Table for functions to be inserted.

Map = {}modimport("directory/setpiece.lua") -- replace directory with location setpiece.lua is located.

--[[
    This function acts as a wrapper which we will use to add our custom layout as a set piece.
------------------------------------------------------------------------------------------------------------
level_id		-	Level Identification (LEVELTYPE.ALL, LEVELTYPE.SURVIVAL, LEVELTYPE.CAVE, LEVELTYPE.ADVENTURE, LEVELTYPE.TEST, LEVELTYPE.UNKNOWN, LEVELTYPE.CUSTOM)
layout_name 	-	The name of the layout which we will be adding, if the layout has not already been added we will add the layout.
layout_type			-	Layout Type (LAYOUT_TYPE.RANDOM, LAYOUT_TYPE.GROUND, LAYOUT_TYPE.ROOM) Default is LAYOUT_TYPE.RANDOM.
count			-	The amount of set pieces we want to spawn. Default is 1.
chance			-	The percentage change the layout will spawn. Default is 100.
terrain			-	Identification of the ground or room. Identification must coincide with the type or it will error out. Ground Example: GROUND.GRASS or GROUND.DIRT	Room Example: Badlands or BGGrass
--]]

-- The layout will automatically be loaded with this function, as long as the static_layout is located
-- in the proper folder directory: scripts/map/static_layoutsMap.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.GROUND, count, chance, GROUND.DIRT )
Map.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.GROUND, count, chance, "Any" )
Map.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.ROOM, count, chance, "Graveyard" )
Map.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.RANDOM )
  • Using the Map.CreateSetPiece function is easy.
    • These first (1st) argument being sent is the LEVEL you want to add it to.
    • The second (2nd) argument being sent is the static layout file which you exported with Tiled. Note: static_layouts reside in MODROOT/scripts/map/static_layouts
    • The third (3rd) argument being sent is the set piece type. GROUND means it will only spawn on that particular ground. ROOM means it will only spawn in that particular room. RANDOM means it can spawn randomly.
    • The fourth (4th) argument being sent is the amount of this set piece type you want to spawn.
    • The fifth (5th) argument being sent is the chance of this set piece spawning. Note: RANDOM does not need more than the first (1st) three (3) arguments.
    • The sixth (6th) argument being sent is the terrain type. GROUND.DIRT, GROUND.DECIDUOUS, etc. ROOM is the specific room name you wish the set piece to spawn inside. NOTE: "Any" is a special value for the LAYOUT_TYPE.GROUND which allows the set piece to spawn anywhere you want it based on your count/chance settings.

 

The extra download you will need to make is the Tile Set; while this tile set is specifically designed for Don't Starve Together, it will work in Don't Starve as long as you refrain from using non-existent tiles (IE: Scale).

  • Download the tile set here: Don't Starve Together Tileset.zip
  • In Tiled after creating a new map, go to Map -> Add External -> Navigate and Select 'Don't Starve Together Tileset.tsx'
  • NOTE: If you are creating your own custom tile you can give the tile a property of 'id', 'name', or 'tile_name' in Tiled with the value of the custom tile NAME you give it inside the game. Using the above setpiece.lua file will automatically set the ground tile in your custom setpiece to the custom ground tile.

Hopefully this helps people understand and use a really simple function and tile set to create truly custom set pieces.

 

Regards,

Kzisor/Ysovuka

 

Edit:

The setpiece.lua was not the proper file. I've uploaded the proper file.

Edited by Kzisor
  • Like 1
Link to comment
Share on other sites

You can use the files provided in this post to make mod friendly tiles for both Don't Starve and Don't Starve Together.

 

FILES:

tile.lua

 

CODE:

-- Table to put the functions in.
Map = {}modimport("directory/tile.lua") -- replace directory with location tile.lua is located.

--[[    This function acts as a wrapper which we will use to add our custom tiles.    
--------------------------------------------------------------------------
tile_name               -   Name of the tile which will be inserted into the GROUND table.
texture_name            -   The tiling style of the tile. See levels/tiles for the types.
noise_texture           -   Name of the noise texture file. Noise Textures are always located at MODROOT/levels/textures/
runsound                -   Sound which will be played when you run on the tile.
walksound               -   Sound which will be played when you walk on the tile.
snowsound               -   Sound which will be played when snow is on the tile.
mudsound                -   Sound which will be played when mud is on the tile.
flashpoint_modifier     -   Flashpoint at which items will begin to combust while on the tile.
--]]
Map.CreateTile( "EXAMPLE", "blocky", "noise_example", "dontstarve/movement/run_dirt", "dontstarve/movement/walk_dirt", "dontstarve/movement/run_ice", "dontstarve/movement/run_mud", 0)
  • Texture Files should always be placed in MODROOT/levels/textures
  • Only supply the file name without the extension, the file will automatically resolve.
  • tile_name can be UPPER or lower case, it will automatically resolve the the proper name.

 

Hope it helps people whom want to mod but, didn't understand how custom tiles worked.

 

Regards,

Kzisor/Ysovuka

Edited by Kzisor
Link to comment
Share on other sites

when I export to lua the data shows up as random characters instead of being formatted like it would be in game code.

 

ie

 

Jx1kEEKACAMwzZk3f9/rMKEHuIhCDZ2w4yI/KCB7t9Zh7aswLn5srxghqxH4PQg6/G3tD855JPz+xNiA6tUAQY

instead of a matrix set like this

 

10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0,

        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        10, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 10, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        10, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 10, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

 

Link to comment
Share on other sites

Please help!!!

local Layouts = GLOBAL.require("map/layouts").Layoutslocal StaticLayout = GLOBAL.require("map/static_layout")Layouts["PigPiece"] = StaticLayout.Get("map/static_layouts/PigPiece")AddRoomPreInit("Forest", function(room)    if not room.contents.countstaticlayouts then        room.contents.countstaticlayouts = {}    end    room.contents.countstaticlayouts["PigPiece"] = 1end)
please help! 

Malformed number near 1end

Link to comment
Share on other sites

On 3/10/2014 at 5:59 PM, JackSlender said:

Hey, guys, this tutorial is for people who would like to make a custom setpiece (i.e. a pre-generated chunk of land), but don't know the specifics of it.  The tutorial will be kind of long and elaborate, but hopefully it will be helpful.  It will require basic modding knowledge, and it is assumed that you already have your base mod (mod folder and modmain) set up.  Now let's start.

First half (setting up all of the properties):

 

Hidden Content

So, first we need to set up the proper program.  First things first, launch the Don't Starve Mod Tools.  You're going to need to launch Tiled.  Now this program is pretty powerful, but I'm only going to go over what you need to know.  You need to go to File, New.  This should bring up a little popup window like this:

post-343838-0-47706200-1394487164_thumb.

As the picture says, the two values on the left are the tile size of the setpiece.  We are going to set those to five for now.  The values on the right are the tile size.  Set those to sixty-four.  That will set up the basic map properties.

Now, we need to import the tileset.  This is just the compilation of tiles we use for our setpiece.  You'll actually have to download this for it to work:

tileset.zip

Now (if you've downloaded it) extract it to a familiar location such as your desktop.  Now go back into Tiled.  Select Map, Add External Tileset and not New Tileset.

post-343838-0-10745800-1394487167_thumb.

Now navigate to the place where you extracted the .zip file, and select ground.tsx.  This is our tileset.  If this works properly, you should see this in the bottom-right corner of your program:

post-343838-0-19402300-1394487170_thumb.

Next, we need to name our layers properly.  On the left-middle side, you should see a button titled Layers.  Click that, and above it you should see something titled Tile Layer 1.  Double click that and rename it to BG_TILES.  Next you should click this button:

post-343838-0-14896500-1394487176_thumb.

And select New Object Layer.  Name this layer FG_OBJECTS.  This is the last thing we need to do to set up the editor.  Now we move on to creating the actual tiles and objects.

 

Second half (building the setpiece)

 

Hidden Content

Now that we're all set up, we need to make some ground for our setpiece.  Make sure to select the BG_TILES layer, or this won't work.  Put your cursor over the tile you want (in the bottom-right corner) and click to select it.  For the sake of simplicity, I'll use grass.  Next, spread it around the middle of the screen simply by clicking and dragging.  It should hopefully look something like this:

post-343838-0-85633200-1394487172_thumb.

Wonderful, now we need to create some objects!  So you will need to select the FG_OBJECTS layer.  Make sure to highlight both of these, top one first:

post-343838-0-60216900-1394487178_thumb.

And click up here on this little rectangle thingy.

post-343838-0-00839800-1394487181_thumb.

Now, just click where you want the object to be located in relation to the tiles you placed earlier.  It should create a small, gray rectangle where you clicked.  Now, you should right click the rectangle, and click Object Properties.  It should bring up a little popup box.  Now type in the name of the prefab you want to create in the type box (I'm going to use researchlab so it stands out).  BE CAREFUL: if you type it in the name box, it WON'T WORK, so make sure to type it in the TYPE box.  I speak from experience, don't make that mistake.  After you've typed the name of your prefab in, press OK.  You can add as many objects as you like but for the sake of simplicity, I'll leave mine at one.

Once you're done with that, you're finally done (finally).  You should definitely save your work so you can modify it later, but the most important part is exporting it:

post-343838-0-77199100-1394487183_thumb.

This will export the file into code.  MAKE SURE it is set to .lua when you export it.  You need to export it to /yourmod/scripts/map/static_layouts/

That is where your setpieces will go.  I'm going to call mine rl (research lab).  At last, we are done.  With most of it.

 

 

Now all you need is to add a little bit of code to initialize it.  To finish, I'm going to show you how to add your setpiece to a biome (won't be making the biome).  Here's the code:


local Layouts = GLOBAL.require("map/layouts").Layoutslocal StaticLayout = GLOBAL.require("map/static_layout")Layouts["ResearchLab"] = StaticLayout.Get("map/static_layouts/rl")AddRoomPreInit("Forest", function(room)	if not room.contents.countstaticlayouts then		room.contents.countstaticlayouts = {}	end	room.contents.countstaticlayouts["ResearchLab"] = 1end)

This code should go into your modworldgenmain, a file in the same location as your modmain.  If you do all of that, you should get something like this:

post-343838-0-11415700-1394488587_thumb.

And voila!  You should have a working setpiece!  I apologize if this tutorial was hard to follow, but please tell me in the comments if you think I can edit it or make it better.  Thank you for reading!

setpiecemod.zip

Oh, I see this is an old tutorial but I would like to make a map with some in-game configurations (no hounds, no deerclops) to make a minigame map. I was planning to use Tiled to make the basic structure like terrain, but these in-game events can be turned off? Excuse me for any error, I'm from Brazil and I'm not fluent in English, but I think you can understand well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...