FrameworkZ 10.8.3
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
fzta_LockUnlockWindow.lua
Go to the documentation of this file.
1if not isClient() then return end
5
6require "TimedActions/ISBaseTimedAction"
7
9
10function ISLockUnlockWindow:isValid()
11 local keyId = self.window:getKeyId()
12 if self.character:getInventory():haveThisKeyId(keyId) then return true end
13 return FrameworkZ.Utilities:IsTrulyInterior(self.character:getSquare())
14end
15
16function ISLockUnlockWindow:update() end
17
18function ISLockUnlockWindow:start()
19 self.character:faceThisObject(self.window)
20end
22function ISLockUnlockWindow:stop()
23 if not self:isValid() then
24 self.character:faceThisObject(self.window)
25 self.character:getEmitter():playSound("DoorIsLocked")
26 end
27
29end
30
31if isServer() then
32 function ISLockUnlockWindow.LockWindow(data, coordinates)
33 local x, y, z = coordinates.x, coordinates.y, coordinates.z
34 local window = getSquare(x, y, z) and getSquare(x, y, z).getWindow and getSquare(x, y, z):getWindow() or nil
35
36 if window then
37 window:setPermaLocked(true)
38 window:setIsLocked(true)
39 end
40 end
41 FrameworkZ.Foundation:Subscribe("ISLockUnlockWindow.LockWindow", ISLockUnlockWindow.LockWindow)
42
43 function ISLockUnlockWindow.UnlockWindow(data, coordinates)
44 local x, y, z = coordinates.x, coordinates.y, coordinates.z
45 local window = getSquare(x, y, z) and getSquare(x, y, z).getWindow and getSquare(x, y, z):getWindow() or nil
46
47 if window then
48 window:setPermaLocked(false)
49 window:setIsLocked(false)
50 end
51 end
52 FrameworkZ.Foundation:Subscribe("ISLockUnlockWindow.UnlockWindow", ISLockUnlockWindow.UnlockWindow)
53end
54
55function ISLockUnlockWindow:perform()
56 if self.shouldLock then
57 FrameworkZ.Foundation:SendFire(self.character, "ISLockUnlockWindow.LockWindow", function()
58 self.window:setPermaLocked(true)
59 self.window:setIsLocked(true)
60 self.character:getEmitter():playSound("WoodDoorLock")
61 end, {self.window:getX(), self.window:getY(), self.window:getZ()})
62 elseif not self.shouldLock then
63 FrameworkZ.Foundation:SendFire(self.character, "ISLockUnlockWindow.LockWindow", function()
64 self.window:setPermaLocked(false)
65 self.window:setIsLocked(false)
66 self.character:getEmitter():playSound("WoodDoorLock")
67 end, {self.window:getX(), self.window:getY(), self.window:getZ()})
68 end
69
70 ISBaseTimedAction.perform(self)
71end
72
73function ISLockUnlockWindow:new(character, window, shouldLock)
74 local o = {}
75
76 setmetatable(o, self)
77 self.__index = self
78 o.character = character
79 o.window = window
80 o.shouldLock = shouldLock
81 o.stopOnWalk = true
82 o.stopOnRun = true
83 o.maxTime = 0
84
85 return o
86end
void local y()
void local x()
void self FrameworkZ UI self nil
Definition MainMenu.lua:95
void self self
Definition MainMenu.lua:89
void local getSquare()
void local isClient()
void local isServer()
void local data()
void FrameworkZ Foundation()
void local IsoFlagType()
void local ISBaseTimedAction()
void UnnamedFunction()
void ISLockUnlockWindow()
Foundation for FrameworkZ.
void UnlockWindow(data, coordinates)
void LockWindow(data, coordinates)