From 83e1d8dc75f15c91f2bd4bf0a495f7f925e67a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fab=C3=ADk?= Date: Sat, 11 Aug 2018 22:33:35 +0200 Subject: [PATCH] Release version 4.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See changelog for list of changes from version 4.0.4 This release officialy closes these issues: Close #1 - Fix camera on outside IC Close #2 - Vehicle's IC could be activated from attacher vehicle Close #4 - Possibility to save toggle style Close #5 - Update error when using turn on functions Close #6 - Network communication Network communication was completely tested by Adam Maršík --- README.md | 4 +- release/README.md | 7 +- release/icSources/InteractiveControl.lua | 219 ++++++++++-------- release/icSources/InteractiveControlEvent.lua | 27 ++- release/icSources/actionFunction.lua | 57 +++-- 5 files changed, 171 insertions(+), 143 deletions(-) diff --git a/README.md b/README.md index e481c43..55aa752 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ You can find all changes between versions in [changelog](./CHANGELOG.md) ### Release -Last script release version: 4.0.4. +Last script release version: 4.1.0. -Release date: 2018-01-25 +Release date: 2018-08-11 ### Development diff --git a/release/README.md b/release/README.md index 0f2e7e2..0576818 100644 --- a/release/README.md +++ b/release/README.md @@ -1,4 +1,4 @@ -# Interactive Control 4.0.4 +# Interactive Control 4.1.0 GitHub repository with releases: https://github.com/LoogleCZ/FS17-InteractiveControl @@ -8,7 +8,10 @@ Author: Martin Fabík Contributor: GtX from LS Modcompany -Testing: Ago-Systemtech (Modhoster Team) +Testing: + +- Ago-Systemtech (Modhoster Team) +- Adam Maršík ## Licence diff --git a/release/icSources/InteractiveControl.lua b/release/icSources/InteractiveControl.lua index a22cd85..9e49b7b 100644 --- a/release/icSources/InteractiveControl.lua +++ b/release/icSources/InteractiveControl.lua @@ -12,8 +12,8 @@ -- GitHub project: https://github.com/LoogleCZ/FS17-InteractiveControl -- If anyone found errors, please contact me at mar.fabik@gmail.com or report it on GitHub -- --- version ID - 4.0.4 --- version date - 2018-01-25 12:15:00 +-- version ID - 4.1.0 +-- version date - 2018-08-11 16:30:00 -- InteractiveControl = {}; @@ -67,7 +67,7 @@ function InteractiveControl:load(savegame) return calculateIndex+index; end; - self.LIC.toggleStyleState = 1; + self.LIC.toggleStyleState = Utils.clamp(Utils.getNoNil(getXMLInt(self.xmlFile,"vehicle.interactiveComponents#toggleStyle"), 1), 1, 2); self.LIC.lastMouseXPos = 0; self.LIC.lastMouseYPos = 0; self.LIC.foundInteractiveObject = nil; @@ -245,7 +245,7 @@ function InteractiveControl:load(savegame) k = k + 1; end; j = j + 1; - self:actionOnObject(upperLayerIndex, false); + self:actionOnObject(upperLayerIndex, false, true); self.LIC:loadICButtonFromXML(self, self.xmlFile, key, self.LIC.interactiveObjects[upperLayerIndex], upperLayerIndex); self.LIC.partsLength[InteractiveControl.OBJECT_TYPE_MONITOR] = self.LIC.partsLength[InteractiveControl.OBJECT_TYPE_MONITOR] + 1; else @@ -424,7 +424,7 @@ function InteractiveControl:postLoad(savegame) -- init actions here end; if savegame ~= nil then - local icToggleStyle = getXMLInt(savegame.xmlFile, savegame.key.."#icToggleStyle"); + local icToggleStyle = getXMLInt(savegame.xmlFile, savegame.key..".interactiveControl#toggleStyle"); if icToggleStyle ~= nil then self.LIC.toggleStyleState = icToggleStyle; end; @@ -472,8 +472,7 @@ function InteractiveControl:getSaveAttributesAndNodes(nodeIdent) return minusIndex+index; end; - local attributes = 'icStateStyle="' .. tostring(self.LIC.toggleStyleState) .. '" '; - local nodes = "\t\t\n"; + local nodes = "\t\t\n"; for k,v in pairs(self.LIC.interactiveObjects) do if v.objectType == InteractiveControl.OBJECT_TYPE_ANIMATION then if v.saveStatus then @@ -487,7 +486,7 @@ function InteractiveControl:getSaveAttributesAndNodes(nodeIdent) end; end; nodes = nodes .. "\t\t"; - return attributes, nodes; + return nil, nodes; end function InteractiveControl:delete() @@ -504,11 +503,9 @@ end; function InteractiveControl:readStream(streamId, connection) -- OK local icCount = streamReadInt8(streamId); for i=0, icCount do - local isOpen = streamReadBool(streamId); - if self.LIC.interactiveObjects[i] ~= nil then - if self.LIC.interactiveObjects[i].synch then - self:actionOnObject(i, isOpen, false); - end; + if self.LIC.interactiveObjects[i].synch then + local isOpen = streamReadBool(streamId); + self:actionOnObject(i, isOpen, true); end; end; end; @@ -517,7 +514,9 @@ function InteractiveControl:writeStream(streamId, connection) -- OK local icCount = (table.getn(self.LIC.interactiveObjects)-1); streamWriteInt8(streamId, icCount); for i=0, icCount do - streamWriteBool(streamId, self.LIC.interactiveObjects[i].isOpen); + if self.LIC.interactiveObjects[i].synch then + streamWriteBool(streamId, self.LIC.interactiveObjects[i].isOpen); + end; end; end; @@ -530,55 +529,45 @@ function InteractiveControl:keyEvent(unicode, sym, modifier, isDown) -- OK end; function InteractiveControl:update(dt) -- OK - - if self.isClient and self:getIsActiveForSound() then - for _,v in pairs(self.LIC.sounds) do - local object = self.LIC.interactiveObjects[v.componentIndex]; - - if object.isOpen and v.openSound ~= nil then - SoundUtil.playSample(v.openSound, 0, 0, nil); - else - SoundUtil.stopSample(v.openSound); - end; - if not object.isOpen and v.closeSound ~= nil then - SoundUtil.playSample(v.closeSound, 0, 0, nil); - else - SoundUtil.stopSample(v.closeSound); - end; - if object.isOpen ~= v.componentStatus then - if object.isOpen and v.openingSound ~= nil then - SoundUtil.playSample(v.openingSound, 1, 0, nil); - if v.closingSound ~= nil then - SoundUtil.stopSample(v.closingSound); - end; + if self.isClient then + if self:getIsActiveForSound() then -- sounds + for _,v in pairs(self.LIC.sounds) do + local object = self.LIC.interactiveObjects[v.componentIndex]; + + if object.isOpen and v.openSound ~= nil then + SoundUtil.playSample(v.openSound, 0, 0, nil); + else + SoundUtil.stopSample(v.openSound); end; - if not object.isOpen and v.closingSound ~= nil then - SoundUtil.playSample(v.closingSound, 1, 0, nil); - if v.openingSound ~= nil then - SoundUtil.stopSample(v.openingSound); + if not object.isOpen and v.closeSound ~= nil then + SoundUtil.playSample(v.closeSound, 0, 0, nil); + else + SoundUtil.stopSample(v.closeSound); + end; + if object.isOpen ~= v.componentStatus then + if object.isOpen and v.openingSound ~= nil then + SoundUtil.playSample(v.openingSound, 1, 0, nil); + if v.closingSound ~= nil then + SoundUtil.stopSample(v.closingSound); + end; + end; + if not object.isOpen and v.closingSound ~= nil then + SoundUtil.playSample(v.closingSound, 1, 0, nil); + if v.openingSound ~= nil then + SoundUtil.stopSample(v.openingSound); + end; end; end; + v.componentStatus = object.isOpen; end; - v.componentStatus = object.isOpen; end; - end; - - if self.isClient then - self.LIC.toggleStyleState = math.min(2, math.max(self.LIC.toggleStyleState, 1)); - if self.LIC.lastCamIndexUsed ~= nil and self.LIC.lastCamIndexUsed ~= self.camIndex then + -- if user toggle cam disable IC + if self.LIC.lastCamIndexUsed ~= nil + and self.LIC.lastCamIndexUsed ~= self.camIndex then self:toggleICState(nil, false); end; - if self:getIsActive() then -- toggle IC toggle type - if InputBinding.hasEvent(InputBinding.INTERACTIVE_CONTROL_MODE) then - self.LIC.toggleStyleState = self.LIC.toggleStyleState + 1; - if self.LIC.toggleStyleState > 2 then - self.LIC.toggleStyleState = 1; - end; - end; - end; - if self.isMotorStarted then -- monitor on/off on start self.forceIsActive = true; if not self.LIC.isInitialized then @@ -614,10 +603,17 @@ function InteractiveControl:update(dt) -- OK else self.LIC.isClicked = false; end; - - self.LIC.foundInteractiveObject = nil; - if self.LIC.isInOutsideRange or (self:getIsActive() and self:getIsActiveForInput(false) and not self:hasInputConflictWithSelection()) then + if self.LIC.isInOutsideRange or (self:getIsActive() and self:getIsActiveForInput(false) and not self:hasInputConflictWithSelection() and self.isEntered) then + if self:getIsActive() then -- toggle IC toggle type (only when we have help) + if InputBinding.hasEvent(InputBinding.INTERACTIVE_CONTROL_MODE) then + self.LIC.toggleStyleState = self.LIC.toggleStyleState + 1; + if self.LIC.toggleStyleState > 2 then + self.LIC.toggleStyleState = 1; + end; + end; + end; + if self.LIC.toggleStyleState == 1 then if InputBinding.hasEvent(InputBinding.INTERACTIVE_CONTROL_SWITCH) then self:toggleICState(self.LIC.isInOutsideRange); @@ -629,16 +625,20 @@ function InteractiveControl:update(dt) -- OK end; elseif self.LIC.toggleStyleState == 2 then if InputBinding.isPressed(InputBinding.INTERACTIVE_CONTROL_SWITCH) then - self:toggleICState(self.LIC.isInOutsideRange, true); + if not self.LIC.isMouseActive then + self:toggleICState(self.LIC.isInOutsideRange, true); + end; else - self:toggleICState(self.LIC.isInOutsideRange, false); + if self.LIC.isMouseActive then + self:toggleICState(self.LIC.isInOutsideRange, false); + end; end; if not self.LIC.isMouseActive then g_currentMission:addHelpButtonText(g_i18n:getText("InteractiveControl_On"), InputBinding.INTERACTIVE_CONTROL_SWITCH); end; end; - end; - if self:getIsActive() and self:getIsActiveForInput(false) and not self:hasInputConflictWithSelection() then + + -- help for toggle style if self.LIC.toggleStyleState == 1 then if self.LIC.isMouseActive then g_currentMission:addHelpButtonText(string.format(g_i18n:getText("InteractiveControl_ModeSelect"), g_i18n:getText("button_normal")), InputBinding.INTERACTIVE_CONTROL_MODE, nil, GS_PRIO_HIGH) @@ -647,24 +647,33 @@ function InteractiveControl:update(dt) -- OK if self.LIC.isMouseActive then g_currentMission:addHelpButtonText(string.format(g_i18n:getText("InteractiveControl_ModeSelect"), g_i18n:getText("InteractiveControl_Quick")), InputBinding.INTERACTIVE_CONTROL_MODE, nil, GS_PRIO_HIGH) end; - end + end; end; - if self.LIC.isMouseActive and not self.isEntered then - self.LIC.lastMouseXPos = InputBinding.mousePosXLast; - self.LIC.lastMouseYPos = InputBinding.mousePosYLast; - for _,v in pairs(self.LIC.interactiveObjects) do - v.isEntered = false; - end - if self.LIC.lastMouseXPos ~= nil and self.LIC.lastMouseYPos ~= nil then - for k,v in pairs(self.LIC.interactiveObjects) do - if v.mark ~= nil and self.LIC.foundInteractiveObject == nil then - local worldX,worldY,worldZ = getWorldTranslation(v.mark); - local x,y,z = project(worldX,worldY,worldZ); - if z <= 1 then - if self.LIC.lastMouseXPos > (x-v.size/2) and self.LIC.lastMouseXPos < (x+v.size/2) then - if self.LIC.lastMouseYPos > (y-v.size/2) and self.LIC.lastMouseYPos < (y+v.size/2) then - if v.canOutside then + -- reset components + for _,v in pairs(self.LIC.interactiveObjects) do + v.isEntered = false; + if v.pulse ~= nil then + if v.pulsingMark then + setScale(v.pulse, v.scaleX, v.scaleY, v.scaleZ); + end; + end; + end; + + -- for outside IC + if self.LIC.isMouseActive then + if not self.isEntered then + self.LIC.foundInteractiveObject = nil; -- reset and search again + self.LIC.lastMouseXPos = InputBinding.mousePosXLast; + self.LIC.lastMouseYPos = InputBinding.mousePosYLast; + if self.LIC.lastMouseXPos ~= nil and self.LIC.lastMouseYPos ~= nil then + for k,v in pairs(self.LIC.interactiveObjects) do + if v.canOutside and v.mark ~= nil and (v.doNotShow == nil or v.doNotShow == false) then + local worldX,worldY,worldZ = getWorldTranslation(v.mark); + local x,y,z = project(worldX,worldY,worldZ); + if z <= 1 then + if self.LIC.lastMouseXPos > (x-v.size/2) and self.LIC.lastMouseXPos < (x+v.size/2) then + if self.LIC.lastMouseYPos > (y-v.size/2) and self.LIC.lastMouseYPos < (y+v.size/2) then v.isEntered = true; self:updateOpenStatus(k); self:renderOverlayAndInfo(v); @@ -677,26 +686,30 @@ function InteractiveControl:update(dt) -- OK end; end; end; - end; - - for k,v in pairs(self.LIC.interactiveObjects) do - if v.pulse ~= nil then - if v.pulsingMark then - if v.isEntered then - local sx,sy,sz = getScale(v.pulse); - sx = sx - (v.pulseScaleX/400) * dt; - sy = sy - (v.pulseScaleY/400) * dt; - sz = sz - (v.pulseScaleZ/400) * dt; - if sx < (v.scaleX - v.pulseScaleX) or sy < (v.scaleY - v.pulseScaleY) or sz < (v.scaleZ - v.pulseScaleZ) then - setScale(v.pulse, (v.scaleX + v.pulseScaleX),(v.scaleY + v.pulseScaleY),(v.scaleZ + v.pulseScaleZ)) + + if self.LIC.foundInteractiveObject ~= nil then + local foundItem = self.LIC.interactiveObjects[self.LIC.foundInteractiveObject]; + if foundItem.pulse ~= nil then + if foundItem.pulsingMark then + local sx,sy,sz = getScale(foundItem.pulse); + sx = sx - (foundItem.pulseScaleX/400) * dt; + sy = sy - (foundItem.pulseScaleY/400) * dt; + sz = sz - (foundItem.pulseScaleZ/400) * dt; + if sx < (foundItem.scaleX - foundItem.pulseScaleX) + or sy < (foundItem.scaleY - foundItem.pulseScaleY) + or sz < (foundItem.scaleZ - foundItem.pulseScaleZ) then + setScale(foundItem.pulse, + (foundItem.scaleX + foundItem.pulseScaleX), + (foundItem.scaleY + foundItem.pulseScaleY), + (foundItem.scaleZ + foundItem.pulseScaleZ)); else - setScale(v.pulse, sx, sy, sz); + setScale(foundItem.pulse, sx, sy, sz); end; - else - setScale(v.pulse, v.scaleX, v.scaleY, v.scaleZ); end; end; end; + else + self.LIC.foundInteractiveObject = nil; -- reset because we don't have IC end; end; end; @@ -721,24 +734,20 @@ end; function InteractiveControl:draw() -- OK - inside needs to be in draw for more accurate results if self.LIC.isMouseActive and self.isEntered then - for _,v in pairs(self.LIC.interactiveObjects) do - v.isEntered = false; - end + self.LIC.foundInteractiveObject = nil; -- reset and search again if self.LIC.lastMouseXPos ~= nil and self.LIC.lastMouseYPos ~= nil then for k,v in pairs(self.LIC.interactiveObjects) do - if v.mark ~= nil and self.LIC.foundInteractiveObject == nil and (v.doNotShow == nil or v.doNotShow == false) then + if v.mark ~= nil and not v.canOutside and (v.doNotShow == nil or v.doNotShow == false) then local worldX,worldY,worldZ = getWorldTranslation(v.mark); local x,y,z = project(worldX,worldY,worldZ); if z <= 1 then if self.LIC.lastMouseXPos > (x-v.size/2) and self.LIC.lastMouseXPos < (x+v.size/2) then if self.LIC.lastMouseYPos > (y-v.size/2) and self.LIC.lastMouseYPos < (y+v.size/2) then - if not v.canOutside then - v.isEntered = true; - self:updateOpenStatus(k); - self:renderOverlayAndInfo(v); - self.LIC.foundInteractiveObject = k; - break; - end; + v.isEntered = true; + self:updateOpenStatus(k); + self:renderOverlayAndInfo(v); + self.LIC.foundInteractiveObject = k; + break; end; end; end; @@ -791,6 +800,8 @@ function InteractiveControl:toggleICState(isOutside, forceStatus) -- OK if self.LIC.isMouseActive then if g_currentMission.player ~= nil then + local x,y,z = getRotation(g_currentMission.player.cameraNode); + g_currentMission.player.backupCamPosition = {x,y,z}; g_currentMission.player.walkingIsLocked = true; end; InputBinding.setShowMouseCursor(true); @@ -821,6 +832,8 @@ function InteractiveControl:toggleICState(isOutside, forceStatus) -- OK self.LIC.foundInteractiveObject = nil; if g_currentMission.player ~= nil then g_currentMission.player.walkingIsLocked = false; + g_currentMission.player.rotX = g_currentMission.player.backupCamPosition[1]; + g_currentMission.player.rotY = g_currentMission.player.backupCamPosition[2]; end; InputBinding.setShowMouseCursor(false); diff --git a/release/icSources/InteractiveControlEvent.lua b/release/icSources/InteractiveControlEvent.lua index aeeaf96..7f2381f 100644 --- a/release/icSources/InteractiveControlEvent.lua +++ b/release/icSources/InteractiveControlEvent.lua @@ -1,9 +1,15 @@ ---[[ -I made some quick changes here to eliminate a MP error when I did a quick check. -I have not done a check in MP with more than one player yet. I will do this tomorrow but I wanted to make sure you were happy with the dirrection of the script :-) - --- OK thats OK -]]-- +-- +-- Part of InteractiveControl script. +-- This file contains InteractiveControlEvent class for emitting network events +-- for IC +-- +-- Author: Martin Fabík (LoogleCZ) +-- Thanks Adam Maršík for network debugging +-- For IC version: 4.1.0 +-- +-- Last edit: 2018-08-11 16:30:00 +-- Free for non-comerecial usage +-- InteractiveControlEvent = {}; InteractiveControlEvent_mt = Class(InteractiveControlEvent, Event); @@ -37,10 +43,9 @@ function InteractiveControlEvent:writeStream(streamId, connection) end; function InteractiveControlEvent:run(connection) - if self.object ~= nil then - self.object:actionOnObject(self.interactiveControlID, self.ICIsOpen, true); - if not connection:getIsServer() then - g_server:broadcastEvent(InteractiveControlEvent:new(self.object, self.interactiveControlID, self.ICIsOpen), nil, connection, self.object); - end; + if not connection:getIsServer() then + g_server:broadcastEvent(self, false, connection, self.object); end; + + self.object:actionOnObject(self.interactiveControlID, self.ICIsOpen, true); end; diff --git a/release/icSources/actionFunction.lua b/release/icSources/actionFunction.lua index d5ad709..a572087 100644 --- a/release/icSources/actionFunction.lua +++ b/release/icSources/actionFunction.lua @@ -4,10 +4,10 @@ -- -- Author: Martin Fabík (LoogleCZ) -- Author of some events: Andy (GtX) --- For IC version: 4.0.4 +-- For IC version: 4.1.0 -- You can find whole list of supported events in documentation -- --- Last edit: 2018-01-25 12:14:00 +-- Last edit: 2018-08-11 16:30:00 -- Free for non-comerecial usage -- @@ -16,6 +16,7 @@ -- All synch attributes in monitors should be set to TRUE. -- All synch attributes in visControl should be set to TRUE. -- All synch attributes in multi buttons should be set to FALSE. +-- Recomended values of synch attribute for buttons can be found on GitHub -- -- @@ -146,7 +147,7 @@ end; local fillOnImplements = function(self, implements, id) for _, implement in pairs(implements) do if implement.object ~= nil then - if implement.object.isFilling ~= nil and implement.object.setIsFilling ~= nil then + if implement.object.isFilling ~= nil and implement.object.setIsFilling ~= nil and implement.object.fillTriggers ~= nil then for _, trigger in ipairs(implement.object.fillTriggers) do if trigger:getIsActivatable(implement.object) then implement.object:setIsFilling(self.LIC.interactiveObjects[id].isOpen); @@ -163,7 +164,7 @@ local fillOnImplementsStatus = function(self, implements, id) if self:getIsActive() then for _, implement in pairs(implements) do if implement.object ~= nil then - if implement.object.isFilling ~= nil and implement.object.setIsFilling ~= nil then + if implement.object.isFilling ~= nil and implement.object.setIsFilling ~= nil and implement.object.fillTriggers ~= nil then for _, trigger in ipairs(implement.object.fillTriggers) do status = (implement.object.isFilling and trigger:getIsActivatable(implement.object)) or status; end; @@ -180,7 +181,7 @@ end; local turnOnOnImplements = function(self, implements, id) for _,implement in pairs(implements) do if implement.object ~= nil then - if implement.object.setIsTurnedOn ~= nil and implement.object:getIsTurnedOnAllowed() then + if implement.object.setIsTurnedOn ~= nil and implement.object.getIsTurnedOnAllowed ~= nil and implement.object:getIsTurnedOnAllowed() then implement.object:setIsTurnedOn(self.LIC.interactiveObjects[id].isOpen); end; end; @@ -191,7 +192,7 @@ local turnOnOnImplementsStatus = function(self, implements, id) status = false; if self:getIsActive() then for _,implement in pairs(implements) do - if implement.object ~= nil then + if implement.object ~= nil and implement.object.getIsTurnedOn ~= nil then status = implement.object:getIsTurnedOn() or status; end; end; @@ -204,7 +205,7 @@ local lowerOnImplements = function(self, implements, id) if implement.object ~= nil then if implement.object.isPickupLowered ~= nil and implement.object.setPickupState ~= nil then implement.object:setPickupState(self.LIC.interactiveObjects[id].isOpen); - elseif implement.object.setFoldState ~= nil and implement.object.foldMiddleAnimTime then + elseif implement.object.setFoldState ~= nil and implement.object.getIsFoldAllowed ~= nil and implement.object.foldMiddleAnimTime then if implement.object:getIsFoldAllowed() then local dir = 1; if not self.LIC.interactiveObjects[id].isOpen then @@ -218,11 +219,8 @@ local lowerOnImplements = function(self, implements, id) end; end; end; - for _,attImpl in pairs(implement.object.attacherVehicle.attachedImplements) do - if attImpl.object == implement.object then - implement.object.attacherVehicle:setJointMoveDown(attImpl.jointDescIndex ,self.LIC.interactiveObjects[id].isOpen); - break; - end; + if implement.object.attacherVehicle ~= nil and implement.object.attacherVehicle.setJointMoveDown ~= nil and implement.jointDescIndex ~= nil then + implement.object.attacherVehicle:setJointMoveDown(implement.jointDescIndex ,self.LIC.interactiveObjects[id].isOpen); end; end; end; @@ -237,13 +235,8 @@ local lowerOnImplementsStatus = function(self, implements, id) status = implement.object.isPickupLowered or status; elseif implement.object.setFoldState ~= nil and implement.object.foldMiddleAnimTime ~= nil then status = (implement.object.turnOnFoldDirection == -1 and implement.object.foldAnimTime + 0.01 < implement.object.foldMiddleAnimTime) or (implement.object.turnOnFoldDirection == 1 and implement.object.foldAnimTime - 0.01 > implement.object.foldMiddleAnimTime) or status; - else - for _,attImpl in pairs(implement.object.attacherVehicle.attachedImplements) do - if attImpl.object == implement.object then - status = implement.object:isLowered() or status; - break; - end; - end; + elseif implement.object.isLowered ~= nil then + status = implement.object:isLowered() or status; end; end; end; @@ -254,7 +247,7 @@ end; local foldOnImplementsFinish = function(self, implements, id) for _, implement in pairs(implements) do if implement.object ~= nil and implement.object.getIsFoldAllowed ~= nil then - if implement.object:getIsFoldAllowed() then + if implement.object:getIsFoldAllowed() and implement.object.setFoldState ~= nil then local dir = 1; if not self.LIC.interactiveObjects[id].isOpen then dir = -1; @@ -281,7 +274,7 @@ end; local foldOnImplementsMiddle = function(self, implements, id) for _, implement in pairs(implements) do if implement.object ~= nil and implement.object.getIsFoldAllowed ~= nil then - if implement.object:getIsFoldAllowed() then + if implement.object:getIsFoldAllowed() and implement.object.setFoldState ~= nil then local dir = 1; if not self.LIC.interactiveObjects[id].isOpen then dir = -1; @@ -413,7 +406,7 @@ function InteractiveControl:actionOnObject(id, isObjectOpen, noEventSend) elseif self.LIC.interactiveObjects[id].event == "steering.cruiseControl.speedUp" then if self.cruiseControl ~= nil then self:setCruiseControlMaxSpeed(self.cruiseControl.speed + 1); - if self.cruiseControl.speed ~= self.cruiseControl.speedSent then + if (noEventSend == nil or noEventSend == false) and self.cruiseControl.speed ~= self.cruiseControl.speedSent then if g_server ~= nil then g_server:broadcastEvent(SetCruiseControlSpeedEvent:new(self, self.cruiseControl.speed), nil, nil, self); else @@ -425,7 +418,7 @@ function InteractiveControl:actionOnObject(id, isObjectOpen, noEventSend) elseif self.LIC.interactiveObjects[id].event == "steering.cruiseControl.speedDown" then if self.cruiseControl ~= nil then self:setCruiseControlMaxSpeed(self.cruiseControl.speed - 1); - if self.cruiseControl.speed ~= self.cruiseControl.speedSent then + if (noEventSend == nil or noEventSend == false) and self.cruiseControl.speed ~= self.cruiseControl.speedSent then if g_server ~= nil then g_server:broadcastEvent(SetCruiseControlSpeedEvent:new(self, self.cruiseControl.speed), nil, nil, self); else @@ -442,6 +435,10 @@ function InteractiveControl:actionOnObject(id, isObjectOpen, noEventSend) self.lmt.toolState = 1; end; end; + elseif self.LIC.interactiveObjects[id].event == "steering.handBrake" then + if self.handBrakeState ~= nil then + self.handBrakeState = self.LIC.interactiveObjects[id].isOpen; + end; elseif self.LIC.interactiveObjects[id].event == "turnsignal.hazard" then if self.setTurnLightState ~= nil then if self.LIC.interactiveObjects[id].isOpen then @@ -765,9 +762,9 @@ function InteractiveControl:actionOnObject(id, isObjectOpen, noEventSend) end; for k,v in pairs(self.LIC.interactiveObjects[id].actionElements) do if v then - self:actionOnObject(k,not open); + self:actionOnObject(k, not open, noEventSend); else - self:actionOnObject(k,open); + self:actionOnObject(k, open , noEventSend); end; end; end; @@ -851,6 +848,10 @@ function InteractiveControl:updateOpenStatus(id) if self.lmt ~= nil then self.LIC.interactiveObjects[id].isOpen = self.lmt.toolState == 2; end; + elseif self.LIC.interactiveObjects[id].event == "steering.handBrake" then + if self.handBrakeState ~= nil then + self.LIC.interactiveObjects[id].isOpen = self.handBrakeState; + end; elseif self.LIC.interactiveObjects[id].event == "turnsignal.hazard" then if self.turnLightState ~= nil then self.LIC.interactiveObjects[id].isOpen = self.turnLightState == Lights.TURNLIGHT_HAZARD @@ -1030,6 +1031,12 @@ function InteractiveControl:checkButtonVisible(id) if self.LIC.interactiveObjects[id].objectType == InteractiveControl.OBJECT_TYPE_EVENT_BUTTON then if string.sub( self.LIC.interactiveObjects[id].event, 1, 5 ) == "l2gs." and type( self["l2gs" .. string.sub(self.LIC.interactiveObjects[id].event, 6)] ) ~= "function" then self.LIC.interactiveObjects[id].doNotShow = true; + elseif self.LIC.interactiveObjects[id].event == "lights.cablight" and self.setCablight == nil then + self.LIC.interactiveObjects[id].doNotShow = true; + elseif self.LIC.interactiveObjects[id].event == "steering.handBrake" and self.handBrakeState == nil then + self.LIC.interactiveObjects[id].doNotShow = true; + elseif self.LIC.interactiveObjects[id].event == "steering.lockMovingTools" and self.lmt == nil then + self.LIC.interactiveObjects[id].doNotShow = true; end; end; end;