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.

Leonardo Cox

[Modding] Update writeables to allow custom params

Recommended Posts

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"] = {
    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)
        writeables_makescreen_old(inst, doer)

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.

Link to comment
Share on other sites