Nycidian Posted October 16, 2013 Share Posted October 16, 2013 For some reason I can't get this hud element to display. I made a custom animation and renamed the build file inside of it appropriately then added the new element like it was done in woodies script but for some reason the new element just doesn't display. Here is the mod charlie.zip Here is the script in the charlie.lua filelocal MakePlayerCharacter = require "prefabs/player_common"local Badge = require "widgets/badge"local grueMax = 100local grueMin = 0local grueCurrent = grueMinlocal assets = { -- Char Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), -- Don't forget to include your character's custom assets! Asset( "ANIM", "anim/charlie.zip" ), Asset( "ANIM", "anim/gruesome.zip"), }local prefabs = {}-- characterlocal GruesomeBadge = Class(Badge, function(self, owner) Badge._ctor(self, "gruesome", owner)end)local function placeGruesome(inst) print("working!!!!!!!!!!!!!") inst.HUD.controls.gruesomebadge = GetPlayer().HUD.controls.sidepanel:AddChild(GruesomeBadge(inst)) inst.HUD.controls.gruesomebadge:SetPosition(0,-100,0) inst.HUD.controls.gruesomebadge:SetPercent(grueCurrent, grueMax) endlocal fn = function(inst) inst:ListenForEvent("enterdark", function(inst, data) print("grues NOT") inst.components.grue:Stop() end) --for key,value in pairs(TUNING) do print(key,value) end -- choose which sounds this character will play inst.soundsname = "wendy" -- a minimap icon must be specified inst.MiniMapEntity:SetIcon( "wendy.png" ) inst:DoTaskInTime(10, placeGruesome) end-- Initialization-- -- Characterreturn MakePlayerCharacter("charlie", prefabs, assets, fn) Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 I think the easiest way would be to create your badge as a copy of "hungerbadge" and change the animations there.Then you can use the following code: local status = GetPlayer().HUD.controls.status local GruesomeBadge = require("widgets/gruesomebadge") status.gruesome = status:AddChild(GruesomeBadge(owner)) status.gruesome:SetPosition(0,-100,0) status.gruesome:SetPercent(grueCurrent, grueMax) status.inst:ListenForEvent("gruedelta", function(inst, data) status.gruesome:SetAmount(data.grue) end, status.owner)I might use wrong functions here that don't apply for you, but the basic works as this. If you haven't already done so I would also recommend to create a "gruesome" component and handle stuff like currentgrue, maxgrue and so on with that instead of using local variables. Link to comment Share on other sites More sharing options...
Nycidian Posted October 16, 2013 Author Share Posted October 16, 2013 I think the easiest way would be to create your badge as a copy of "hungerbadge" and change the animations there.Then you can use the following code: local status = GetPlayer().HUD.controls.status local GruesomeBadge = require("widgets/gruesomebadge") status.gruesome = status:AddChild(GruesomeBadge(owner)) status.gruesome:SetPosition(0,-100,0) status.gruesome:SetPercent(grueCurrent, grueMax) status.inst:ListenForEvent("gruedelta", function(inst, data) status.gruesome:SetAmount(data.grue) end, status.owner)I might use wrong functions here that don't apply for you, but the basic works as this. If you haven't already done so I would also recommend to create a "gruesome" component and handle stuff like currentgrue, maxgrue and so on with that instead of using local variables. I already made a copy of the sanity animation that's not the issue and I tried your method and the game crashes. BTW where do you find the error log I never have had to find it before? Link to comment Share on other sites More sharing options...
Craig_Perry Posted October 16, 2013 Share Posted October 16, 2013 I already made a copy of the sanity animation that's not the issue and I tried your method and the game crashes. BTW where do you find the error log I never have had to find it before?\Documents\Klei\DoNotStarve Link to comment Share on other sites More sharing options...
Nycidian Posted October 16, 2013 Author Share Posted October 16, 2013 \Documents\Klei\DoNotStarvethanks Link to comment Share on other sites More sharing options...
Nycidian Posted October 16, 2013 Author Share Posted October 16, 2013 I think the easiest way would be to create your badge as a copy of "hungerbadge" and change the animations there.Then you can use the following code: local status = GetPlayer().HUD.controls.status local GruesomeBadge = require("widgets/gruesomebadge") status.gruesome = status:AddChild(GruesomeBadge(owner)) status.gruesome:SetPosition(0,-100,0) status.gruesome:SetPercent(grueCurrent, grueMax) status.inst:ListenForEvent("gruedelta", function(inst, data) status.gruesome:SetAmount(data.grue) end, status.owner)I might use wrong functions here that don't apply for you, but the basic works as this. If you haven't already done so I would also recommend to create a "gruesome" component and handle stuff like currentgrue, maxgrue and so on with that instead of using local variables.Well I figured out what was crashing the game with your method the HUD is not loaded right away so if you don't delay calling it it crashes with that added in I get the same results as mine in that nothing shows up on the screen I can call the variable and it says it exists as a badge and that it is set to show so I don't know why it isn't doing so. Thanks for trying though. I still could use some help with this is anyone has another idea. Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 thanksNow that you have the error, can you post it? I'd like to help you there. EDIT: Damnit, that was some timing xDWhen it doesn't show with that code (which I know works) then I have to guess that something's wrong with the anim file. Have you tried it by just using the original health animations? Link to comment Share on other sites More sharing options...
Nycidian Posted October 16, 2013 Author Share Posted October 16, 2013 Now that you have the error, can you post it? I'd like to help you there. EDIT: Damnit, that was some timing xDsee above Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 see abovesee above : P Link to comment Share on other sites More sharing options...
Nycidian Posted October 16, 2013 Author Share Posted October 16, 2013 Now that you have the error, can you post it? I'd like to help you there. EDIT: Damnit, that was some timing xDWhen it doesn't show with that code (which I know works) then I have to guess that something's wrong with the anim file. Have you tried it by just using the original health animations?I tried renaming and changing the bin file on a copy of the sanity animation that did nothing. I then changed the name in this code to "sanity"local GruesomeBadge = Class(Badge, function(self, owner) Badge._ctor(self, "sanity", owner)end)This sadly worked which tells me the badge.lua is not loading the new animation for some reason. I also tried placing the the gruesome animation in the regular anim folder this didn't do it either. P.S. I also renamed the gruesome file to sanity and redid the bin and it loads in place of sanity fine. Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 To be honest, i think putting "sanity" in this place is necessary, it is the anim value given to the Badge which will then do self.anim:GetAnimState():SetBank(anim) self.anim:GetAnimState():SetBuild(anim)This yields a big problem as far as I can see. You can rename the build easily, but not rename the bank (as far as I know), thus you will not be able to implement your own animations this way.I would suggest duplicating the code from the badge exclusively for the sanitybadge instead of the sanitybadge being an object coming from the badge class (any real programmer would probably get a headache from how I'm formulating stuff here xD) This way you have full control over what build and bank you'll use which is necessary since you'll have to load an existing bank.Additionally Alternatively you could create your completely own animations with the correct bank name which would allow you to use the existing badg classWhich one is more to your liking should be the way to go (at least if noone comes up with a better idea) Link to comment Share on other sites More sharing options...
Nycidian Posted October 16, 2013 Author Share Posted October 16, 2013 To be honest, i think putting "sanity" in this place is necessary, it is the anim value given to the Badge which will then do self.anim:GetAnimState():SetBank(anim) self.anim:GetAnimState():SetBuild(anim)This yields a big problem as far as I can see. You can rename the build easily, but not rename the bank (as far as I know), thus you will not be able to implement your own animations this way.I would suggest duplicating the code from the badge exclusively for the sanitybadge instead of the sanitybadge being an object coming from the badge class (any real programmer would probably get a headache from how I'm formulating stuff here xD) This way you have full control over what build and bank you'll use which is necessary since you'll have to load an existing bank.Additionally Alternatively you could create your completely own animations with the correct bank name which would allow you to use the existing badg classWhich one is more to your liking should be the way to go (at least if noone comes up with a better idea) YES!!!!! figured it out so you have to load your anim as an asset on that page then over write the function from the badge file that set the bank to be what ever the original file you used waslocal MakePlayerCharacter = require "prefabs/player_common"--local Badge = require "widgets/badge"local grueMax = 100local grueMin = 0local grueCurrent = grueMinlocal assets = { -- Char Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/charlie.zip" ), Asset( "ANIM", "anim/gruesome.zip"), }local prefabs = {}local function placeGruesome(inst) local status = GetPlayer().HUD.controls.status local GruesomeBadge = require "widgets/gruesomebadge" status.gruesome = status:AddChild(GruesomeBadge(inst)) status.gruesome:SetPosition(0,-100,0) status.gruesome:SetPercent(grueCurrent, grueMax) status.gruesome.anim:GetAnimState():SetBank("sanity") status.gruesome.anim:GetAnimState():SetBuild("gruesome") endlocal fn = function(inst) inst:ListenForEvent("enterdark", function(inst, data) print("grues NOT") inst.components.grue:Stop() end) -- choose which sounds this character will play inst.soundsname = "wendy" -- a minimap icon must be specified inst.MiniMapEntity:SetIcon( "wendy.png" ) inst:DoTaskInTime(1, placeGruesome) end-- Initialization-- -- Characterreturn MakePlayerCharacter("charlie", prefabs, assets, fn)Thank you for the help, it might be hacked but what ever it works Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 YES!!!!! figured it out so you have to load your anim as an asset on that page then over write the function from the badge file that set the bank to be what ever the original file you used wasWait... why... why didn't I think of that T_TAnyways, I need to feel smart so I have to correct you : P You're not overwriting the function that set the bank, since the bank is set in the class constructor. You're simply resetting the bank.... phew, now the world is alright again Good work Nycidian! ^^ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.