Razcaz89 Posted January 16, 2015 Share Posted January 16, 2015 (edited) Hello everyone here at Klei Entertainment Forums Started playing DST about a week ago, had never played DS either. Straight up game works great minus the hud being on the outer screens i dove into the game none the less, well after playing for like ages. i really wanted to fix the hud. so off to google i searched... alas nothing started reading all the lua scripts in mods very quickly trying to grasp how others complied thier mods and how the game devs implemented the hud in the first place. after all the time i spent reading i came up with a simple 14 line setup to move the interfacetho im encountering a hicup with the crafting tab..... it becomes inoperable, highlighting for the mouse still works but they become unclickable ive attached code below (bolded section is what isn't working) local function StatusDisplaysPostInit(self) self.brain:SetPosition(0-1720,-40,0) --values to be adjusted self.heart:SetPosition(40-1720,20,0) self.stomach:SetPosition(-40-1720,20,0)endAddClassPostConstruct("widgets/statusdisplays", StatusDisplaysPostInit)local function UIClockPostInit(self) self:SetPosition(-1720,0,0) --values to be adjustedendAddClassPostConstruct("widgets/uiclock", UIClockPostInit)local function CraftTabsPostInit(self) self:SetPosition(1720,0,0) endAddClassPostConstruct("widgets/crafttabs", CraftTabsPostInit)anyone able to point me in the correct direction to fix this? picture attached so you can see ingame Edited January 19, 2015 by Razcaz89 Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/ Share on other sites More sharing options...
rezecib Posted January 16, 2015 Share Posted January 16, 2015 @Razcaz89, Hmm... Looking at crafttabs.lua, you could try playing with the positioning of self.crafting in your CraftTabsPostInit. (also self.controllercrafting, if you want to make that compatible, too-- I believe you can test it without a controller by using caps lock). Nice work figuring out how to get that far, though! One thing to keep in mind is that you can delve into the game's code just as easily as delving in the mod code (and game code is actually almost always easier to read). What I did here was just look at the scripts/widgets/crafttabs.lua. Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-602625 Share on other sites More sharing options...
Razcaz89 Posted January 17, 2015 Author Share Posted January 17, 2015 (edited) ok its all working modifying the crafttabs.lua in the game files to this fixed the "closeing of crafting tabs when you pass 33% of your screen" (3 screens = left screen is about 33% so when i was moving the craft tabs onto center screen it was simply running the close function.) if self.crafting.open then local x = TheInput:GetScreenPosition().x local w,h = TheSim:GetScreenSize() if x > w*1 then -- if x > w*0.33 then (this is the old values) self.crafting:Close() self.tabs:DeselectAll() end endnow im having brain fail implimenting that into my mod lol im so new to lua and have very little experience with any other code, i did visual basic in year 8 and abit of java in year 11 and that was 10 years ago now. im not sure how i would go about changing that value in the middle of the function it runs in Edited January 19, 2015 by Razcaz89 Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-602979 Share on other sites More sharing options...
Razcaz89 Posted January 17, 2015 Author Share Posted January 17, 2015 (edited) . Edited January 19, 2015 by Razcaz89 Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-602984 Share on other sites More sharing options...
DarkXero Posted January 17, 2015 Share Posted January 17, 2015 You will have to overwrite the OnUpdate function. Use:AddClassPostConstruct("crafttabs", function(self, owner, top_root) function CraftTabs:OnUpdate(dt) --Same function but with w = 1 endend) Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-603112 Share on other sites More sharing options...
Razcaz89 Posted January 19, 2015 Author Share Posted January 19, 2015 (edited) alright i still can't get this function to update from my mod all i get is error's no matter how i think i should write it this is my crafttabs.lua that works perfectlyfunction CraftTabs:OnUpdate(dt) self.hint_update_check = self.hint_update_check - dt if 0 > self.hint_update_check then if not TheInput:ControllerAttached() then self.openhint:Hide() else self.openhint:Show() self.openhint:SetString(TheInput:GetLocalizedControl(TheInput:GetControllerID(), CONTROL_OPEN_CRAFTING)) end self.hint_update_check = HINT_UPDATE_INTERVAL end if self.crafting.open then local x = TheInput:GetScreenPosition().x local w,h = TheSim:GetScreenSize() if x > w*0.55 or x < w*0.22 then -- THIS IS THE MODIFIED LINE -- if x > w*0.33 then -- Original Line self.crafting:Close() self.tabs:DeselectAll() end end if self.needtoupdate then self:DoUpdateRecipes() end endif self.needtoupdate thenself:DoUpdateRecipes()endendive already cut up the crafting textures to fit the screen nicely and adjusted locations of everything Edited January 19, 2015 by Razcaz89 Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-603548 Share on other sites More sharing options...
rezecib Posted January 19, 2015 Share Posted January 19, 2015 all i get is error's What kind of errors? The first change I see that you'd need to have would be making any calls to TheInput go to GLOBAL.TheInput instead (same for TheSim and CONTROL_OPEN_CRAFTING). You'll also have to replace HINT_UPDATE_INTERVAL with 2.0, which is its value in crafttabs, but it's local to that file. I think that's all you'd need to change? Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-603625 Share on other sites More sharing options...
Razcaz89 Posted January 19, 2015 Author Share Posted January 19, 2015 (edited) this is how i wrote it.....AddClassPostConstruct("crafttabs", function(self, owner, top_root) function CraftTabs:OnUpdate(dt) self.hint_update_check = self.hint_update_check - dt if 0 > self.hint_update_check then if not GLOBAL.TheInput:ControllerAttached() then self.openhint:Hide() else self.openhint:Show() self.openhint:SetString(GLOBAL.TheInput:GetLocalizedControl(GLOBAL.TheInput:GetControllerID(), GLOBAL.CONTROL_OPEN_CRAFTING)) end self.hint_update_check = 2 end if self.crafting.open then local x = GLOBAL.TheInput:GetScreenPosition().x local w,h = GLOBAL.TheSim:GetScreenSize() if x > w*0.43 or x < w*0.22 then -- THIS IS THE MODIFIED LINE -- if x > w*0.33 then -- Original Line self.crafting:Close() self.tabs:DeselectAll() end end if self.needtoupdate then self:DoUpdateRecipes() end endend) this is the error code[00:00:21]: Mod: 3-Screen Hud Fix (3-Screen HUD Fix) Error loading mod![string "scripts/modutil.lua"]:70: module 'crafttabs' not found:no file '../mods/3-Screen Hud Fix/scripts/crafttabs.lua' (checked with custom loader)no file 'scripts/crafttabs.lua' (checked with custom loader)no file 'scriptlibs/crafttabs.lua' (checked with custom loader)no file 'scripts/crafttabs.lua' (checked with custom loader)no field package.preload['crafttabs']no file '..\mods\3-Screen Hud Fix\scripts\crafttabs.lua'no file 'scripts\crafttabs.lua'no file 'scriptlibs\crafttabs.lua'no file 'scripts/crafttabs.lua'LUA ERROR stack traceback:=[C] in function 'require'scripts/modutil.lua(70,1) in function 'AddClassPostConstruct'scripts/modutil.lua(286,1) in function 'AddClassPostConstruct'../mods/3-Screen Hud Fix/modmain.lua(26,1) in main chunk=[C] in function 'xpcall'scripts/util.lua(455,1) in function 'RunInEnvironment'scripts/mods.lua(319,1) in function 'InitializeModMain'scripts/mods.lua(300,1) in function 'LoadMods'scripts/main.lua(244,1) in function 'ModSafeStartup'scripts/main.lua(292,1)=[C] in function 'SetPersistentString'scripts/mainfunctions.lua(24,1) in function 'SavePersistentString'scripts/modindex.lua(76,1)=[C] in function 'GetPersistentString'scripts/modindex.lua(63,1) in function 'BeginStartupSequence'scripts/main.lua(291,1) in function 'callback'scripts/modindex.lua(342,1)=[C] in function 'GetPersistentString'scripts/modindex.lua(322,1) in function 'Load'scripts/main.lua(290,1) in main chunk and writing it like thislocal function CraftUpdatePostInit(self) function CraftTabs:OnUpdate(dt) self.hint_update_check = self.hint_update_check - dt if 0 > self.hint_update_check then if not GLOBAL.TheInput:ControllerAttached() then self.openhint:Hide() else self.openhint:Show() self.openhint:SetString(GLOBAL.TheInput:GetLocalizedControl(GLOBAL.TheInput:GetControllerID(), GLOBAL.CONTROL_OPEN_CRAFTING)) end self.hint_update_check = 2 end if self.crafting.open then local x = GLOBAL.TheInput:GetScreenPosition().x local w,h = GLOBAL.TheSim:GetScreenSize() if x > w*0.43 or x < w*0.22 then -- THIS IS THE MODIFIED LINE -- if x > w*0.33 then -- Original Line self.crafting:Close() self.tabs:DeselectAll() end end if self.needtoupdate then self:DoUpdateRecipes() end endendAddClassPostConstruct("widgets/crafttabs", CraftUpdatePostInit) breaks the mouse hover textwith error message[00:00:23]: [string "../mods/3-Screen Hud Fix/modmain.lua"]:27: attempt to index global 'CraftTabs' (a nil value)LUA ERROR stack traceback:../mods/3-Screen Hud Fix/modmain.lua:27 in (upvalue) postfn (Lua) <26-54> self = callbacks = table: 23914FE8 bg_cover = Image - ../mods/3-Screen Hud Fix/images/hud.xml:craft_bg_cover.tex inst = 112528 - (valid:true) focus = false children = table: 23914FC0 focus_flow_args = table: 23914D90 focus_target = false craft_idx_by_tab = table: 23914E08 bg = Image - ../mods/3-Screen Hud Fix/images/hud.xml:craft_bg.tex openhint = Text - owner = 112358 - wilson (valid:true) shown = false controllercrafting = Crafting enabled = true tabs = TabGroup name = CraftTabs tabbyfilter = table: 39C8D540 focus_flow = table: 23914D18 hint_update_check = 2 crafting = Crafting tab_order = table: 39C8D3D8 this is alittle further down the log where the next error occurs with complete game freeze [00:00:23]: SCRIPT ERROR! Showing error screen [00:00:23]: #[string "scripts/widgets/hoverer.lua"]:44: attempt to index field 'controls' (a nil value)#LUA ERROR stack traceback:@scripts/widgets/hoverer.lua:44 in (method) OnUpdate (Lua) <26-123> self = callbacks = table: 239143B8 followhandler = table: 23914EA8 lastStr = inst = 112525 - (valid:true) focus = false children = table: 239144D0 focus_flow_args = table: 23914840 focus_target = false secondarytext = Text - owner = 112358 - wilson (valid:true) parent = Controls strFrames = 0 name = HoverText enabled = true focus_flow = table: 23914110 text = Text - shown = true isFE = false using_mouse = true str = nil edit: edited all my posts so that errors stop occuring in the topic Edited January 19, 2015 by Razcaz89 Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-603685 Share on other sites More sharing options...
DarkXero Posted January 19, 2015 Share Posted January 19, 2015 Right, sorry, I'm an idiot, I had the same error in other situation. As you can see, the module isn't found. Switch "crafttabs" for "widgets/crafttabs" in AddClassPostConstruct. Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-603727 Share on other sites More sharing options...
rezecib Posted January 19, 2015 Share Posted January 19, 2015 function CraftTabs:OnUpdate(dt) Change this to self:OnUpdate(dt) Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-603755 Share on other sites More sharing options...
Razcaz89 Posted January 21, 2015 Author Share Posted January 21, 2015 alright i got it working very quickly once i changed crafttabs:onupdate(dt) to self:OnUpdate(dt) Link to comment https://forums.kleientertainment.com/forums/topic/49226-centering-hud-on-3-screen-setup-half-working/#findComment-604313 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