JadeKnightblazer Posted January 25, 2015 Share Posted January 25, 2015 Looking for a way to disable the percent hud on the items with finiteuses. Anyway to override what ever pastes the number string over the icons while in inventory? Link to comment Share on other sites More sharing options...
Mobbstar Posted January 25, 2015 Share Posted January 25, 2015 It gets very annoying since "fueled" and "armor" also show their percentage. I don't know how to change that though, nor am I going to do coding detective work. Link to comment Share on other sites More sharing options...
Blueberrys Posted January 26, 2015 Share Posted January 26, 2015 @JadeKnightblazer, @Mobbstar, Line 220 in "..\scripts\widgets\itemtile.lua"self.percent:SetString(string.format("%2.0f%%", val_to_show))Specifically the "%%". It appends a percent sign to the values. (According to this) It's in the "ItemTile:SetPercent(percent)" function. To change it, just override that function in your modmain using AddClassPostConstruct("widgets/itemtile", your_itemtile_postconst) Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted January 26, 2015 Author Share Posted January 26, 2015 @JadeKnightblazer, @Mobbstar, Line 220 in "..\scripts\widgets\itemtile.lua"self.percent:SetString(string.format("%2.0f%%", val_to_show))Specifically the "%%". It appends a percent sign to the values. (According to this) It's in the "ItemTile:SetPercent(percent)" function. To change it, just override that function in your modmain using AddClassPostConstruct("widgets/itemtile", your_itemtile_postconst) Thanks, now just to figure out how to use it for only certain items. Was hoping something easy like this could be placed in the customitem script. inst.AddWidget("itemtile")inst.widgets.itemtile.percent:SetString(" ") but... AddWidget does not work. Possible to post an example of your AddClassPostConstruct, with the custom postconst enable / disable certain custom items with the ItemTile:SetPercent. please Link to comment Share on other sites More sharing options...
Blueberrys Posted January 26, 2015 Share Posted January 26, 2015 @JadeKnightblazer, Not sure if I understood your question correctly. I think you meant something like this.local function itemtile_post(self, invitem) -- save old function self.old_SetPercent = self.SetPercent -- override with your own function self.SetPercent = function(self, percent) -- call old function first self:old_SetPercent(percent) if self.invitem and self.invitem.prefab == "your_item_prefab" then local oldStr = self.percent:GetString() self.percent:SetString(string.format("%2.0f", oldStr)) -- remove % end endendAddClassPostConstruct("widgets/itemtile", itemtile_post)Remember to change your_item_prefab accordingly. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted January 27, 2015 Author Share Posted January 27, 2015 thank you very much, going to try this one Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted January 27, 2015 Author Share Posted January 27, 2015 Hmm... sadly it does not work. Maybe it has to do with the Refresh function itemtile has. Meaning... at first the percents are removed untill the game tic occurs. Link to comment Share on other sites More sharing options...
Blueberrys Posted January 27, 2015 Share Posted January 27, 2015 @JadeKnightblazer, may I see your code? Edit: Replace thisself.percent:SetString(string.format("%2.0f", oldStr))with thisself.percent:SetString(string.sub(oldStr,1,-2)) Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted January 27, 2015 Author Share Posted January 27, 2015 --Turn off percent on certain Items local function itemtile_post(self, invitem) -- save old function self.old_SetPercent = self.SetPercent -- override with your own function self.SetPercent = function(self, percent) -- call old function first self:old_SetPercent(percent) if self.invitem and self.invitem.prefab == "skitemmealticket" then local oldStr = self.percent:GetString() --self.percent:SetString(string.format("%2.0f", oldStr)) -- remove % self.percent:SetString(string.sub(oldStr,1,-2)) end endendAddClassPostConstruct("widgets/itemtile", itemtile_post)All placed in the modmain.lua This code does not crash the game at all, nor does it remove the percent indicator =/. Most likely on my end unless others havn't been around to get this run-a-around to work. Link to comment Share on other sites More sharing options...
Blueberrys Posted January 27, 2015 Share Posted January 27, 2015 @JadeKnightblazer, Add these print statements and see what they print to the console/log:--Turn off percent on certain Itemslocal function itemtile_post(self, invitem) -- save old function self.old_SetPercent = self.SetPercent -- override with your own function self.SetPercent = function(self, percent) -- call old function first self:old_SetPercent(percent) print("Checking prefab") if self.invitem and self.invitem.prefab == "skitemmealticket" then local oldStr = self.percent:GetString() print(oldStr) --self.percent:SetString(string.format("%2.0f", oldStr)) -- remove % local newStr = string.sub(oldStr,1,-2) print(newStr) self.percent:SetString(newStr) end endendAddClassPostConstruct("widgets/itemtile", itemtile_post) Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted January 27, 2015 Author Share Posted January 27, 2015 Sadly I am not aware where print places its messages. (Sorry I normally program in Java / Minecraft). Link to comment Share on other sites More sharing options...
Mobbstar Posted January 27, 2015 Share Posted January 27, 2015 Sadly I am not aware where print places its messages. (Sorry I normally program in Java / Minecraft).in the log 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.