Sign in to follow this  

Help with 'writeable' component on custom item?

Recommended Posts

justjasper    77

I know it seems like I live in this forum begging for help right now, but I'm really enjoying learning new things!

I'm working on craftable stone/marble graves, and I want to be able to 'engrave' them like you can the signposts in game. I thought it would be fun to be able to mark spots, or to make graveyards for player deaths, or your faithful companions (beefalo graveyard, anyone?)

I thought applying this to an item would be as simple as adding the 'writeable' component into the prefab, but it doesn't work. I've also tried making a standalone copy of "writeable" (etc) for my prefab to call on but that doesn't work.

I've looked at 'Domestication Plus' since that uses the writeable component somehow, but I can't work out how they've done it. The file attached contains some edits of the files in Domestication Plus.

Any hints/help would be appreciated!

justjasper Craftable Gravestones (DST).rar

Share this post

Link to post
Share on other sites
zazabar    8

I'll take a look at this here in a minute :) 

Edit: Okay, took a look. Part of the problem is that you have the data for the writeables dissociated with the gravestones themselves. If you look in the beefalodomestication.lua, you'll see that they have the writeable data in the same file where it is being called. You don't have to do it directly like that, but right now there is nothing linking the information in your signs.lua. In fact, your gravesigns.lua calls the information from the original writeables, which doesn't contain anything for your signs. 

This is why it's crashing when you attempt to do anything with them. Hope this helps!

Edited by zazabar

Share this post

Link to post
Share on other sites
justjasper    77

Could I make this work with addprefabpostinit? I've not had any luck so far and can't figure out any way forward (though work/Xmas has been kicking my butt so I've not had much time to test much).

Share this post

Link to post
Share on other sites
Welpx    1

Honestly I'm having the same issue. Writeable component is one of the most confusing aspects I have seen here. I'd love if someone got a simpler solution...

EDIT: After commenting line by line on beefalodomestication.lua, I was able to find the core functions for a renaming tool

@justjasper I believe this might help you (You need upvaluehacker from the beefalo mod too)



--The amazing petal renaming tool! You just need to use a feather pencil on a petal to give it a cute/metal name

local TheNet = GLOBAL.TheNet
local require = GLOBAL.require


local UpvalueHacker = require("tools/upvaluehacker")
local writeables = require("writeables")
local kinds = UpvalueHacker.GetUpvalue(writeables.makescreen, "kinds")


local random_strings = {

local myprompt = "What do you want to write?"
local mycancel = "Cancel"
local mymiddle = "Random"
local myaccept = "Write it!"

kinds.petals = {
    prompt = myprompt,
    animbank = "ui_board_5x3",
    animbuild = "ui_board_5x3",
    menuoffset = GLOBAL.Vector3(6, -70, 0),

    cancelbtn = { text = mycancel, cb = nil, control = GLOBAL.CONTROL_CANCEL },
    middlebtn = { text = mymiddle, cb = function(inst, doer, widget)
            widget:OverrideText( random_strings[math.random(#random_strings)] )
        end, control = GLOBAL.CONTROL_MENU_MISC_2 },
    acceptbtn = { text = myaccept, cb = nil, control = GLOBAL.CONTROL_ACCEPT },


local Writeable = require("components/writeable")
Writeable.near_dist = 3
local _SetText = Writeable.SetText
function Writeable:SetText(text, ...)
	_SetText(self, text, ...)
	if self.onsettext then self:onsettext(text, ...) end

local _Write = Writeable.Write
function Writeable:Write(...)
	_Write(self, ...)

local function UpdateName(inst)
	local name = inst.components.writeable:GetText()

local function onaccepttest(inst, item, giver)
	if item.prefab == "featherpencil" then
	--return item.prefab == "featherpencil"

local function postinit(inst)
	inst.UpdateName = UpdateName
	inst:DoTaskInTime(0, inst.UpdateName)


	inst.components.writeable.near_dist = 10
	inst.components.writeable.onsettext = function() inst:UpdateName() end
	inst.components.inspectable.getspecialdescription = nil --we don't want the writer to store it here

AddPrefabPostInit("petals", postinit)


Does anyone know a way to reload the game after a crash without closing and opening again? This could've saved me a LOT OF TIME

Edited by Welpx

Share this post

Link to post
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
Sign in to follow this