Guest User

Untitled

a guest
Nov 1st, 2025
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | Gaming | 0 0
  1. --[[
  2. -- Author --
  3.  
  4. Christian (dev_cmedina)
  5.  
  6. -- Key Configurations --
  7.  
  8. Feel free to change these to whatever you like.
  9. A list of all valid keys can be found here:
  10.  
  11. https://raw.githubusercontent.com/UE4SS-RE/RE-UE4SS/ccfe4a45d0ea5aa5f8fc0b27b11d582ad51ae242/docs/lua-api/table-definitions/key.md
  12. --]]
  13.  
  14. MOVE_IN = Key.NUM_EIGHT
  15. MOVE_OUT = Key.NUM_TWO
  16. MOVE_LEFT = Key.NUM_FOUR
  17. MOVE_RIGHT = Key.NUM_SIX
  18. MOVE_UP = Key.NUM_NINE
  19. MOVE_DOWN = Key.NUM_THREE
  20. RESET_CAMERA = Key.MULTIPLY
  21. SAVE_CAMERA = Key.DIVIDE
  22.  
  23. --------------------
  24.  
  25. isInitialized = false
  26. CameraController = nil
  27. AimController = nil
  28. Character = nil
  29. offsetX = -15
  30. offsetY = 15
  31. offsetZ = 65
  32. DEFAULT_CAMERA_OFFSET_X = -15
  33. DEFAULT_CAMERA_OFFSET_Y = 15
  34. DEFAULT_CAMERA_OFFSET_Z = 90
  35.  
  36. local function SetOffsetX(offsetDelta)
  37. offsetX = offsetX + offsetDelta
  38. end
  39.  
  40. local function SetOffsetY(offsetDelta)
  41. offsetY = offsetY + offsetDelta
  42. end
  43.  
  44. local function SetOffsetZ(offsetDelta)
  45. offsetZ = offsetZ + offsetDelta
  46. end
  47.  
  48. local function RefreshCameraOffsets()
  49. -- Versuch 1: normale Syntax
  50. local ok = pcall(function()
  51. AimController:ChangeIsAiming(true)
  52. AimController:ChangeIsAiming(false)
  53. end)
  54.  
  55. if not ok then
  56. -- Versuch 2: mit explizitem Self-Parameter (UE4 erwartet 2 Parameter)
  57. pcall(function()
  58. AimController:ChangeIsAiming(AimController, true)
  59. AimController:ChangeIsAiming(AimController, false)
  60. end)
  61. end
  62. end
  63.  
  64. local function SetCameraOffsets(Camera)
  65. Camera.WalkCameraOffset.X = offsetX
  66. Camera.WalkCameraOffset.Y = offsetY
  67. Camera.WalkCameraOffset.Z = offsetZ
  68.  
  69. Camera.HipShootCameraOffset.X = offsetX
  70. Camera.HipShootCameraOffset.Y = offsetY
  71. Camera.HipShootCameraOffset.Z = offsetZ
  72.  
  73. Camera.AimCameraOffset.X = offsetX
  74. Camera.AimCameraOffset.Y = offsetY
  75. Camera.AimCameraOffset.Z = offsetZ
  76.  
  77. Camera.AirCameraOffset.X = offsetX
  78. Camera.AirCameraOffset.Y = offsetY
  79. Camera.AirCameraOffset.Z = offsetZ
  80.  
  81. Camera.AirHipShootCameraOffset.X = offsetX
  82. Camera.AirHipShootCameraOffset.Y = offsetY
  83. Camera.AirHipShootCameraOffset.Z = offsetZ
  84.  
  85. Camera.FlyCameraOffset.X = offsetX
  86. Camera.FlyCameraOffset.Y = offsetY
  87. Camera.FlyCameraOffset.Z = offsetZ
  88.  
  89. Camera.FlyHipShootCameraOffset.X = offsetX
  90. Camera.FlyHipShootCameraOffset.Y = offsetY
  91. Camera.FlyHipShootCameraOffset.Z = offsetZ
  92.  
  93. Camera.FlyAimCameraOffset.X = offsetX
  94. Camera.FlyAimCameraOffset.Y = offsetY
  95. Camera.FlyAimCameraOffset.Z = offsetZ
  96.  
  97. Camera.CrouchCameraOffset.X = offsetX
  98. Camera.CrouchCameraOffset.Y = offsetY
  99. Camera.CrouchCameraOffset.Z = offsetZ
  100.  
  101. Camera.CrouchHipShootCameraOffset.X = offsetX
  102. Camera.CrouchHipShootCameraOffset.Y = offsetY
  103. Camera.CrouchHipShootCameraOffset.Z = offsetZ
  104.  
  105. Camera.CrouchAimCameraOffset.X = offsetX
  106. Camera.CrouchAimCameraOffset.Y = offsetY
  107. Camera.CrouchAimCameraOffset.Z = offsetZ
  108.  
  109. Camera.SlidingCameraOffset.X = offsetX
  110. Camera.SlidingCameraOffset.Y = offsetY
  111. Camera.SlidingCameraOffset.Z = offsetZ
  112.  
  113. Camera.SlidingHipShootCameraOffset.X = offsetX
  114. Camera.SlidingHipShootCameraOffset.Y = offsetY
  115. Camera.SlidingHipShootCameraOffset.Z = offsetZ
  116.  
  117. Camera.SlidingAimCameraOffset.X = offsetX
  118. Camera.SlidingAimCameraOffset.Y = offsetY
  119. Camera.SlidingAimCameraOffset.Z = offsetZ
  120. end
  121.  
  122. local function ResetCameraOffsets()
  123. offsetX = DEFAULT_CAMERA_OFFSET_X
  124. offsetY = DEFAULT_CAMERA_OFFSET_Y
  125. offsetZ = DEFAULT_CAMERA_OFFSET_Z
  126. SetCameraOffsets(CameraController)
  127. RefreshCameraOffsets()
  128. end
  129.  
  130. local function SaveCameraOffsets()
  131. local file = io.open("./Mods/AdjustableCamera/CameraSettings.lua", "w")
  132. if not file then error("[AdjustableCamera] Unable to save camera settings to system.") end
  133.  
  134. local cameraConfig = {
  135. X = offsetX,
  136. Y = offsetY,
  137. Z = offsetZ,
  138. }
  139.  
  140. file:write("return {\n")
  141. for k, v in pairs(cameraConfig) do
  142. file:write(string.format(" %s = %s,\n", k, tostring(v)))
  143. end
  144. file:write("}\n")
  145. file:close()
  146. print("[AdjustableCamera] Camera offsets saved to CameraSettings.lua.")
  147. end
  148.  
  149. local function LoadCameraOffsets()
  150. local ok, config = pcall(dofile, "./Mods/AdjustableCamera/CameraSettings.lua")
  151. if not ok then return nil end
  152. return config
  153. end
  154.  
  155. local function InitializeCameraOffsets(cameraConfig)
  156. if cameraConfig then
  157. offsetX = cameraConfig.X
  158. offsetY = cameraConfig.Y
  159. offsetZ = cameraConfig.Z
  160. end
  161. end
  162.  
  163. NotifyOnNewObject("/Script/Pal.PalPlayerCharacter", function(Character)
  164. print(Character:GetFullName())
  165. CameraController = Character.CameraBoom
  166. AimController = Character.ShooterComponent
  167.  
  168. if not AimController:IsValid() then error("[AdjustableCamera] Error loading Aim Component.\n") end
  169. if not CameraController:IsValid() then error("[AdjustableCamera] Error loading Camera Controller.\n") end
  170.  
  171. if not isInitialized then
  172. local cameraConfig = LoadCameraOffsets()
  173. InitializeCameraOffsets(cameraConfig)
  174. end
  175.  
  176. SetCameraOffsets(CameraController)
  177.  
  178. isInitialized = true
  179. print("[AdjustableCamera] Initialization complete.")
  180. end)
  181.  
  182. RegisterKeyBind(MOVE_IN, function()
  183. if isInitialized then
  184. ExecuteAsync(function()
  185. SetOffsetX(20)
  186. SetCameraOffsets(CameraController)
  187. RefreshCameraOffsets()
  188. end)
  189. end
  190. end)
  191.  
  192. RegisterKeyBind(MOVE_OUT, function()
  193. if isInitialized then
  194. ExecuteAsync(function()
  195. SetOffsetX(-20)
  196. SetCameraOffsets(CameraController)
  197. RefreshCameraOffsets()
  198. end)
  199. end
  200. end)
  201.  
  202. RegisterKeyBind(MOVE_LEFT, function()
  203. if isInitialized then
  204. ExecuteAsync(function()
  205. SetOffsetY(-10)
  206. SetCameraOffsets(CameraController)
  207. RefreshCameraOffsets()
  208. end)
  209. end
  210. end)
  211.  
  212. RegisterKeyBind(MOVE_RIGHT, function()
  213. if isInitialized then
  214. ExecuteAsync(function()
  215. SetOffsetY(10)
  216. SetCameraOffsets(CameraController)
  217. RefreshCameraOffsets()
  218. end)
  219. end
  220. end)
  221.  
  222. RegisterKeyBind(MOVE_UP, function()
  223. if isInitialized then
  224. ExecuteAsync(function()
  225. SetOffsetZ(10)
  226. SetCameraOffsets(CameraController)
  227. RefreshCameraOffsets()
  228. end)
  229. end
  230. end)
  231.  
  232. RegisterKeyBind(MOVE_DOWN, function()
  233. if isInitialized then
  234. ExecuteAsync(function()
  235. SetOffsetZ(-10)
  236. SetCameraOffsets(CameraController)
  237. RefreshCameraOffsets()
  238. end)
  239. end
  240. end)
  241.  
  242. RegisterKeyBind(RESET_CAMERA, function()
  243. if isInitialized then
  244. ExecuteAsync(function()
  245. ResetCameraOffsets()
  246. end)
  247. end
  248. end)
  249.  
  250. RegisterKeyBind(SAVE_CAMERA, function()
  251. if isInitialized then
  252. ExecuteAsync(function()
  253. SaveCameraOffsets()
  254. end)
  255. end
  256. end)
Tags: palworld
Advertisement
Add Comment
Please, Sign In to add comment