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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/ 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-605789 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606055 Share on other sites More sharing options...
JadeKnightblazer Posted January 26, 2015 Author Share Posted January 26, 2015 (edited) @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 Edited January 26, 2015 by JadeKnightblazer Link to comment https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606097 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606292 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606378 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606384 Share on other sites More sharing options...
Blueberrys Posted January 27, 2015 Share Posted January 27, 2015 (edited) @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)) Edited January 27, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606402 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606534 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606546 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606604 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 https://forums.kleientertainment.com/forums/topic/49701-turning-off-displays-on-items/#findComment-606607 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