Jump to content

Recommended Posts

Does anyone have any idea how to use this component?  I've only found a few mods that seem to use it, but can't understand their code..  I thought it would be really simple, but I think I'm missing code related to UI elements.  Basically, I'm just trying to add the writeable component to a custom tent.

Link to comment
https://forums.kleientertainment.com/forums/topic/155857-writeable-component/
Share on other sites

3 minutes ago, Rickzzs said:

It is similar to container. It is a component plus a definition(you require it and add a param).

Wonderful, can you tell me more, or provide an example?  I could provide my current code, but it's currently very messy..  Basically I just wanted a placid structure to place and name, so I took a tent, stripped it of everything tent related, and tried adding the writable component.

--1.Add Writeable component
    --inst.entity:SetPristine()
    --if not TheWorld.ismastersim then
    --    return inst
    --end

    inst:AddComponent("writeable")
	 -- config the component
    -- inst.components.writeable:SetDefaultWriteable(false)
    -- inst.components.writeable:SetAutomaticDescriptionEnabled(false)
	--...

--2.Add Params
local writeables=require("writeables")
writeables.AddLayout(prefab,{
    prompt = STRINGS.SIGNS.MENU.PROMPT_BEEFALO,--the name
    animbank = "ui_board_5x3",--the background
    animbuild = "ui_board_5x3",
    menuoffset = Vector3(6, -70, 0),--the position
	maxcharacters = TUNING.BEEFALO_NAMING_MAX_LENGTH,--max length


    defaulttext = function(inst, doer)--default text
        return subfmt(STRINGS.NAMES.BEEFALO_BUDDY_NAME, { buddy = doer.name })
    end,

    cancelbtn = {--mostly cancel button
        text = STRINGS.BEEFALONAMING.MENU.CANCEL,
        cb = nil,--callback
        control = CONTROL_CANCEL --keybind
    },
    middlebtn = {--mostly something else
        text = STRINGS.BEEFALONAMING.MENU.RANDOM,
        cb = function(inst, doer, widget)
            local name_index = math.random(#STRINGS.BEEFALONAMING.BEEFNAMES)
            widget:OverrideText( STRINGS.BEEFALONAMING.BEEFNAMES[name_index] )
        end,
        control = CONTROL_MENU_MISC_2
    },
    acceptbtn = {--mostly accept button
        text = STRINGS.BEEFALONAMING.MENU.ACCEPT,
        cb = nil,
        control = CONTROL_ACCEPT
    },
  })

 

  • Like 1

Thanks, but for some reason that hasn't worked.

I can see that you've defined 'maxcharacters', but it seems to cause the writeablewidget code to crash, because 'config.maxcharacters' claims 'config' is nil.

ice_den.lua

Edited by FurryEskimo
On 5/3/2024 at 4:52 PM, Rickzzs said:
--2.Add Params

I don't know what I have done not right. It's driving me crazy. For some reason code doesn't work for clients. It says:
 

[01:04:57]: Invalid LeftClick RPC from (KU_voGjEE4r) kristal_milton

or


[01:05:00]: Invalid UseItemFromInvTile RPC from (KU_voGjEE4r) kristal_milton	

Everytime client tryied to perform action, this traceback appears. And it's same with homesigns so it's SOMETHING wrong with action, right? I think so, the problem is not replica writeable or not replica writeable. I don't even know what that error message suppose to mean. I don't even know what is the LeftClick RPC and where the hell it is, why is it invalid. I've been trying for 5 days and I know that it's bad to ask people you don't know to do stuff you're supposed to do but please. Here's my files: modmain.luawritten_papyrus.lua.

On 12/11/2024 at 12:47 AM, Mr.CrazyPotato said:

I don't know what I have done not right. It's driving me crazy. For some reason code doesn't work for clients. It says:
 

[01:04:57]: Invalid LeftClick RPC from (KU_voGjEE4r) kristal_milton

or


[01:05:00]: Invalid UseItemFromInvTile RPC from (KU_voGjEE4r) kristal_milton	

Everytime client tryied to perform action, this traceback appears. And it's same with homesigns so it's SOMETHING wrong with action, right? I think so, the problem is not replica writeable or not replica writeable. I don't even know what that error message suppose to mean. I don't even know what is the LeftClick RPC and where the hell it is, why is it invalid. I've been trying for 5 days and I know that it's bad to ask people you don't know to do stuff you're supposed to do but please. Here's my files: modmain.luawritten_papyrus.lua.

I don't know why ur adding another write action but RPC can be traced by GLOBAL.HandleRPC (to trace it simply insert a print when this function is called). The error comes from GLOBAL.RPC.LeftClick, which is located in scripts/networkingrpc.lua(maybe I remember the names wrongly) where there's a server-side check on every param of the action sent by client. And your action failed on that check.

Edited by Rickzzs
  • Thanks 1

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
×
  • Create New...