Jump to content

World Gen Data and Mod Changes


Recommended Posts

2 hours ago, Ipsquiggle said:

@Muche I tested this and saw that once a slot had savedata, when you selected that slot, it's mod configs would come from the savedata. (It's layered on top of the client data I believe, so you may see load messages in the log in all cases.) If you're moving between empty slots then it should use the client value, or the last viewed value if going to a slot for the first time. It's a little weird, but in the important case (having the correct saved config on an existing save slot) it appears to be correct. Have you noticed otherwise?

At first I thought it did that because of some old values that didn't upgrade correctly, but I tried it from the scratch and the log still says

Spoiler

[00:00:22]: QueryStats: { "req":"modrank", "field":"Session.Loads.Mods.list", "fieldop":"unwind", "linkpref":"external", "limit": 20}
[00:00:22]: Frontend-Unloading mod 'all'.	
[00:00:22]: loaded mod_config_data/modconfiguration_workshop-514078314	
[00:00:23]: FrontendLoadMod	workshop-514078314	
[00:00:23]: loaded mod_config_data/modconfiguration_workshop-514078314_CLIENT	
[00:00:23]: Fontend-Loading mod: workshop-514078314 (Turfed!) Version:1.2	
[00:00:23]: Mod: workshop-514078314 (Turfed!)	Loading modworldgenmain.lua	
[00:00:23]: modimport: ../mods/workshop-514078314/tile_adder.lua	
[00:00:23]: [Turfed] Settings: InsulatingTurfs=false, InsulationDuration=120, SanityTurfs=false, RainProtectingTurfs=false, SpeedyTurfs=false, SpeedyTurfSpeeds=1.25, EnableGameTurfRecipes=false, EnableTurfedTurfRecipes=true, EnableFlooringPlanting=false	
[00:00:32]: Frontend-Unloading mod 'all'.	
[00:00:32]: loaded mod_config_data/modconfiguration_workshop-514078314	
[00:00:33]: FrontendLoadMod	workshop-514078314	
[00:00:33]: loaded mod_config_data/modconfiguration_workshop-514078314_CLIENT	
[00:00:33]: Fontend-Loading mod: workshop-514078314 (Turfed!) Version:1.2	
[00:00:33]: Mod: workshop-514078314 (Turfed!)	Loading modworldgenmain.lua	
[00:00:33]: modimport: ../mods/workshop-514078314/tile_adder.lua	
[00:00:33]: [Turfed] Settings: InsulatingTurfs=false, InsulationDuration=120, SanityTurfs=false, RainProtectingTurfs=false, SpeedyTurfs=false, SpeedyTurfSpeeds=1.25, EnableGameTurfRecipes=false, EnableTurfedTurfRecipes=true, EnableFlooringPlanting=false	

 

The InsulationDuration option is set to 120 in modconfiguration_workshop-514078314_CLIENT, 99999999999999 in save slot 1 and 960 in save slot 2.

Attached is saveindex, _CLIENT config and some of mod's files (mod is being currently updated, included files are the different ones from version 1.1 that is available on the workshop). TurfedsConfigInUI.zip

Link to comment
Share on other sites

old code to get list of all tasks that will be used to generate the world.


local tasklist = require("map/tasks").sampletasks
local task_names = {}
  
for _, task in pairs(tasklist) do
   table.insert(task_names, task.id)
end  

this no longer has a table "tasklist" to insert stuff into.

I am trying to add layouts to any task on the map including modded in tasks from other mods. I have tried many things but I just don't understand enough.

Link to comment
Share on other sites

22 minutes ago, afetogbo said:

old code to get list of all tasks that will be used to generate the world.


local tasklist = require("map/tasks").sampletasks
local task_names = {}
  
for _, task in pairs(tasklist) do
   table.insert(task_names, task.id)
end  

this no longer has a table "tasklist" to insert stuff into.

I am trying to add layouts to any task on the map including modded in tasks from other mods. I have tried many things but I just don't understand enough.

Try

AddTaskSetPreInitAny(function(task_set_data)
    local task_names = task_set_data.tasks
    --// Do stuff with task_names, but note this must be done within this function.
end)

 

  • Like 1
Link to comment
Share on other sites

I was using an old code for set piece (not mine), but it isn't working anymore since the change. Since i don't understand this lvl of code, i'm not able to correct it.
If i want to add Set piece again, is there somewhere a code i can use or a way to do this ?

Link to comment
Share on other sites

  • Developer
12 hours ago, Kzisor said:

@Ipsquiggle, while you're looking into AddTile feature, please also look into making custom tiles be usable in custom Set Pieces.

Funny, while I was walking to work this morning thinking about AddTile, I thought, "Huh, I wonder how that works with setpieces?"

Thanks for all your thoughts here!

8 hours ago, Lumina said:

I was using an old code for set piece (not mine), but it isn't working anymore since the change. Since i don't understand this lvl of code, i'm not able to correct it.
If i want to add Set piece again, is there somewhere a code i can use or a way to do this ?

Can you post code showing what you were doing previously? That would help us to point you in the right direction!

  • Like 1
Link to comment
Share on other sites

@Ipsquiggle

If I may ask, what's your current schedule? I mean, how is your time currently divided between the worldgen data and modding API changes discussed here, bug fixing DST and working on Through the Ages? I ask mostly to have a feel for what kind of request is reasonable or not.

Edited by simplex
Link to comment
Share on other sites

  • Developer
12 hours ago, Muche said:

At first I thought it did that because of some old values that didn't upgrade correctly, but I tried it from the scratch and the log still says

The InsulationDuration option is set to 120 in modconfiguration_workshop-514078314_CLIENT, 99999999999999 in save slot 1 and 960 in save slot 2.

Aha! I found it. I was being misled by the dialogue box. This will be fixed in the next update.

Link to comment
Share on other sites

46 minutes ago, Ipsquiggle said:

Can you post code showing what you were doing previously? That would help us to point you in the right direction!

Sure,

Spoiler

-- GLOBAL variables which are needed.
local require = GLOBAL.require

--[[    Copyright © 2015 Ysovuka/Kzisor     ]]

-- The Layouts table is where we will add our set piece layout.
-- The file is provided in "scripts/map" of the original game.
local Layouts = require("map/layouts").Layouts

-- The StaticLayouts variable is used to get the layout of our set piece.
-- The file is provided in "scripts/map" of the original game.
local StaticLayouts = require("map/static_layout")

-- Thie LEVELTYPE table is used to indicate the level identification.
-- The file is provided in "scripts/map" of the original game.
require("map/level")
local LEVELTYPE = GLOBAL.LEVELTYPE
LEVELTYPE.ALL = "ALL"


-- This function acts as a wrapper which we will use to add our custom layout to the game.
-- The name of the layout will be identical to the filename.
local function AddLayout(name)
    -- Puts our layout in the Layouts table.
    Layouts[name] = StaticLayouts.Get("map/static_layout/"..name)

    -- We return the name and the layout for later usage.
    return name, Layouts[name]
end


-- This function acts as a wrapper which we will use to add our custom layout as a random set piece.
-- This function requires a Level Identification (LEVELTYPE.ALL, LEVELTYPE.SURVIVAL, LEVELTYPE.CAVE, LEVELTYPE.ADVENTURE, LEVELTYPE.TEST, LEVELTYPE.UNKNOWN, LEVELTYPE.CUSTOM).
local function AddRandomSetPiece(levelid, layout_name)
    -- Check to see if we want it on all level types.
    if levelid == LEVELTYPE.ALL then
        AddLevelPreInitAny(function(level)
            -- Ensure that we have a variable to store our data.
            if not level.random_set_pieces then
                level.random_set_pieces = {}
            end

            table.insert(level.random_set_pieces, layout_name)
        end)

    else -- We want it on a specific level type.
        AddLevelPreInit(levelid, function(level)
            -- Ensure that we have a variable to store our data.
            if not level.random_set_pieces then
                level.random_set_pieces = {}
            end

            table.insert(level.random_set_pieces, layout_name)
        end)
    end
end

-- This function acts as a wrapper which we will use to add our custom layout as a static set piece per level.
-- This function requires Level Identification (LEVELTYPE.ALL, LEVELTYPE.SURVIVAL, LEVELTYPE.CAVE, LEVELTYPE.ADVENTURE, LEVELTYPE.TEST, LEVELTYPE.UNKNOWN, LEVELTYPE.CUSTOM).
-- This function requires a list of tasks which can be located in "scripts/map/tasks.lua" file of the original game.
function env.AddSetPiece(levelid, layout_name, count, tasks, chance)
     
    -- Set chance to chance or 100 to ensure it spawns.
    chance = chance or 100

    -- Set count to count or 1 to ensure it spawns.
    count = count or 1
    
local function RandomChance()
        local _count = 0
 
        for i = 0, count do
            if (chance * 10) >= math.random(1, 1000) then
                _count = _count + 1
            end
        end
 
        return _count
    end
    -- Check to see if we want it on all level types.
    if levelid == LEVELTYPE.ALL then
        AddLevelPreInitAny(function(level)
            -- Ensure that we have a variable to store our data.
            if not level.set_pieces then
                level.set_pieces = {}
            end
 
            -- Initial set up.
            level.set_pieces[layout_name] = { count = 0, tasks = tasks }
 
            -- Add our layout to the room layouts ensuring at least one spawns.
            level.set_pieces[layout_name].count = RandomChance() or 0
        end)
 
    else -- We want it on a specific level type.
        AddLevelPreInit(levelid, function(level)
            -- Ensure that we have a variable to store our data.
            if not level.set_pieces then
                level.set_pieces = {}
            end
 
            -- Initial set up.
            level.set_pieces[layout_name] = { count = 0, tasks = tasks }

            -- Add our layout to the room layouts ensuring at least one spawns.
            level.set_pieces[layout_name].count = RandomChance() or 0
        end)
    end
end

-- This function acts as a wrapper which we will use to add our custom layout as a static set piece per room.
-- This function requires Room Idenficiation (A list of rooms can be found in rooms.lua).
-- The rooms.lua file is located in the root directory of this mod.
function env.AddRoomSetPiece(room_name, layout_name, count, chance)
     
    -- Set chance to chance or 100 to ensure it spawns.
    chance = chance or 100

    -- Set count to count or 1 to ensure it spawns.
    count = count or 1

local function RandomChance()
        local _count = 0
 
        for i = 0, count do
            if (chance * 10) >= math.random(1, 1000) then
                _count = _count + 1
            end
        end
 
        return _count
    end
 
    AddRoomPreInit(room_name, function(room)
        -- Ensure that we have a variable to store our data.
        if not room.contents.countstaticlayouts then
            room.contents.countstaticlayouts = {}
        end
 
        -- Initial set up.
        room.contents.countstaticlayouts[layout_name] = 0
 
        -- Add our layout to the room layouts ensuring at least one spawns.
        room.contents.countstaticlayouts[layout_name] = RandomChance() or 0
    end)
 
end

-- Initialize the task list.
require("map/tasks")
-- Obtain the global task list for usage.
local tasklist = require("map/tasks").sampletasks
-- This function will return all task names in the game, including those from mods.
local function GetTaskList()
    local task_names = {}
 
    for _, task in pairs(tasklist) do
       table.insert(task_names, task.id)
    end

    return task_names
end

-- Initialize our custom layout.
local set_piece_example_layout_name, set_piece_example_layout = AddLayout("set_piece_example")

AddSetPiece(LEVELTYPE.ALL, set_piece_example_layout_name, 1, GetTaskList(), 100)

Here is also a little mod using the setpiece as example if needed.

Mushroom.rar

Spoiler


[00:00:25]: [string "../mods/Mushroom - Old/modworldgenmain.lua"]:157: bad argument #1 to 'pairs' (table expected, got nil)    
[00:00:25]: @scripts/stacktrace.lua:130 in (global) StackTraceToLog (Lua) <129-132>
@scripts/util.lua:614 in () ? (Lua) <614-614>
   msg = [string "../mods/Mushroom - Old/modworldgenmain.lua"]:157: bad argument #1 to 'pairs' (table expected, got nil)
@=[C]:-1 in (global) pairs (C) <-1--1>
@../mods/Mushroom - Old/modworldgenmain.lua:157 in (local) GetTaskList (Lua) <154-162>
   task_names = table: 2B8D3D98
@../mods/Mushroom - Old/modworldgenmain.lua:167 in () ? (main) <0-0>
   require = function - =[C]:-1
   Layouts = table: 326DE2B0
   StaticLayouts = table: 326DDB58
   LEVELTYPE = table: 13A59CA0
   AddLayout = function - ../mods/Mushroom - Old/modworldgenmain.lua:23
   AddRandomSetPiece = function - ../mods/Mushroom - Old/modworldgenmain.lua:34
   tasklist = nil
   GetTaskList = function - ../mods/Mushroom - Old/modworldgenmain.lua:154
   mushrooms_little_farm_layout_name = mushrooms_little_farm
   mushrooms_little_farm_layout = table: 2B8D3208
@=[C]:-1 in (global) xpcall (C) <-1--1>
@scripts/util.lua:614 in (global) RunInEnvironmentSafe (Lua) <612-615>
   fn = function - ../mods/Mushroom - Old/modworldgenmain.lua:0
   fnenv = table: 326DC4D8
@scripts/mods.lua:473 in (method) InitializeModMain (Lua) <455-487>
   self =
      modnames = table: 13AE6C98
      worldgen = false
      failedmods = table: 14180F98
      currentlyloadingmod = Mushroom - Old
      records = table: 13AE6AB8
      enabledmods = table: 13AE6E28
      loadedprefabs = table: 13AE6BF8
      mods = table: 13AE6E78
   modname = Mushroom - Old
   env = table: 326DC4D8
   mainfile = modworldgenmain.lua
   safe = true
   fn = function - ../mods/Mushroom - Old/modworldgenmain.lua:0
   status = nil
   r = nil
@scripts/mods.lua:359 in (method) FrontendLoadMod (Lua) <335-362>
   self =
      modnames = table: 13AE6C98
      worldgen = false
      failedmods = table: 14180F98
      currentlyloadingmod = Mushroom - Old
      records = table: 13AE6AB8
      enabledmods = table: 13AE6E28
      loadedprefabs = table: 13AE6BF8
      mods = table: 13AE6E78
   modname = Mushroom - Old
   initenv = table: 1FF154D0
   env = table: 326DC4D8
   loadmsg = Fontend-Loading mod: Mushroom - Old (Mushrooms OLD) Version:0.5
   oldpath = scripts\?.lua;scriptlibs\?.lua;scripts/?.lua
@scripts/widgets/modstab.lua:701 in (method) OnConfirmEnable (Lua) <695-733>
   self =
      clientmodsbutton = Client Mods
      mainmenu = MENU
      shown = true
      last_server_modname = Mushroom - Old
      next_in_tab_order = function - scripts/screens/servercreationscreen.lua:84
      detailtitle2 = Text -
      detaildesc = Text -
      options_scroll_list_client = ScrollBar
      enabled = true
      top_mods_panel = ModsTab
      last_mod_click_time = 24000
      updatetask = PERIODIC updateforworkshop: 1.000000
      updateallenabled = false
      currentmodname = Mushroom - Old
      updateallbutton = BUTTON
      servermodsbutton = Server Mods
      currentmodtype = server
      name = ModsTab
      optionwidgets_client = table: 2BAE98F8
      focus_flow = table: 2B38FDA8
      detailcompatibility = Text - Compatible with Don't Starve Together.
      optionwidgets_server = table: 2BAE9A38
      detailimage = Image - ../mods/Mushroom - Old/modicon.xml:modicon.tex
      detailtitle = Text -
      modlinkbutton = BUTTON
      default_focus = Server Mods
      middle_line = Image - images/ui.xml:line_vertical_5.tex
      callbacks = table: 2B390028
      detailauthor = Text -
      detailpanel = detailpanel
      options_scroll_list_server = ScrollBar
      modnames_server_dl = table: 2BAE6EC8
      nav_bar = nav_bar
      mods_page = mods_page
      focus = true
      inst = 100521 -  (valid:true)
      modnames_server = table: 2BAE64F0
      modconfigable = false
      modnames_client_dl = table: 2BAE6B08
      focus_flow_args = table: 2B390550
      focus_target = false
      left_line = Image - images/ui.xml:line_vertical_5.tex
      parent = detail_panel
      focus_forward = Server Mods
      cleanallbutton = BUTTON
      modnames_client = table: 2BAE6540
      can_fade_alpha =
[00:00:25]: stack traceback:
    scripts/util.lua:614 in () ? (Lua) <614-614>
    =[C]:-1 in (global) pairs (C) <-1--1>
    ../mods/Mushroom - Old/modworldgenmain.lua:157 in (local) GetTaskList (Lua) <154-162>
    ../mods/Mushroom - Old/modworldgenmain.lua:167 in () ? (main) <0-0>
    =[C]:-1 in (global) xpcall (C) <-1--1>
    scripts/util.lua:614 in (global) RunInEnvironmentSafe (Lua) <612-615>
    scripts/mods.lua:473 in (method) InitializeModMain (Lua) <455-487>
    scripts/mods.lua:359 in (method) FrontendLoadMod (Lua) <335-362>
    scripts/widgets/modstab.lua:701 in (method) OnConfirmEnable (Lua) <695-733>
    scripts/widgets/modstab.lua:753 in (method) EnableCurrent (Lua) <735-756>
    scripts/widgets/modstab.lua:595 in (method) OnControl (Lua) <587-604>
    scripts/widgets/widget.lua:116 in (field) OnControl (Lua) <110-124>
    ...
    scripts/widgets/widget.lua:116 in (field) OnControl (Lua) <110-124>
    scripts/widgets/scrollablelist.lua:147 in (method) OnControl (Lua) <146-162>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (field) OnControl (Lua) <110-124>
    scripts/screens/servercreationscreen.lua:701 in (method) OnControl (Lua) <700-736>
    scripts/frontend.lua:329 in (method) OnControl (Lua) <313-371>
    scripts/input.lua:158 in (method) OnControl (Lua) <155-162>    
[00:00:25]: MOD ERROR: Mushroom - Old (Mushrooms OLD): Mod: Mushroom - Old (Mushrooms OLD)    
[00:00:27]:    EResult 15, 394470072

And here is the log message when i try to create a new world with this.

 

It was working fine before (even if the code wasn't supported anymore). I think that the problem is related to the recent update but i'm not skilled at codage at all, so i can't be sure...

Thanks for the answer, i appreciate it, whatever you can or cannot do to help me :)

 

I like set piece, i find that it's a great way to add news things to discover, so i would love to be able to add set piece again, but if it's something that require a too high lvl in coding, i will do without.

 

Thanks again :)

Edit : (And English isn't my native language, so sorry for all mistake and misunderstanding)

Edited by Lumina
Link to comment
Share on other sites

  • Developer
19 minutes ago, simplex said:

@Ipsquiggle

If I may ask, what's your current schedule? I mean, how is your time currently divided between the worldgen data and modding API changes discussed here, bug fixing DST and working on Through the Ages? I ask mostly to have a feel for what kind of request is reasonable or not.

The main priority right now is bug fixing in anticipation of leaving early access. The current burst of mod development was actually a response to refactoring rather than a specific mod system improvement, I just tried to take the opportunity to make things a little better along the way. Then it will be full steam into TTA. I'd say to not hold your breath on anything, but (and this goes out to all modders!) always feel free to @ me or Peter in this forum if you're running against specific deficiencies in the mod API or have suggestions for improvement. We tend to work on this when we have the chance, rather than by schedule, so it's good to have a backlocg of requests that we can help with!

Link to comment
Share on other sites

  • Developer
12 minutes ago, Lumina said:

It was working fine before (even if the code wasn't supported anymore). I think that the problem is related to the recent update but i'm not skilled at codage at all, so i can't be sure...

Thanks for the answer, i appreciate it, whatever you can or cannot do to help me :)

Yep, so it looks like I made that code kind of impossible in the last update. Basically, the list of tasks isn't available anymore, so you can't easily add the setpiece to "all tasks". In the next update, tasks.lua will have a function, GetAllTaskNames(), which gives you a list of all tasks, which can be used instead of the original task list.

I'm not sure what all may be broken in that code, though, so I would suggest that after the next hotfix comes out, start a new thread in this forum, and @ me in it and we'll see if we can work through the issues.

Link to comment
Share on other sites

8 hours ago, Ipsquiggle said:

Funny, while I was walking to work this morning thinking about AddTile, I thought, "Huh, I wonder how that works with setpieces?"

Thanks for all your thoughts here!

You're welcome, hope it will be of some help to you.

Link to comment
Share on other sites

@Ipsquiggle

I just went through and fixed Pickle It and have a question. Direct access to terrain.rooms is going away, but what about terrain.filter?

Pickle It adds new plants to the world and it looks like to prevent them from spawning on roads and what-not I'm doing this:

GLOBAL.terrain.filter.beet_planted = {GLOBAL.GROUND.ROAD, GLOBAL.GROUND.WOODFLOOR, GLOBAL.GROUND.CARPET, GLOBAL.GROUND.CHECKER, GLOBAL.GROUND.ROCKY, GLOBAL.GROUND.MARSH}

Will this stay accessible? Or will we be gaining a method similar to AddRoomPreInit() for modifying filters?

note: It's been about a year since I've really poked around DST mod code, so I don't remember exactly what's going on. Our new modworldgenmain.lua is accessible here, if you want to check it out: https://github.com/mariewest/Pickle-It-Dont-Starve-Together-Mod/blob/master/modworldgenmain.lua 

Link to comment
Share on other sites

  • Developer
On 4/9/2016 at 8:08 PM, simplex said:

This is only fringe-related to this topic, but is there a way to obtain a shard name from a shard id at the Lua level?

TheShard:GetShardId() Misread that, sorry. Checking... No, the name isn't available on the Lua side at the moment, sorry.

On 4/9/2016 at 4:35 PM, nickwest said:

Will this stay accessible? Or will we be gaining a method similar to AddRoomPreInit() for modifying filters?

note: It's been about a year since I've really poked around DST mod code, so I don't remember exactly what's going on. Our new modworldgenmain.lua is accessible here, if you want to check it out:

In the short term that will remain accessible, as I've run out of time to do something nicer for the moment. (When I do hide it, I'll definitely make it backwards compatible as I've done with terrain.rooms.) However, thanks for pointing it out!

The modworldgenmain.lua looks correct to my eyes, though. :)

  • Like 1
Link to comment
Share on other sites

  • Developer

Actually terrain.filters will probably remain accessible, as that's the correct place to specify a filter. The reason I changed terrain.rooms is because that was just the wrong way to get the list of rooms; our code was changed to not use that as well.

  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Ipsquiggle said:

Actually terrain.filters will probably remain accessible, as that's the correct place to specify a filter. The reason I changed terrain.rooms is because that was just the wrong way to get the list of rooms; our code was changed to not use that as well.

Awesome, thanks!

Link to comment
Share on other sites

On 4/12/2016 at 3:18 AM, Ipsquiggle said:

TheShard:GetShardId() Misread that, sorry. Checking... No, the name isn't available on the Lua side at the moment, sorry.

Has getting the shard name become a thing yet? I will eventually check all environment vars and/or scanning memory as needed... but for now I will have to use ShardId to save time.
(I will avoid making assumptions based on ismaster() in case someone has 3+shards.)

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