Make scripts run on client

This commit is contained in:
2025-03-31 17:43:36 +02:00
parent 42ba29dc9d
commit 9ba782b8e9
13 changed files with 37 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
-- luacheck: globals Item Vector2 Character MyModGlobal -- luacheck: globals Item Vector2 Character MyModGlobal CLIENT
-- luacheck: max line length 420 -- luacheck: max line length 420
if not CLIENT then return end
local dump = require("Cyka.dump") local dump = require("Cyka.dump")
local quickstack = require("Cyka.quickstack") local quickstack = require("Cyka.quickstack")

View File

@@ -1,4 +1,5 @@
-- luacheck: globals Character MyModGlobal Timer -- luacheck: globals Character MyModGlobal Timer CLIENT
if not CLIENT then return end
local quickstack = require("Cyka.quickstack") local quickstack = require("Cyka.quickstack")
local utils = require("Cyka.utils") local utils = require("Cyka.utils")

View File

@@ -1,4 +1,5 @@
-- luacheck: globals Character Game MyModGlobal -- luacheck: globals Character Game MyModGlobal CLIENT
if not CLIENT then return end
local utils = require("Cyka.utils") local utils = require("Cyka.utils")
local dump = require("Cyka.dump") local dump = require("Cyka.dump")

View File

@@ -1,4 +1,6 @@
-- luacheck: globals Character MyModGlobal -- luacheck: globals Character MyModGlobal CLIENT
if not CLIENT then return end
---@return Barotrauma.Item|nil, Barotrauma.Items.Components.Repairable|nil ---@return Barotrauma.Item|nil, Barotrauma.Items.Components.Repairable|nil
local function getRepairableObjectInFocus() local function getRepairableObjectInFocus()
-- Make sure we have a controlled character -- Make sure we have a controlled character
@@ -51,8 +53,8 @@ local function clickRepairButton()
local button = repairableComponent.RepairButton local button = repairableComponent.RepairButton
if button then if button then
MyModGlobal.debugPrint("Clicking repair button") MyModGlobal.debugPrint("Clicking repair button")
-- button.OnClicked(button, repairableComponent) -- Try to access repair functionality directly
button.OnButtonDown() repairableComponent.requestStartFixAction = 1 -- FixActions.Repair = 1
end end
-- MyModGlobal.debugPrint("StartRepairing result: " .. tostring(result)) -- MyModGlobal.debugPrint("StartRepairing result: " .. tostring(result))

View File

@@ -1,4 +1,5 @@
-- luacheck: globals MyModGlobal Character Hook EnsurePatch -- luacheck: globals MyModGlobal Character Hook EnsurePatch CLIENT
if not CLIENT then return end
local utils = require "Cyka.utils" local utils = require "Cyka.utils"
local dump = require "Cyka.dump" local dump = require "Cyka.dump"

View File

@@ -1,4 +1,6 @@
-- luacheck: globals Game MyModGlobal -- luacheck: globals Game MyModGlobal CLIENT
if not CLIENT then return end
---@return Barotrauma.Location.StoreInfo[], string? ---@return Barotrauma.Location.StoreInfo[], string?
local function getCurrentStore() local function getCurrentStore()
if not Game or not Game.GameSession or not Game.GameSession.Campaign then if not Game or not Game.GameSession or not Game.GameSession.Campaign then

View File

@@ -1,4 +1,6 @@
-- luacheck: globals Character MyModGlobal -- luacheck: globals Character MyModGlobal CLIENT
if not CLIENT then return end
local dump = require("Cyka.dump") local dump = require("Cyka.dump")
local utils = require("Cyka.utils") local utils = require("Cyka.utils")
local quickstack = require("Cyka.quickstack") local quickstack = require("Cyka.quickstack")

View File

@@ -1,5 +1,7 @@
-- luacheck: globals Character MyModGlobal Timer -- luacheck: globals Character MyModGlobal Timer CLIENT
-- luacheck: max line length 420 -- luacheck: max line length 420
if not CLIENT then return end
local utils = require("Cyka.utils") local utils = require("Cyka.utils")
local dump = require("Cyka.dump") local dump = require("Cyka.dump")

View File

@@ -1,5 +1,7 @@
-- luacheck: globals MyModGlobal Character -- luacheck: globals MyModGlobal Character CLIENT
-- luacheck: max line length 420 -- luacheck: max line length 420
if not CLIENT then return end
local utils = require("Cyka.utils") local utils = require("Cyka.utils")
---@class ItemLocation ---@class ItemLocation

View File

@@ -1,4 +1,6 @@
-- luacheck: globals Character MyModGlobal Timer -- luacheck: globals Character MyModGlobal Timer CLIENT
if not CLIENT then return end
local utils = require("Cyka.utils") local utils = require("Cyka.utils")
---@param inventory Barotrauma.ItemInventory ---@param inventory Barotrauma.ItemInventory
@@ -96,7 +98,8 @@ local function tryUnloadSlot(slot)
for _, nearbySlot in ipairs(nearbySlots) do for _, nearbySlot in ipairs(nearbySlots) do
local canAccept = nearbySlot.inventory.CanBePutInSlot(iitem.Prefab, nearbySlot.slotIndex) local canAccept = nearbySlot.inventory.CanBePutInSlot(iitem.Prefab, nearbySlot.slotIndex)
if canAccept then if canAccept then
local moved = nearbySlot.inventory.TryPutItem(iitem, nearbySlot.slotIndex, true, false, Character.Controlled, true) local moved = nearbySlot.inventory.TryPutItem(iitem, nearbySlot.slotIndex, true, false,
Character.Controlled, true)
-- print(string.format("Moved item %s to slot %d", iitem.Name, nearbySlot.slotIndex)) -- print(string.format("Moved item %s to slot %d", iitem.Name, nearbySlot.slotIndex))
if moved then break end if moved then break end
end end

View File

@@ -1,4 +1,6 @@
-- luacheck: globals Character MyModGlobal LuaUserData Descriptors Timer -- luacheck: globals Character MyModGlobal LuaUserData Descriptors Timer CLIENT
if not CLIENT then return end
local dump = require("Cyka.dump") local dump = require("Cyka.dump")
-- LuaUserData.MakeMethodAccessible(Descriptors["Barotrauma.Sonar"], "UpdateGUIElements") -- LuaUserData.MakeMethodAccessible(Descriptors["Barotrauma.Sonar"], "UpdateGUIElements")

View File

@@ -1,7 +1,7 @@
-- luacheck: globals Character Timer Hook SERVER -- luacheck: globals Character Timer Hook SERVER CLIENT
if not SERVER then return end if not SERVER then return end
local amountExperience = 6000 local amountExperience = 6000
local passiveExperienceDelay = 60 local passiveExperienceDelay = 2
local passiveExperienceTimer = 0 local passiveExperienceTimer = 0
Hook.Add("think", "examples.passiveExperience", function() Hook.Add("think", "examples.passiveExperience", function()

View File

@@ -1,6 +1,6 @@
-- luacheck: globals SERVER Hook Keys LuaUserData PlayerInput Character Descriptors -- luacheck: globals Hook Keys LuaUserData PlayerInput Character Descriptors CLIENT
-- luacheck: max line length 420 -- luacheck: max line length 420
if SERVER then return end if not CLIENT then return end
local isToggle = true -- toggle or hold behaviour local isToggle = true -- toggle or hold behaviour
local smoothZoom = false -- smooth or step local smoothZoom = false -- smooth or step