Jump to content

Recommended Posts

I want to add a prefab to spawn in already existing rooms. I've read through the worldgen guide but it doesn't seem that what I want to do is touched on anywhere there.

 

At first I thought I would simply need to make a task and apply it to those rooms, but after looking further into that it appears to adds a prefab to those rooms requires you access that room.

 

Also can anyone explain the relation of rooms -> biomes? Are the biomes just community created terminology to refer to rooms?

 

e.g. the forest biome is simply referring to  "map/rooms/terrain_forest".

Edited by Renarii

@Renarii, Biomes is a community created terminology referring to a location in game, e.g. Desert, Forest, Rocky, etc.. Rooms is the technical terminology used by the code itself. You will need to look in the scripts/maps/rooms folder at the terrains as well as all the rooms as these are what create the "biomes".

 

Please note that if you do add something via modworldgenmain.lua you will need to regenerate your world for it to show up properly.

@Renarii, you can access all the existing rooms with code like the following:

GLOBAL.require("map/terrain")for k, v in pairs(terrain.rooms) do    -- k is the key/index of the room.    -- v is the room table.end

You will still need to research what each of the rooms contents are and how each of them work. You can find all rooms in scripts/maps/rooms.

Alright, I've hit another snag from what I understand this should make bamboo now spawn in all the listed rooms.

local rooms = GLOBAL.terrain.roomslocal bamboorooms = {  BGMarsh=0.05,  Marsh=0.05,  SlightlyMermySwamp=0.05,  Forst=0.05,  Clearing=0.05,  ForestMole=0.05,  DeepForest=0.05,  CrappyDeepForest=0.05}for key, room in pairs(rooms) do  if bamboorooms[key] then    room.contents["distributeprefabs"]["bamboo"] = bamboorooms[key]  endend

However after running this and confirming that bamboo was listed in distributeprefabs correctly for those rooms I can't find it anywhere on the map. Does anyone know why it isn't spawning? At first I thought maybe the weight was to low but even after changing it to .9 I wasn't able to find it anywhere on the map.

Yup, it doesn't seem to have spawned c_gonext("bamboo") returns attempt to index a nil value in consolecommands.lua on line 419 which is where it's assigning the lastfound variable.

 

lastfound = found.GUID -- found is nil so throws an error
Edited by Renarii

@Renarii, this code should work.

local rooms = GLOBAL.terrain.roomslocal bamboorooms = {  BGMarsh=0.05,  Marsh=0.05,  SlightlyMermySwamp=0.05,  Forst=0.05,  Clearing=0.05,  ForestMole=0.05,  DeepForest=0.05,  CrappyDeepForest=0.05} for key, room in pairs(rooms) do  if bamboorooms[key] then    rooms[key].contents.distributeprefabs.bamboo = bamboorooms[key]  endend 
@Kzisor I see what you did there, but sadly it doesn't work. I've confirmed that the bamboo key is being added to distributeprefabs it just isn't showing up on the map anywhere. I can get it to spawn by using c_spawn("bamboo") and then it shows up correctly. Edited by Renarii

@Renarii, are you regenerating your world? New prefabs are only spawned in worldgeneration. Please post your mod and I will see what the issue is in the code, it is probably something really stupid. World generation code is finicky unlike other code. 

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
×
  • Create New...