Jump to content

Help with map gen and Alcehmy Engine


sarudak

Recommended Posts

So my ultimate goal is to remove the recipe for the Alchemy Engine and have one gen in each cave such that the player has to spend more time on teir 1 with limited tools and also provide more motivation  to explore the caves. Based on my reading of the code I need a static layout. I'm not sure I fully understand what's going on yet but it looks like each in vanilla code each file for static layout builds out some kind of data structure and returns it and then those are all stuffed in some kind of larger data structure indexed by string keys which are accessed later like so: 

 

countstaticlayouts={["MushroomRingMedium"] = function()  
if math.random(0,200) > 185 then 
return 1 
end
return 0 
  end},

 

So i don't know do I need to add my new static layout with the alchemy engine to the larger data structure or can I just pop is straight into the countstaticlayouts structure with a 1.

 

My first crack at adding them looked like 

 

GLOBAL.require("map/terrain")
 
GLOBAL.terrain.rooms.Stairs.contents.distributeprefabs.researchlab2 = 1
 
I expected this to have alchemy engines popping up like weeds but no dice. Am I doing something in particular wrong or did the 1 blow it's circuits?
 
As a side note how to remove recipes from being craftable?
 
Thanks much!
Link to comment
Share on other sites

I don't think you can remove recipes externally. You must kill it at its roots. Derp. That's why I didn't explain it further, because it's almost certainly wrong.

There is a set piece tutorial out there that should walk you through the creation of a set piece without overriding any files. But I don't know much about world gen, and I've never used that tutorial.

What I did, however, is adding a new, small biome, and have it spawn exactly one instance. It's essentially a set piece with random layout.

Link to comment
Share on other sites

Thanks I found that tutorial you referenced. (There's mod tools? O.o)

 

Anyway what did you mean about the recipes? You mean i would have to delete the original entry?

 

Not sure what he meant, but you should be able to remove any recipe by simply putting

GLOBAL.Recipes["researchlab2"]=nil

 

into modmain

Link to comment
Share on other sites

Where did you find the stairs room?  I believe your first chunk of code would work to some extent if you replace stairs with one of the biomes that appears in rooms/caves.lua.  If that doesn't work, than another simple way to do it is just make a tiny setpiece and bump up the spawnrate.

Link to comment
Share on other sites

@DeathDisciple: I'll try that!

 

@JackSlender: It's the room with the thelucite plug in the caves.lua file. Turns out my code actually worked but it had been disabled by a previous crash and I forgot to reenable it. What I actually want though is for one and only one alchemy engine to spawn per cave level. Kinda like how the things spawn. Bonus points if I can get it to spawn away from the entrance to the caves. I think a small setpiece is what I want.

Link to comment
Share on other sites

So following the tutorial I made this:

return {
  version = "1.1",
  luaversion = "5.1",
  orientation = "orthogonal",
  width = 1,
  height = 1,
  tilewidth = 64,
  tileheight = 64,
  properties = {},
  tilesets = {
    {
      name = "tiles",
      firstgid = 1,
      tilewidth = 64,
      tileheight = 64,
      spacing = 0,
      margin = 0,
      image = "../../../../tools/tiled/dont_starve/tiles.png",
      imagewidth = 512,
      imageheight = 256,
      properties = {},
      tiles = {}
    }
  },
  layers = {
    {
      type = "tilelayer",
      name = "BG_TILES",
      x = 0,
      y = 0,
      width = 24,
      height = 24,
      visible = true,
      opacity = 1,
      properties = {},
      encoding = "lua",
      data = {
        0
      }
    },
    {
      type = "objectgroup",
      name = "FG_OBJECTS",
      visible = true,
      opacity = 1,
      properties = {},
      objects = {
        {
          name = "",
          type = "researchlab2",
          shape = "rectangle",
          x = 26,
          y = 26,
          width = 0,
          height = 0,
          visible = true,
          properties = {}
        }
      }
    }
  }
}
 
and then attached it to a room like so:
 
Layouts["ResearchLab"] = StaticLayout.Get("map/static_layouts/SimplestAlchemyEngine")
 
AddRoomPreInit("BatCaveRoom", function(room)
    if not room.contents.countstaticlayouts then
        room.contents.countstaticlayouts = {}
    end
    room.contents.countstaticlayouts["ResearchLab"] = 1
end)
 
The first and immediate problem is that it shows the alchemy lab on the map but when I actually go to it there's nothing there.
The second is that this generates many alcemy engines in the caves when I really only want 1 or maybe 2.
 
Any thoughts?

 

Link to comment
Share on other sites

Ok the problem seems to be researchlab2. The code works fine with just researchlab. Not sure why. Maybe it has something to do with researchlab2 not being used in any static layouts? Maybe I need to add it to a dataset somewhere?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...