Jump to content

Character Widget Creation, Help Appreciated


Recommended Posts

So I did some dabbling in widget creation, and it ended up giving me a bit of a headache.  Alot of different things I needed to cover, with getting the widget to display properly, as well as transfering netvariables so clients could utilize the widgets just as effectively.  That much being said, I only really ever managed to get a basic text widget to show up and show a variable, not very pretty looking but it's functioning.

 

I was wondering if I could get some assistance on making a widget as the best I can do is just a simple box and the idea I have for one is probably more complex than I know how to do.  So I'll describe what I have in mind.

 

I have a character who gets a unique buff from eating different crock pot foods.  Currently, when the character eats a crock pot food, they get a unique buff (tied to that food) that lasts for a certain duration dependant on the food that was eaten.

 

Right now, the buff's work perfectly but there's no actual conveyance to the player as to the buff's current durations or their effects.

 

I want to create a widget that looks similar to the health/sanity/hunger badges that empties out over the course of the buff's duration.

 

But also, the buff's can stack, and from what I was thinking, I didn't want the player to have all these buff timers cluttering the screen.  So my thought is to have a single widget that shows up on the screen, which when the mouse is put over it, makes the individual buffs slide out sideways so that the player can see the buffs when they want too, but when they don't it's compacted into a little area.

 

Also, for the timers I want the player to be able to put their mouse over the buff timers so they can see a little name and/or description of what the buff might be doing.

 

 

So yeah, that's what I have in mind, but I'm not quite sure where to begin.  I've tried looking at the badge widget for a reference but it does alot of different things in alot of different places and I'm not sure exactly how many pieces are required.

 

Any assistance would be appreciated, once I got a general idea how to set this up I should be able to take care of the rest.  At the moment I'm having trouble figuring out a good starting point for it.

 

  • Like 1
Link to comment
Share on other sites

local Widget = GLOBAL.require("widgets/widget")local ImageButton = GLOBAL.require("widgets/imagebutton")local Text = GLOBAL.require("widgets/text") local BuffList = Class(Widget, function(self)    Widget._ctor(self, "BuffList")    self.buffs = {}    for i = 1, 5, 1 do        local buff = self:AddChild(Text(GLOBAL.BUTTONFONT, 40, "Buff "..i))        buff:SetPosition(0, -45 * i, 0)        buff:SetHoverText("Description "..i)        buff.hovertext:SetPosition(-200, 4, 0)        self.buffs[i] = buff    end    self:Hide()end) AddClassPostConstruct("widgets/statusdisplays", function(self)    if self.owner.prefab == "wilson" then        self.buffbar = self:AddChild(Widget("buffbar"))        self.buffbar:SetPosition(0, -200, 0)        self.bufflist = self.buffbar:AddChild(BuffList())        self.bufflist:SetPosition(0, -30, 0)        self.menubutton = self.buffbar:AddChild(ImageButton())        self.menubutton.text = self.menubutton.image:AddChild(Text(GLOBAL.BUTTONFONT, 50, "Buffs"))        self.menubutton.text:SetColour(0, 0, 0, 1)        self.menubutton.onclick = function()            if self.bufflist:IsVisible() then                self.bufflist:Hide()            else                self.bufflist:Show()            end        end    endend)

@Zackreaver:

You press Buffs button to display buffs.

You hover over buff text to display buff description on the side.

Edited by DarkXero
Link to comment
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
 Share

×
  • Create New...