ZA_WARUDO Posted August 12, 2020 Share Posted August 12, 2020 (edited) yoyozi.luaspirit_stack.luamodmain(origi).lua In this character's prefab (yoyozi.lua) it has stacking power system (inst.spirit) So I want to make a widget to show her current spirit stacks but I don't know how. Please help me. Thank you! (simple text widget is ok) *spirit_stack.lua is the file I prepared in widgets folder.* Edited August 12, 2020 by ZA_WARUDO Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/ Share on other sites More sharing options...
DecDuck Posted August 13, 2020 Share Posted August 13, 2020 In sprit_stack.lua, you seemed to have missed the end and close bracket at the end of the file: local Text = require "widgets/text" local Widget = require "widgets/widget" local spirit_stack = Class(Widget ,function(self ,owner) Widget._ctor(self, "spirit_stack") self.owner = owner self.isFE = false self:SetClickable(false) self.num = self:AddChild(Text(BODYTEXTFONT, 33)) self.num:SetHAlign(ANCHOR_MIDDLE) self.num:SetPosition(5, -50, 0) self.num:SetScale(0.75,0.75,0.75) self.num:MoveToFront() end) -- HERE return spirit_stack Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/#findComment-1362653 Share on other sites More sharing options...
ZA_WARUDO Posted August 14, 2020 Author Share Posted August 14, 2020 17 hours ago, decduck3 said: In sprit_stack.lua, you seemed to have missed the end and close bracket at the end of the file: local Text = require "widgets/text" local Widget = require "widgets/widget" local spirit_stack = Class(Widget ,function(self ,owner) Widget._ctor(self, "spirit_stack") self.owner = owner self.isFE = false self:SetClickable(false) self.num = self:AddChild(Text(BODYTEXTFONT, 33)) self.num:SetHAlign(ANCHOR_MIDDLE) self.num:SetPosition(5, -50, 0) self.num:SetScale(0.75,0.75,0.75) self.num:MoveToFront() end) -- HERE return spirit_stack Thank you for telling me for that But how should I write new code in modmain and character's prefab in order to make a text widget? Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/#findComment-1362810 Share on other sites More sharing options...
DecDuck Posted August 14, 2020 Share Posted August 14, 2020 (edited) I am not actually an expert on this stuff, but after some poking around: In statusdisplays.lua, it checks for a DoDelta, and then updates the player's stats accordingly. It also checks for if you are on a boat, and other things. Also this line in controls.lua: self.status = self.sidepanel:AddChild(StatusDisplays(self.owner)) It is connected to the HUD variable in player_common.lua Also: Quote self.num:SetHAlign(ANCHOR_MIDDLE) Is this meant to be like this? With the capital? Quick question, have you got the text status showing but not updating? Or do you not have it showing? Edited August 14, 2020 by decduck3 Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/#findComment-1362890 Share on other sites More sharing options...
ZA_WARUDO Posted August 15, 2020 Author Share Posted August 15, 2020 Ok thank you so much for your information. #Is this meant to be like this? With the capital? - Yes it is. I have seen it from many widgets. Quick question, have you got the text status showing but not updating? Or do you not have it showing? - Both because I don't know anything about widget mod (Sorry for being stupid) Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/#findComment-1363044 Share on other sites More sharing options...
DecDuck Posted August 15, 2020 Share Posted August 15, 2020 (edited) From the modmain.lua of Combined Status: local require = GLOBAL.require local Widget = require('widgets/widget') local Image = require('widgets/image') local Text = require('widgets/text') local PlayerBadge = require("widgets/playerbadge" .. (DST and "" or "_combined_status")) local Minibadge = require("widgets/minibadge") if not DST then table.insert(Assets, Asset("ATLAS", "images/avatars_combined_status.xml")) table.insert(Assets, Asset("IMAGE", "images/avatars_combined_status.tex")) table.insert(Assets, Asset("ANIM", "anim/cave_clock.zip")) end local Badge = require("widgets/badge") I have also attached the entire modmain.lua for you to look at. Also Minibadge.lua which is what Combined Status uses for the little values like temperature While going through it, I think you have to have a function that creates and mantains the badge/widget, and then use AddClassPostConstruct to add it to the player. You also will need to check if it's the modded character, or if it's a vanilla one to enable/disable it. modmain.lua minibadge.lua Edited August 15, 2020 by decduck3 Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/#findComment-1363099 Share on other sites More sharing options...
DecDuck Posted August 15, 2020 Share Posted August 15, 2020 I tried a few things and got this: Here is my code. You could probably fix it up: local function temperature (self) self.temperature = self:AddChild(Minibadge("temperature", self.owner)) self.inst:ListenForEvent("temperaturedelta", function(inst) local val = DST and self.owner:GetTemperature() or self.owner.components.temperature.current self.temperature.num:SetString(val) end, self.owner) self.temperature:SetPosition(65.5, 0, 0) end AddClassPostConstruct("widgets/badge", temperature) (In modmain.lua) Then in minibadge.lua: local UIAnim = require "widgets/uianim" local Text = require "widgets/text" local easing = require "easing" local Widget = require "widgets/widget" local Minibadge = Class(Widget, function(self, name, owner) Widget._ctor(self, "Minibadge") self.owner = owner self.name = name self:SetScale(.9, .9, .9) self.bg = self:AddChild(Image("images/status_bgs.xml", "status_bgs.tex")) self.bg:SetScale(.4,.43,1) self.bg:SetPosition(-.5, -40) self.num = self:AddChild(Text(NUMBERFONT, 28)) self.num:SetHAlign(ANCHOR_MIDDLE) self.num:SetPosition(3.5, -40.5) self.num:SetScale(1,.78,1) end) return Minibadge Link to comment https://forums.kleientertainment.com/forums/topic/120898-help-how-to-make-specific-value-widget/#findComment-1363109 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