will_b_gaming Posted February 10, 2025 Share Posted February 10, 2025 I'm trying to make a structure with basic features for modding practice. I'm currently stuck on trying to make it work as a sign. I've been looking at the code for homesign.lua, but simply adding in the writeable component causes my game to crash whenever I try to write on it. Crash log: client_log.txt Mod: Summer Shrine.rar Link to comment https://forums.kleientertainment.com/forums/topic/163923-how-do-you-make-a-writeable-sign/ Share on other sites More sharing options...
GameBoyAdv4002 Posted February 12, 2025 Share Posted February 12, 2025 What's the crash message/result in Klei/DoNotStarveTogether/client_log.txt? I'm not familiar with this component so I can't really guess what the problem might be. Link to comment https://forums.kleientertainment.com/forums/topic/163923-how-do-you-make-a-writeable-sign/#findComment-1796724 Share on other sites More sharing options...
will_b_gaming Posted February 12, 2025 Author Share Posted February 12, 2025 14 minutes ago, GameBoyAdv4002 said: What's the crash message/result in Klei/DoNotStarveTogether/client_log.txt? I'm not familiar with this component so I can't really guess what the problem might be. client_log.txt The line in question is: self.edit_text:SetTextLengthLimit(config.maxcharacters or MAX_WRITEABLE_LENGTH) so I need to find a way to define "config." I haven't been able to find a way that satisfies this code though. Link to comment https://forums.kleientertainment.com/forums/topic/163923-how-do-you-make-a-writeable-sign/#findComment-1796733 Share on other sites More sharing options...
oregu Posted February 15, 2025 Share Posted February 15, 2025 (edited) On 2/12/2025 at 3:47 PM, will_b_gaming said: client_log.txt 36.53 kB · 1 download The line in question is: self.edit_text:SetTextLengthLimit(config.maxcharacters or MAX_WRITEABLE_LENGTH) so I need to find a way to define "config." I haven't been able to find a way that satisfies this code though. Old answer regarding adding mod CONFIG to things Spoiler The way I usually handle defining config is making it TUNING[modname].CONFIG to ensure its unique (I guess you could also do GLOBAL[modname].CONFIG because they're technically constants but that's meh). A caveat is with things you don't modimport (often widgets for me) , you have to pass modname or config to the widget or whatever you're trying to require, something like this -- adding widget local ExampleWidget = require"widgets/example" local CONFIG = TUNING[modname].CONFIG self[SOMEROOTPOSITION]:AddChild(ExampleWidget(CONFIG, MODROOT)) -- widget (seperate file) local ExampleWidget = Class(Widget, function(self, CONFIG, MODROOT) I also add MODROOT along with it in case I need it, some data accessing functions require it like TheSim:AtlasContains for some reason. EDIT: Oh, it seems I misunderstood the question. but what I said is still somewhat relevant in understanding. it looks like you have to require"writables" and do writables.AddLayout("yourprefab", layoutdata) in order for the writable to add your config data properly (thats my guess though) look at wrtiables.lua, as for layoutdata, kinds[someprefab] is the config information you are looking for. Edited February 15, 2025 by oregu Correction Link to comment https://forums.kleientertainment.com/forums/topic/163923-how-do-you-make-a-writeable-sign/#findComment-1797646 Share on other sites More sharing options...
will_b_gaming Posted February 15, 2025 Author Share Posted February 15, 2025 9 hours ago, oregu said: it looks like you have to require"writables" and do writables.AddLayout("yourprefab", layoutdata) in order for the writable to add your config data properly (thats my guess though) It works now. Here's the code I put into modmain.lua: local glorpflorp = require "writeables" local SignGenerator = require"signgenerator" glorpflorp.AddLayout("swamp_sign", { prompt = STRINGS.SIGNS.MENU.PROMPT, animbank = "ui_board_5x3", animbuild = "ui_board_5x3", menuoffset = nil, 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 }, }) Link to comment https://forums.kleientertainment.com/forums/topic/163923-how-do-you-make-a-writeable-sign/#findComment-1797765 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now