icantevenname

  • Content Count

    390
  • Joined

  • Last visited

Community Reputation

59 Excellent

About icantevenname

  • Rank
    Senior Member
...

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Enable
  1. Okay, the this-is-how-to-do-it post. First off, you'll need to make a folder named "widgets" in the "scripts" folder. In "widgets" create a lua file and name it whatever ya want. Here, we'll call it "changethistoyourownname" so you know what to change. This down here is all you need for the badge to exist. local Badge = require "widgets/badge" -- badge template to be used local changethistoyourownname = Class(Badge, function(self, owner) Badge._ctor(self, nil, owner, { 225 / 255, 64 / 255, 0 / 255, 1 }) -- "nil" here is supposed to be the badge's art, but we couldn't figure it out. It'll use the default badge art without a icon.-- { 174 / 255, 21 / 255, 21 / 255, 1 } = colour in an rbg format self.owner = owner self.num.max = 100 --This number is the max of the character's badge self.num.current = self.num.max --Best you don't mess with this 'less ya got somethin' up your sleeve. owner:ListenForEvent("changethistoasimilarnamedirty",function(owner,data) --Yes, your custom name with "dirty" at the end. self.num.current = self.owner.changethistoasimilarname:value() self.percent = self.owner.changethistoasimilarname:value() / self.num.max end) self:StartUpdating() -- does uhhhhhgh something end) function changethistoyourownname:OnUpdate(dt) if self.owner ~= nil and self.owner.changethistoasimilarname ~= nil then local percent = self.owner.changethistoasimilarname:value() / self.num.max self:SetPercent(percent,self.num.max) --Don't touch this. FOR THE LUVVA YER DEITY OF CHOICE, DON'T TOUCH THIS! 'Less you wanna jack up yer numbers. end end return changethistoyourownname Now in your modmain, put this under your character's info. changethistoyourownname = require "widgets/changethistoyourownname" AddClassPostConstruct("widgets/statusdisplays", function(self) if self.owner.prefab ~= 'whateveryoucalledyourguy' then return end self.name = self:AddChild(changethistoyourownname(self.owner)) self.name:SetPosition(-125, 75, 0) --Best to change these all to zero and start the game to see where it is. Then change the numbers one by one to get a better idea of what each number does. end) Now to your character's lua, go to their common_postinit and add inst.changethistoasimilarname = net_ushortint(inst.GUID, "changethistoasimilarname", "changethistoasimilarnamedirty" ) --net_ushortint is the typical use of stats --"name" is the name of the netvariable --"namesdirty" is an Event which is called whenever this is changed inst.changethistoasimilarname:set(100) -- inst.name:set(number) [same as] inst.name = number inst.changethistoasimilarname:value() --getting the value of the net_variable But like this, the game won't keep track of how much of your meter is left when your save or load, resetting it to max when you load a game. So put in the following outside of any of the other tables local function OnSave(inst,data) data.changethistoasimilarname = inst.changethistoasimilarname:value() end local function OnLoad(inst,data) if data and data.changethistoasimilarname then inst.changethistoasimilarname:set(data.changethistoasimilarname) end end And at the end of the master_postinit, put inst.OnLoad = OnLoad inst.OnSave = OnSave 'Less I'm forgettin' somethin', that's it! Yer shiny new badge is all ret-2-go! It can do jus' about anythin' at this point! But that's too broad for this post, so I'm not going to cover it here. If ya ever need help, jus' ask. Not me though, I keep overestimating my programming abilities. Though I will add this, if you need to change your meter's value, it's inst.changethistoasimilarname:set(val + 1) --Be sure to change "inst" when necessary --It doesn't only have to be +. It could be -. Or *. Or /. Depends on what y'er doin'.
  2. Perfect! Though I had to close that last end with an ). It's all working like a charm! I'll do that last all-you-need-to-know post sometime later. I don't know about you, but over here it's everyone's-asleep-o'-clock, so I oughtta go to bed. Thanks so much!
  3. Alright, did all the tinkering I could. And I'm tapped outta ideas. All that's left is the regen. We're almost done.
  4. Er... I just noticed something... Reloading the save resets sptnink back to max, no matter what it was before...
  5. That worked! It took me awhile to post that cuz I tripled-checked to make sure my eyes weren't playing tricks on me. Now only one thing, the regen. I'm gunna tinker around on my own first. If I run outta ideas, I'll ask for help. If I do figure it out, I'll post what I did for you to check out. To see if it's stable or not. Thinkin' when this is said an' done, I oughtta post a quick this-is-how-its-done here so others don't have to read every little thing.
  6. No, still a hard crash... But I did find this in the log this time... [00:00:31]: [string "../mods/Inky/scripts/widgets/sptninkbadge.l..."]:18: variable 'self' is not declared That's the "self:OnUpdate(dt)". I'm gunna change it back to "sptninkbadge" to see what happens.
  7. It causes the game to hard crash to desktop. No error message or anything. I had to go into the client log to find the error... [00:00:29]: [string "scripts/mainfunctions.lua"]:1338: variable 'global_error_widget' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) scripts/mainfunctions.lua(1338,1) =[C] in function 'SetPersistentString' scripts/mainfunctions.lua(26,1) in function 'SavePersistentString' scripts/modindex.lua(119,1) =[C] in function 'GetPersistentString' scripts/modindex.lua(106,1) in function 'BeginStartupSequence' scripts/main.lua(446,1) in function 'callback' scripts/modindex.lua(735,1) =[C] in function 'GetPersistentString' scripts/modindex.lua(709,1) in function 'Load' scripts/main.lua(445,1) in main chunk
  8. I've replaced "self:SetPercent(val,100)" with "self.anim:GetAnimState():SetPercent("anim", 1 - self.percent)" to see what would happen, and the meter was working well. But the numbers wouldn't show up when I hovered over the badge.
  9. It's working, but the numbers are more than they're supposed to be. sptnink has a max of 100, starts at 10000, goes down by 200 every shot instead of 2. And since 200 is more than 100, the meter never visually depletes, so the player won't know how many more shots they have. I've done everything I could think of to fix it, but nothing's working. The only thing I could figure out was that the line "self:SetPercent(val,100)" may have something to do with it.
  10. Now it's saying that in sptninkbadge.lua "inst" isn't declared. self.num.current = inst.name:value() I've tried to change "name" to "sptnink" but the same error happens. But on the bright side, sptnink does drop on use!
  11. As in, they attack with the weapon itself as opposed to have the weapon fire projectiles. Pistol whiping, in a sense.
  12. Yes, I do want sptnink to deplete on use. I also kinda wanna have it so that if the character using the weapon has not enough or no sptnink, then they end up using the weapon as a blunt instrument.
  13. Okay, a few things... It does work now! But I needed to give a number to "self.num.max". I already do have "inkmeter_inky" made. But hey, it shows up! I just need to know how to make it regen over time and lower when using a weapon. I'm sure I can figure the rest out from there.
  14. So I did do that, but then an error happened in the badge lua. Does that mean my mod's badge code is too wonky? Should I provide the rest of my badge's lua?
  15. Ah. Thought that was one of those things that'll make everything fall apart when changed. But now it says that "art" ain't declared. local sptninkbadge = Class(Badge, function(self, owner) Badge._ctor(self, art, owner, { 174 / 255, 21 / 255, 21 / 255, 1 }, "inkmeter_inky") -- status health = texture -- { 174 / 255, 21 / 255, 21 / 255, 1 } = colour in an rbg format self.owner = owner self.num.max = max_value self.num.current = self.num.max owner:ListenForEvent("sptninkdirty",function(owner,data) self.num.current = inst.name:value() self.percent = inst.name:value() / self.num.max end) self:StartUpdating() -- does uhhhhhgh something end) An' I've tried to change "inkmeter_inky" back to "status_health" and "nil" as Mr. Die suggested, but art's still ain't declared.