Jump to content

Recommended Posts

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 interface

tho 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

post-573344-0-44597400-1421411848_thumb.

Edited by Razcaz89

@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.

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    end

now 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 by Razcaz89

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 perfectly

function 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()endend

ive already cut up the crafting textures to fit the screen nicely and adjusted locations of everything

post-573344-0-06663500-1421627316_thumb.

Edited by Razcaz89
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?

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 this

local 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 text

with 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 :hopelessness:

 

 

[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 by Razcaz89

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...