Jump to content

October 22nd Modding Preview


Recommended Posts

  • Developer

Hey everymodder! Here's a more detailed version of this week's preview changelist for modding, with examples!

Mod System:

Mods which overwrite core game assets have usually crashed the game unless the game is restarted once. Now a mod can specify this to force the game to restart when the mod is loaded.

-- in modinfo.lua-- This is required if you overwrite certain core assets and animations, the game-- will crash if it's not started up with your mod enabled. This forces the game to-- restart upon enabling.restart_required = true



Mods can now specify an arbitrary save slot instead of using slots 1-4. This is useful for 'game mode' mods which don't sit nicely on top of an existing Don't Starve save.

In screens/newgamescreen.lua, function NewGameScreen:Start(), you can see where SaveGameIndex:StartSurvivalMode() is called with a slot. The main game uses slots called 1, 2, 3 and 4, but you can call this function with the slotname of your choice. For example:
-- in modmain.lualocal function PatchMainScreen(self)  local function StartMyMod()    local slotname = "mymod"    local function onsaved()      StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = slotname})    end    GLOBAL.SaveGameIndex:StartSurvivalMode(slotname, "wilson", {}, onsaved)  end   self.MainMenu = function(self)    local menu_items = {}    -- we add our custom callback to the start button which makes it launch our special slot    table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.PLAY, cb= StartGame, offset = Vector3(0,20,0)})    table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.MODS, cb= function() self:OnModsButton() end})    table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.OPTIONS, cb= function() self:DoOptionsMenu() end})    table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.EXIT, cb= function() self:OnExitButton() end})    self:ShowMenu(menu_items)    self.main_menu = true  endendAddClassPostConstruct("screens/mainscreen", PatchMainScreen)

 

Now your mod will start up it's own slot where you can do crazy things, without messing with players' existing saves: instead of making a save game called 'survival_1', it will create 'survival_mymod'.



Assets:
 

Road textures can now be overwritten by a mod.
 

Mods can specify their own minimap atlases. Custom minimap icons!
-- modmain.lualocal Assets ={  Asset("IMAGE", "images/myminimap.tex"),  Asset("ATLAS", "images/myminimap.xml"),}-- This tells the game to use your new atlas. It has to be in the root of modmain.AddMinimapAtlas("images/myminimap.xml")
-- yourprefab.lualocal function create(Sim)  local inst = CreateEntity()  -- ... set up other components, transform, etc  local minimap = inst.entity:AddMinimapEntity()  minimap:SetIcon("myminimap.tex")  return instendreturn Prefab("yourprefab", create, assets)



World Gen:

Can now specify the range of background nodes to generate for each node in the level definition.
> Levels with blockers can now specify what their "blank" nodes are in case you don't want it to be ocean. 
-- in modworldgenmain.lua-- All blockers will be bounded by killer swamps, rather than oceanAddRoom("MySpecialBlockerRoom", {  type = "background",  value = GLOBAL.GROUND.MARSH,  contents = {    distributepercent = 0.5,    distributeprefabs = {      tentacle = 1,    },  }})AddLevel(GLOBAL.LEVELTYPE.SURVIVAL, {  id="MY_LEVEL",  tasks = { ... },  -- Set what room around blockers is, rather than the default 'blank' room  blocker_blank_room_name = "MySpecialBlockerRoom",  -- Change the number of background nodes per task  -- Each room will have between 0 and 4 background nodes  background_node_range = {0,4},})

 

The special blockers are for if you want to maintain that idea of an "entrance room" but don't want all the empty space that appears around it. Putting background nodes here would be a natural choice.

The background node range helps you control the ratio of specific rooms to background rooms. If this number is higher each of your specific rooms will be surrounded by background nodes, if it's low or none then few or no background nodes will be generated.



Tasks have a little more control over internal connectedness by specifying a custom crosslink factor for rooms, and whether or not the rooms are generated in a loop.
AddTask("MyTask", {  locks = LOCKS.NONE,  keys_given = {KEYS.TIER1},  room_choices = {    ["BeefalowPlain"] = 8,  },  room_bg = GROUND.FOREST,  background_room = "BGSavanna",  colour = {r=0.8,g=0.8,b=0.5,a=1},  -- The number of neighbors beyond the first that each node links to  crosslink_factor = 0,  -- Whether or not to connect the last node to the first  make_loop = true,})

 
Each room in a task is initially generated in a line, with the rooms generated in order. If you use the crosslink_factor=0 and make_loop=false, then the rooms will just end up in a line. For each increment of crosslink_factor, each node attaches to one additional neighbor, making the task tighter and tighter connected. If you use make_loop, the last node is connected to the first, putting the rooms initially into a circle instead of a line. These two values can be tweaked to control how long or dense a task is.

The links between rooms will affect the overall shape of the layout, as well as where roads can appear.

post-202401-0-51538000-1381958822_thumb.




Development:

Better logging when animations and builds are missing.

Sublime Text, a great script editor, is now packaged with the mod tools in Steam! Use this when working with Lua files for syntax highlighting, multi-file search, and other handy editing tricks.
Link to comment
Share on other sites

Mods can now specify an arbitrary save slot instead of using slots 1-4. This is useful for 'game mode' mods which don't sit nicely on top of an existing Don't Starve save.

:grin:

Unfortunately, this won't be of use for U&A, since it'd hook up with normal saves. This is really a shame, since that would solve the issue with the player loading a save while in the could world with U&A disabled, trashing all mod savedata for general chaos.

Sublime Text, a great script editor, is now packaged with the mod tools in Steam! Use this when working with Lua files for syntax highlighting, multi-file search, and other handy editing tricks.

... why? Isn't @Cheerio's thread already over the top in advertising for a product I don't believe Klei has any ties with? It's not like this is truly relevant, but I quite dislike that you're promoting a text editor as "official", especially when it's a commercial one (whether it's freely available or not is not quite relevant). Wouldn't a discrete thread recommending it posted under a non-dev account, liked to in the Getting Started thread, be enough?

And does this mean we won't get a dependency system for mod loading at all? I've been holding off on so much for so many months waiting for that.

But more importantly, what about mod savedata?

Link to comment
Share on other sites

Mods can specify their own minimap atlases. Custom minimap icons!

-- modmain.lualocal Assets ={  Asset("IMAGE", "images/myminimap.tex"),  Asset("ATLAS", "images/myminimap.xml"),}-- This tells the game to use your new atlas. It has to be in the root of modmain.AddMinimapAtlas("images/myminimap.xml")
-- yourprefab.lualocal function create(Sim)  local inst = CreateEntity()  -- ... set up other components, transform, etc  local minimap = inst.entity:AddMinimapEntity()  minimap:SetIcon("myminimap.tex")  return instendreturn Prefab("yourprefab", create, assets)

Did anyone get this working. Because it doesn't seem to work for me at all. I also tried to do it like Cheerio did it for the first time here, didn't work either. And then I looked in The Screecher and it said in the comments "Note that we still overwrite the minimap atlas because we need to stomp the "reveal" shape for aesthetic reasons.". So i was wondering, does The Screecher even use custom minimap icons? Only the helipad has a custom icon in use and that works. Now my last thought was that it might be the same problem that i have with the bigportraits and such, converting them on my own will make them not work. So does anyone have a working sample could check out?

Link to comment
Share on other sites

Did anyone get this working. Because it doesn't seem to work for me at all. I also tried to do it like Cheerio did it for the first time here, didn't work either. And then I looked in The Screecher and it said in the comments "Note that we still overwrite the minimap atlas because we need to stomp the "reveal" shape for aesthetic reasons.". So i was wondering, does The Screecher even use custom minimap icons? Only the helipad has a custom icon in use and that works. Now my last thought was that it might be the same problem that i have with the bigportraits and such, converting them on my own will make them not work. So does anyone have a working sample could check out?

I have a working minimap icon in Charlie's mod, if you wish to take a look.

Link to comment
Share on other sites

I have a working minimap icon in Charlie's mod, if you wish to take a look.

I'm confused... I had exactly the same setup. My code was perfectly fine. But for some reason the atlas file was the problem. It looked identical to yours, yet it wouldn't work. So I just copy-pasted yours and changed the image name in it and ta-daa, it worked. I must be missing something totally obvious.

Old File:

<Atlas><Texture filename="waverly.tex" />    <Elements><Element name="waverly.tex" u1="0" u2="1" v1="0" v2="1" /></Elements></Atlas>

New File:

<Atlas><Texture filename="waverly.tex" />    <Elements><Element name="waverly.tex" u1="0" u2="1" v1="0" v2="1" /></Elements></Atlas>

Anyways, thanks a lot! It's awesome to finally have custom minimap icons working ^^

Link to comment
Share on other sites

I'm confused... I had exactly the same setup. My code was perfectly fine. But for some reason the atlas file was the problem. It looked identical to yours, yet it wouldn't work. So I just copy-pasted yours and changed the image name in it and ta-daa, it worked. I must be missing something totally obvious.

Old File:

<Atlas><Texture filename="waverly.tex" />    <Elements><Element name="waverly.tex" u1="0" u2="1" v1="0" v2="1" /></Elements></Atlas>

New File:

<Atlas><Texture filename="waverly.tex" />    <Elements><Element name="waverly.tex" u1="0" u2="1" v1="0" v2="1" /></Elements></Atlas>

Anyways, thanks a lot! It's awesome to finally have custom minimap icons working ^^

 

FYI sometimes certain whitespace characters that you can't see will get added from copying an pasting between places and will screw things up. I had this happen multiple times while making my last mod. It near impossible to figure out where they are, at least I found it so, I ended up having to delete whole swathes of code and retype it.

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