Jump to content

how do i force wrold setting via modmain asdsdf


Recommended Posts

You can force the most settings within modworldgenmain.lua (create it in your modfile where also modmain.lua is).

There you add:

AddTaskSetPreInitAny(function(tasksetdata)
    if tasksetdata.location == "forest" then
        tasksetdata.overrides={
            world_size  =  "small",
            wormhole_prefab = "wormhole",
            layout_mode = "LinkNodesByKeys",
            season_start  =  "autumn",
            autumn = "veryshortseason",
            winter = "veryshortseason",
            spring = "veryshortseason",
            summer = "veryshortseason",
        }
    end
end)

I noticed you always have to include wormhole_prefab and layout_mode, otherwise game will crash. All other things are optionally. You can find the possible options here:
Don't Starve Together\data\scripts\map\customise.lua

______________________________________________________________________________

Setting game mode and if caves should be active is a bit more complicated.
For caves I added this workaround:

        if tasksetdata.location=="cave" then
            tasksetdata.tasks = {"CaveExitTask1"}
            tasksetdata.numoptionaltasks = 0
            tasksetdata.optionaltasks = {}
            tasksetdata.set_pieces = {}
            tasksetdata.valid_start_tasks = {"CaveExitTask1"}
            tasksetdata.overrides={
            world_size  =  "small",
            wormhole_prefab = "wormhole",
            layout_mode = "LinkNodesByKeys",
            }
        end


This means, even if cave will exist, it will be totally empty.


The workaround for the mode was to let the game crash, if the wrong mode is active :D
 

if _G.TheNet:GetServerGameMode() ~= "adventure" then
    print("You have to choose adventure as game mode!! "..errortoabortgame) -- errortoabortgame is nil and can't be added to a string, it will cause a crash
end

From what I know you can't set the mode, but you can change the mode details.
So instead forcing to use survival, you can change any choosen mode to work like survival:
I copied this code somewhere:
 

-----------spawn mode------------------------------------------------
-- local SpawnMode = GetModConfigData("spawn_mode")

-- GLOBAL.GAME_MODES["custom_game"].spawn_mode = SpawnMode


----------ghost sanity drain--------------------------------------------
-- local GhostSanityDrain = GetModConfigData("ghost_sanity_drain")

-- GLOBAL.GAME_MODES["custom_game"].ghost_sanity_drain = GhostSanityDrain

-----------ghost enabled------------------------------------------------
-- local GhostEnabled = GetModConfigData("ghost_enable")

-- GLOBAL.GAME_MODES["custom_game"].ghost_enabled = GhostEnabled

----------------reset timer-----------------------------
-- local ResetTime = GetModConfigData("reset_time")

-- if ResetTime then
    -- GLOBAL.GAME_MODES["custom_game"].reset_time = { time = 120, loadingtime = 180 }
-- end

-------------------------poratl revival------------------------------

-- local PortalRez = GetModConfigData("portal_rez")

-- GLOBAL.GAME_MODES["custom_game"].portal_rez = PortalRez

-----------------banned items-----------------------------------------
-- local BanResItems = GetModConfigData("ban_rez")

-- if BanResItems then
    -- GLOBAL.GAME_MODES["custom_game"].invalid_recipes = { "reviver", "lifeinjector", "amulet", "resurrections" }
-- end

 

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