Quantcast
Channel: [Don't Starve Together] Suggestions and Feedback Latest Topics
Viewing all articles
Browse latest Browse all 7901

[Modding] Update writeables to allow custom params

$
0
0

Given that the recent update in the beta, at long last, updated containers to finally support custom params without having to override functions to do it (aka making it far easier to make custom chests), I suggest that the same should be done to writeables. Writeables have the same problem where you'll need to override functions to allow custom writeable objects to use existing widgets (below is an example of what I did for writeable gravestones)

local writeables = require "writeables"

local params = {}

params["gravestone_l"] = {
    prompt = STRINGS.SIGNS.MENU.PROMPT,
    animbank = "ui_board_5x3",
    animbuild = "ui_board_5x3",
    menuoffset = _G.Vector3(6, -70, 0),

    cancelbtn = { text = STRINGS.SIGNS.MENU.CANCEL, cb = nil, control = CONTROL_CANCEL },
    middlebtn = { text = STRINGS.SIGNS.MENU.RANDOM, cb = function(inst, doer, widget)
            widget:OverrideText( SignGenerator(inst, doer) )
        end, control = CONTROL_MENU_MISC_2 },
    acceptbtn = { text = STRINGS.SIGNS.MENU.ACCEPT, cb = nil, control = CONTROL_ACCEPT },

    --defaulttext = SignGenerator,
}

local writeables_makescreen_old = writeables.makescreen
function writeables.makescreen(inst, doer)
    local t = params[inst.prefab]
    if t ~= nil then
		if doer and doer.HUD then
			return doer.HUD:ShowWriteableWidget(inst, t)
		end
    else
        writeables_makescreen_old(inst, doer)
    end
end

Overall sign mods are not near as popular as container/chest mods so I'm not surprised that most people aren't aware of this. It would be a nice change regardless.


Viewing all articles
Browse latest Browse all 7901

Trending Articles