Don't Starve Together

Don't Starve Together

Pickle's First Person Mod
108 20 Oct, 2020 @ 9:30pm
Code changes
 
< >
Showing 1-3 of 3 comments
108 20 Oct, 2020 @ 9:31pm 
Just a more efficient way to disable drag walking. It works just by replacing the old disable dragwalking code. This also may or may not fix the Forge crash. (Haven't tested.)

-- Disable dragwalking
local ACTIONS = GLOBAL.ACTIONS
local BufferedAction = GLOBAL.BufferedAction
local TheInput = GLOBAL.TheInput

local PlayerControllerPostConstruct = function(self)
local OriginalOnLeftClick = self.OnLeftClick

self.OnLeftClick = function(self, down)
-- IsAOETargeting only exists in DST Forge, check if it exists for DS compatibility
local LocalIsAOET = false
if self.IsAOETargeting then
LocalIsAOET = self:IsAOETargeting()
end

-- Prevent dragwalking if down and nothing is being placed
if down and (self.placer_recipe == nil or self.placer == nil) and not LocalIsAOET then
local act = self:GetLeftMouseAction() or BufferedAction(self.inst, nil, ACTIONS.WALKTO, nil, TheInput:GetWorldPosition())
local mouseEntity = TheInput:GetWorldEntityUnderMouse()
local mousePointsAtPlayerOrNil = mouseEntity == nil or mouseEntity == self.inst
if act.action == ACTIONS.WALKTO and act.target == nil and mousePointsAtPlayerOrNil then
return
end
end

return OriginalOnLeftClick(self, down)
end
end

AddClassPostConstruct('components/playercontroller', PlayerControllerPostConstruct)

Steam removes tabs and spaces.
108 20 Oct, 2020 @ 9:32pm 
local function ReApplyGhostHands( inst, forcereskin )
inst.AnimState:HideSymbol("swap_body")
inst.AnimState:HideSymbol("swap_hat")
inst.AnimState:SetLayer(4)

to

local function ReApplyGhostHands( inst, forcereskin )
inst.AnimState:HideSymbol("swap_body")
inst.AnimState:HideSymbol("swap_hat")
inst.AnimState:SetLayer(6)

I recommend changing inst.AnimState:SetLayer(4) to inst.AnimState:SetLayer(6) (or 5 i guess) which is LAYER_FRONTEND as LAYER_WORLD_CEILING causes tools and hands to go behind trees and stuff while interacting with them (chopping, collecting)
Pickleplayer  [developer] 2 Nov, 2020 @ 6:30pm 
Huh, I've never been offered code optimizations before. Next time I fix up this mod for compatibility, I'll see about trying this out. Thanks!
< >
Showing 1-3 of 3 comments
Per page: 1530 50