[READ-ONLY] Mirror of https://github.com/thoda-dev/du-elevator. a generic elevator script for Dual Universe
0

Configure Feed

Select the types of activity you want to include in your feed.

v1.3.3 source + doc

Thomas (Aug 11, 2023, 8:25 PM +0200) e375fb9a 55e2a265

+19 -6
+4
README.MD
··· 95 95 | ElevatorData.longitudinalSpeed | number | the absolute Longitudinal speed of the elevator in m/s. | 96 96 | ElevatorData.coreAltitude | number | the altitude from sea level returned by the core in meters. (warning: this altitude in space when far from planets is 0) | 97 97 | ElevatorData.altitude | number | computed altitude from the distance between the construct and the sea level of the closest planet. (not 0 when in space) | 98 + | ElevatorData.atmosphereDistance | number | computed distance from the construct to the atmosphere of the closest planet | 99 + | ElevatorData.atmosphereAltitude | number | computed altitude of the atmosphere of the closest planet | 100 + | ElevatorData.atmoMaxSpeed | number | the maximum speed of the elevator in m/s when in atmosphere. (anti burn security) | 101 + | ElevatorData.currentMaxSpeed | number | the maximum speed of the elevator in m/s. (50km/h in space) | 98 102 | ElevatorData.planetData | table | Atlas Data of the closest planet. See atlas in game file for the structure (Game Directory\data\lua\atlas.lua) | 99 103 100 104 # Coming Soon
+15 -6
Source/Unit/OnStart.lua
··· 44 44 ElevatorData.longitudinalSpeed - number - the absolute Longitudinal speed of the elevator in m/s. 45 45 ElevatorData.coreAltitude - number - the altitude from sea level returned by the core in meters. (warning: this altitude in space when far from planets is 0) 46 46 ElevatorData.altitude - number - computed altitude from the distance between the construct and the sea level of the closest planet. (not 0 when in space) 47 + ElevatorData.atmosphereDistance - number - computed distance from the construct to the atmosphere of the closest planet 48 + ElevatorData.atmosphereAltitude - number - computed altitude of the atmosphere of the closest planet. 49 + ElevatorData.atmoMaxSpeed - number - the maximum speed of the elevator in m/s when in atmosphere. (anti burn security) 50 + ElevatorData.currentMaxSpeed - number - the maximum speed of the elevator in m/s. (50km/h in space) 47 51 ElevatorData.planetData - table - Atlas Data of the closest planet. See atlas in game file for the structure (Game Directory\data\lua\atlas.lua) 48 52 ]] 49 53 --locale for Translation ··· 230 234 --[[ 231 235 Version Management 232 236 ]] 233 - local version = "V 1.3.2" 237 + local version = "V 1.3.3" 234 238 local log_split = "=================================================" 235 239 --printing version in lua chat 236 240 system.print(log_split)local a=""local b=math.ceil((50-#version-2)/2)for c=1,b,1 do a=a..'='end;a=a.." "..version.." "for c=1,b,1 do a=a..'='end;system.print(a)system.print(log_split) ··· 276 280 if core == nil then 277 281 system.print('Core unit is not linked, exiting the script') 278 282 unit.exit() 283 + end 284 + if databank == nil then 285 + system.print('Databank is not linked') 279 286 end 280 287 281 288 --[[ ··· 329 336 if __DEBUG then system.print('BaseForward: ' .. json.encode(BaseForward)) end 330 337 if databank ~= nil then 331 338 if databank.hasKey('ConstructInitPos') and not force then 332 - BaseForward = Serializer:parse(databank.getStringValue('ConstructInitPos')) 339 + ConstructInitPos = Serializer:parse(databank.getStringValue('ConstructInitPos')) 340 + system.print("ConstructInitPos loaded from databank") 333 341 else 334 342 local toStore = Serializer:stringify(ConstructInitPos) 335 343 databank.setStringValue('ConstructInitPos', toStore) ··· 338 346 end 339 347 if databank.hasKey('BaseForward') and not force then 340 348 BaseForward = Serializer:parse(databank.getStringValue('BaseForward')) 349 + system.print("BaseForward loaded from databank") 341 350 else 342 351 local toStore = Serializer:stringify(BaseForward) 343 352 databank.setStringValue('BaseForward', toStore) ··· 628 637 ElevatorData.altitude = computePlanetSeaDistance(ElevatorData.planetData, constructWorldPosition) 629 638 ElevatorData.atmosphereDistance = ElevatorData.altitude - ElevatorData.atmosphereAltitude 630 639 local isInAtmosphere = ElevatorData.atmosphereDistance <= 0 631 - local targetIsInAtmosphere = TargetAltitude <= ElevatorData.atmosphereDistance 640 + local targetIsInAtmosphere = TargetAltitude <= ElevatorData.atmosphereAltitude 632 641 if maxBrake ~= nil then 633 642 local g = core.getGravityIntensity() 634 643 if ElevatorData.verticalSpeedSigned < 0 then ··· 647 656 local distance = TargetAltitude - ElevatorData.altitude 648 657 local targetDistance = utils.sign(distance) * (math.abs(distance)-brakeDistance) 649 658 distancePID:inject(targetDistance) 650 - if distancePID:get() > 0.25 or ElevatorData.verticalSpeedSigned < -MaxSpeed then --using a 0.25 meter deadband for stabilizing 659 + if distancePID:get() > 0.25 or ElevatorData.verticalSpeedSigned < -ElevatorData.currentMaxSpeed then --using a 0.25 meter deadband for stabilizing 651 660 Nav.axisCommandManager:setThrottleCommand(axisCommandId.vertical, 1) 652 661 ElevatorData.direction = 'up' 653 662 if ElevatorData.verticalSpeedSigned < 0 then 654 663 finalBrakeInput = 1 655 664 end 656 - elseif distancePID:get() < -0.25 or ElevatorData.verticalSpeedSigned > MaxSpeed then 665 + elseif distancePID:get() < -0.25 or ElevatorData.verticalSpeedSigned > ElevatorData.currentMaxSpeed then 657 666 Nav.axisCommandManager:setThrottleCommand(axisCommandId.vertical, -1) 658 667 ElevatorData.direction = 'down' 659 668 if ElevatorData.verticalSpeedSigned > 0 then ··· 666 675 667 676 --Brakes 668 677 if (math.abs(distance) < (ElevatorData.verticalSpeed*3.6) and canBrake) --speed control 669 - or (ElevatorData.verticalSpeed >= MaxSpeed) --anti burn speed 678 + or (ElevatorData.verticalSpeed >= ElevatorData.currentMaxSpeed) --anti burn speed 670 679 or ((math.abs(distancePID:get()) < .25) and canBrake) --altitude reached with 0.25m deadband 671 680 or ((brakeDistance > math.abs(distance)) and canBrake) --braking distance 672 681 or (finalBrakeInput == 0 and autoBrakeSpeed > 0 and Nav.axisCommandManager.throttle == 0 and constructVelocity:len() < autoBrakeSpeed)