Jump to content

Reviving a Set Piece Mod


Recommended Posts

So awhile ago I released a mod called Saber Lion Wilderness into the workshop, branching out from my usual character mods. But as quickly as it was released it was quickly discontinued because of how worldgen has changed. Luckily Lumina provided a nice guide to update the information in order to bring this mod back to life

And even though I got the gist of it I came out with this error:  #[string "scripts/map/object_layout.lua"]:185: No layout was provided!

And now im stumped on what to do next. The only thing i majorly touched upon on was my the modworldgenmain:

-- local require = GLOBAL.require
 
-- local Layouts = require("map/layouts").Layouts
-- local StaticLayout = require("map/static_layout")
-- local Tasks = require("map/tasks")
 
local Layouts = GLOBAL.require("map/layouts").Layouts -- load the table of existing layouts. we want to add our layouts
Layouts["SaberWildHome"] = GLOBAL.require("map/layouts/saberwildhome") 

AddTaskSetPreInitAny(function(tasksetdata)
    if tasksetdata.location ~= "forest" then -- this stuff is only for overworld  (of course you can also make it for caves or both)
        return
    end
    tasksetdata.set_pieces["Saber Wild Wilderness"] = { count = 2, tasks={"Great Plains",}} -- random task from this list is chosen for every count. So if there is no placing problem (masks) you will have it 2 times in the world
end)

-- AddLevelPreInitAny(function(level)
	-- if level.location ~= "forest" then -- only in overworld
		-- return
	-- end
	-- if level.ordered_story_setpieces == nil then -- if ordered_story_setpieces does not exist already, create it
		-- level.ordered_story_setpieces = {}
	-- end
	-- table.insert(level.ordered_story_setpieces, "Saber Wild Wilderness")
-- end)

What did I miss?

Edited by rons0n
Link to comment
Share on other sites

Uncommenting half the code leads to the same error. Im guessing something is wrong with my layout?

I skimmed through your examples and compared them to mine but I didnt see anything odd about it.

 

return {
  version = "1.1",
  luaversion = "5.1",
  orientation = "orthogonal",
  width = 10,
  height = 10,
  tilewidth = 64,
  tileheight = 64,
  properties = {},
  tilesets = {
    {
      name = "ground",
      firstgid = 1,
      filename = "../../../../../../../../../../Users/TohsakaRin/Desktop/tileset/ground.tsx",
      tilewidth = 64,
      tileheight = 64,
      spacing = 0,
      margin = 0,
      image = "../../../../../../../../../../Users/TohsakaRin/Desktop/tileset/tiles.png",
      imagewidth = 512,
      imageheight = 128,
      properties = {},
      tiles = {}
    }
  },
  layers = {
    {
      type = "tilelayer",
      name = "BG_TILES",
      x = 0,
      y = 0,
      width = 10,
      height = 10,
      visible = true,
      opacity = 1,
      properties = {},
      encoding = "lua",
      data = {
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5
      }
    },
    {
      type = "objectgroup",
      name = "FG_OBJECTS",
      visible = true,
      opacity = 1,
      properties = {},
      objects = {
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 65,
          y = 7,
          width = 123,
          height = 118,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 65,
          y = 255,
          width = 121,
          height = 131,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 63,
          y = 513,
          width = 128,
          height = 121,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 449,
          y = 5,
          width = 124,
          height = 120,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 450,
          y = 255,
          width = 123,
          height = 128,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 448,
          y = 512,
          width = 127,
          height = 125,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 257,
          y = 129,
          width = 124,
          height = 122,
          visible = true,
          properties = {}
        },
        {
          name = "",
          type = "saberwildhome",
          shape = "rectangle",
          x = 256,
          y = 388,
          width = 124,
          height = 120,
          visible = true,
          properties = {}
        }
      }
    }
  }
}
 

Edited by rons0n
Link to comment
Share on other sites

Here are some examples of set piece i have using Serpens code :



local Layouts = GLOBAL.require("map/layouts").Layouts -- load the table of existing layouts. we want to add our layouts
Layouts["Fairy Ring"] = GLOBAL.require("map/layouts/fairy_ring")
Layouts["Base Debris"] = GLOBAL.require("map/layouts/base_debris")

AddLevelPreInitAny(function(level)
    Layouts["Fairy Ring"].fill_mask = GLOBAL.PLACE_MASK.IGNORE_IMPASSABLE_BARREN
    Layouts["Base Debris"].fill_mask = GLOBAL.PLACE_MASK.IGNORE_IMPASSABLE_BARREN
end)

AddTaskSetPreInitAny(function(tasksetdata)
    if tasksetdata.location ~= "forest" then -- this stuff is only for overworld  (of course you can also make it for caves or both)
        return
    end
    tasksetdata.set_pieces["Fairy Ring"] = { count = 2, tasks={"Befriend the pigs","Forest hunters", "For a nice walk", "Magic meadow",}} -- random task from this list is chosen for every count. So if there is no placing problem (masks) you will have it 2 times in the worl
    tasksetdata.set_pieces["Base Debris"] = { count = 2, tasks={"Befriend the pigs","Forest hunters", "For a nice walk", "Magic meadow",}} -- random task from this list is chosen for every count. So if there is no placing problem (masks) you will have it 2 times in the world

end)

In modworldgenmain.lua

Fairy ring :

require("constants")
local StaticLayout = require("map/static_layout")

return					 {
                            type = LAYOUT.CIRCLE_EDGE,
                            defs =
                                {
                                     unknown_plant = { "red_mushroom", "green_mushroom", "blue_mushroom", "flower_evil"},
                                },
                            count =
                                {
                                    unknown_plant = 15,
                                },
                            scale = 1.5
                        }

In map/layouts/fairy_ring

Base debris :

require("constants")
local StaticLayout = require("map/static_layout")

return  StaticLayout.Get("map/static_layout/debris_base",
      {
      start_mask = PLACE_MASK.NORMAL,
      fill_mask = PLACE_MASK.IGNORE_IMPASSABLE_BARREN,
      layout_position = LAYOUT_POSITION.CENTER,
      defs = -- Define a choice list for substitution below
          {
              randomdebris = { "rocks", "debris_potted_fern", "debris_plank", "pottedfern" },
              randomdebris2 = { "rocks", "debris_potted_fern", "debris_plank", "pottedfern" },
          },
      })

in map/layouts/base_debris.lua

Debris base :

return {
  version = "1.1",
  luaversion = "5.1",
  orientation = "orthogonal",
  width = 7,
  height = 7,
  tilewidth = 64,
  tileheight = 64,
  properties = {},
  tilesets = {
    {
      name = "ground",
      firstgid = 1,
      filename = "D:/Steam/steamapps/common/Don't Starve Mod Tools/mod_tools/Tiled/dont_starve/ground.tsx",
      tilewidth = 64,
      tileheight = 64,
      spacing = 0,
      margin = 0,
      image = "D:/Steam/steamapps/common/Don't Starve Mod Tools/mod_tools/Tiled/dont_starve/tiles.png",
      imagewidth = 512,
      imageheight = 384,
      properties = {},
      tiles = {}
    }
  },
  layers = {
    {
      type = "tilelayer",
      name = "BG_TILES",
      x = 0,
      y = 0,
      width = 7,
      height = 7,
      visible = true,
      opacity = 1,
      properties = {},
      encoding = "lua",
      data = {
        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
      }
    },
    {
      type = "objectgroup",
      name = "FG_OBJECTS",
      visible = true,
      opacity = 1,
      properties = {},
      objects = {
        {
          name = "randomdebris",
          type = "randomdebris",
          shape = "rectangle",
          x = 177,
          y = 179,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        },
        {
          name = "debris_plank",
          type = "debris_plank",
          shape = "rectangle",
          x = 166,
          y = 237,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        },
        {
          name = "randomdebris",
          type = "randomdebris",
          shape = "rectangle",
          x = 246,
          y = 257,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        },
        {
          name = "debris_campfire",
          type = "debris_campfire",
          shape = "rectangle",
          x = 219,
          y = 213,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        },
        {
          name = "debris_cookpot",
          type = "debris_cookpot",
          shape = "rectangle",
          x = 244,
          y = 159,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        },
        {
          name = "randomdebris2",
          type = "randomdebris2",
          shape = "rectangle",
          x = 294,
          y = 192,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        }
      }
    }
  }
}

In map/static_layout/debris_base.lua

Important note :

In Serpens code you need a layout (in map/layouts) to add indirectly your static_layout, you don't add the static_layout directly (maybe it could work, but untested, so i use the method provided)

In my code, one of the directory is "static_layout", because an old code i'm using used it as directory name and it was easier to adapt rather than replacing old name (less risk of error, so i was lazy), but original code use "static_layouts" as directory. So be careful if you copy/paste part of my code to have the right names at the right place.

 

For example :

require("constants")
local StaticLayout = require("map/static_layout")

["SimpleBase"] = StaticLayout.Get("map/static_layouts/simple_base", {  -- load the static layout
                            areas = {
                                construction_area = function() return PickSome(2, { "birdcage", "cookpot", "firepit", "homesign", "beebox", "meatrack", "icebox", "tent" }) end, -- picksome is a function defined in util.lua, it will pick 2 random things from the list
                            },
                        })

Here you have a file required ("map/static_layout"), and a path ("map/statics_layouts/simple_base").

(Oh and i should change some things in my code, i didn't know this function).


I hope it's clear, good luck. Also, verify i don't miss some line, like GLOBAL.require("map/tasks"), my code is a little messy since i already have some line in others place. Use Serpens example if you have line missing or stuff like this.

Edited by Lumina
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...