Jump to content

Create a room in the cave (modworldgenmain.lua file)


Zeyn

Recommended Posts

Hello !

 

I have created some rooms for a mod, and i would like one of these rooms to be in the cave (underground). Here is the code i have made for now for this room (code in the modworldgenmain.lua) :

Layouts["box_thing"] = StaticLayout.Get("map/static_layouts/box")-- Remove the ring thing layout creating by defaultLayouts["TeleportatoBoxLayout"] = StaticLayout.Get("map/static_layouts/The_Nil_Piece")-- Add a room to the world that include the box thingAddRoom("box_thing", {                    colour={r=0,g=0,b=0,a=0},                    value = GLOBAL.GROUND.CAVE,                    tags = {},                    contents =  {                                    distributepercent = 0,                                    countstaticlayouts=                                    {                                        box_thing = 1,                                    },                                    distributeprefabs=                                    {                                    },                                }                    })task.room_choices["box_thing"] = 1

I have tried to change the value GLOBAL.GROUND with GLOBAL.UNDERGROUND but this won't works, this value is just to change the ground of the room.

 

Link to comment
Share on other sites

You know, i begin in modding, and what is simple for you is probably not for me. Could you explain me a little more ?

 

Excuse me, I assumed you knew what a task is beforehand. Don't Starves world generation basically works in these steps: levels (islands or worlds, if you will) -> tasks (branches) -> rooms (biomes) -> setpieces (you know these for sure)

 

As you can see,  you are making a tiny room for your setpiece (to assure one and only one spawns, I assume), and adding that room to a task. Depending on what task you add it to, it will appear in a different environment (e.g. "BefallowPlain" will put your setpiece nearby beefalos).

 

That's where the "task.room_choices" comes into play. The declaration of "task" determines the task your room ends up in, and by replacing it by others, you can control the area and even level your room appears in.

 

Here's a short list of some examples for cave tasks: BatCaves,TentacledCave,FungalPlain,Cavern

 

I hope this helps :encouragement:

Link to comment
Share on other sites

Thank you orian34 and Mobbstar for your help ! Effectively, i didn't knew what a task was, and that's much clear now. I think i will be able to do it with your help ! :joyous:
 

Link to comment
Share on other sites

Ok it works when i do this :

-- Add a room to the world that include the box thing AddRoom("box_thing", {                    colour={r=0,g=0,b=0,a=0},                    value = GLOBAL.GROUND.CAVE,                    tags = {},                    contents =  {                                    distributepercent = 0,                                    countstaticlayouts=                                    {                                        box_thing = 1,                                    },                                    distributeprefabs=                                    {                                    },                                }                    })local task = GLOBAL.tasks.GetTaskByName("BatCaves", GLOBAL.tasks.sampletasks)task.room_choices["box_thing"] = 1

But there are two main problems :

 

- This create a room with the box thing in each caves, so three box things

- The world can't be generated if there is no box thing on the "normal" world

 

I search solutions. If someone have an idea that can help, don't hesitate ! :ugeek: 

 

Link to comment
Share on other sites

Ok it works when i do this :

-- Add a room to the world that include the box thing AddRoom("box_thing", {                    colour={r=0,g=0,b=0,a=0},                    value = GLOBAL.GROUND.CAVE,                    tags = {},                    contents =  {                                    distributepercent = 0,                                    countstaticlayouts=                                    {                                        box_thing = 1,                                    },                                    distributeprefabs=                                    {                                    },                                }                    })local task = GLOBAL.tasks.GetTaskByName("BatCaves", GLOBAL.tasks.sampletasks)task.room_choices["box_thing"] = 1

But there are two main problems :

 

- This create a room with the box thing in each caves, so three box things

- The world can't be generated if there is no box thing on the "normal" world

 

I search solutions. If someone have an idea that can help, don't hesitate ! :ugeek:

perhaps adding some dirty trick when you generate the first cave that stays on until you change of island. It would deactivate the creation of the room...But i have no idea of how it would work...

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...