From 305347a27c7635536b9d5f0af80ecfc1a3d3659c Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 3 Aug 2022 02:53:59 +0500 Subject: [PATCH] adds --- .../suspension_builder/suspension_builder.txt | 85 +++++++++++-------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/koptilnya/suspension_builder/suspension_builder.txt b/koptilnya/suspension_builder/suspension_builder.txt index 78d272c..762a134 100644 --- a/koptilnya/suspension_builder/suspension_builder.txt +++ b/koptilnya/suspension_builder/suspension_builder.txt @@ -1,26 +1,27 @@ ---@name susp builder +--@name suspension builder 0.1 --@author loh kakoito --@shared if SERVER then --Settings - local elasticConst = 15000 + local elasticConst = 30000 local elasticDamp = 2000 + local elasticAddLength = 0 + local suspenionArm = 300 + local baseMass = 700 local wheelMass = 65 - local suspenionArm = 300 + local wheelModel = "models/sprops/trans/wheel_b/t_wheel30.mdl" + local steerPlatesModel = "models/sprops/rectangles_thin/size_1_5/rect_6x12x1_5.mdl" + --######## - wire.adjustInputs( {'E1', 'E2', 'E3', 'E4'}, {'entity', 'entity', 'entity', 'entity'} ) - local e1 = wire.ports.E1 - local e2 = wire.ports.E2 - local e3 = wire.ports.E3 - local e4 = wire.ports.E4 local base = chip():isWeldedTo() base:setAngles(Angle(0,90,0)) base:setMass(baseMass) + base:setNocollideAll(true) local errorSound = "buttons/button10.wav" local hintSound = "buttons/button15.wav" @@ -32,8 +33,8 @@ if SERVER then net.writeEntity(base) net.writeString(wheelModel) net.send(Player) - - timer.create("plateCheck", 1, 0, CheckSteerPlates) + + init() end end) @@ -47,41 +48,44 @@ if SERVER then sounds.create(chip(), type == NOTIFY.HINT and hintSound or errorSound):play() end - function CheckSteerPlates() - e1 = wire.ports.E1 e2 = wire.ports.E2 e3 = wire.ports.E3 e4 = wire.ports.E4 - - if e1:isValid() and e2:isValid() and e3:isValid() and e4:isValid() then - plates = {e1, e2, e3, e4} - timer.stop("plateCheck") + function init() print("Arrows to move it") print("Enter to send settings and spawn") - SendClientNotification('Arrows to move it', NOTIFY.HINT, 5) - else - print("Connect steering plates") - SendClientNotification('Connect steering plates', NOTIFY.ERROR, 5) - end + SendClientNotification('Arrows to move it', NOTIFY.HINT, 7) + SendClientNotification('Enter to send settings and spawn', NOTIFY.HINT, 7) end local Positions = {} local Angles = {} + local i = 0 - function Build() - for i = 1, 4 do - plates[i]:setAngles(base:getAngles()) - local wheel = prop.create(Positions[i], Angles[i], wheelModel, true) - wheel:setMass(wheelMass) - wheel:enableSphere(true) - - constraint.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true) - constraint.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(-suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true) - constraint.ballsocketadv(wheel, plates[i], nil, nil, Vector(0), Vector(0), nil, nil, Vector(-180, -0.1, -0.1), Vector(180, 0.1, 0.1), Vector(0), true, true) - constraint.ballsocketadv(plates[i], wheel, nil, nil, Vector(0), Vector(0), nil, nil, Vector(-180, 0.1, 0.1), Vector(180, -0.1, -0.1), Vector(0), true, true) - constraint.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,0))), elasticConst, elasticDamp, nil, nil, true) - constraint.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,0))), elasticConst, 100, nil, nil, true) + function CreateProps() + i = i + 1 + local steerPlate = prop.create(base:localToWorld(Vector(i > 2 and -10 or 10, 100 + (i%2 == 0 and 10 or -10) , 40)), base:getAngles(), steerPlatesModel, true) + steerPlate:setNocollideAll(true) + steerPlate:enableGravity(false) + local wheel = prop.create(Positions[i], Angles[i], wheelModel, true) + wheel:setMass(wheelMass) + sounds.create(chip(), "buttons/button24.wav"):play() + --wheel:enableSphere(true) + + constraint.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true) + constraint.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(-suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true) + constraint.ballsocketadv(wheel, steerPlate, nil, nil, Vector(0), Vector(0), nil, nil, Vector(-180, -0.1, -0.1), Vector(180, 0.1, 0.1), Vector(0), true, true) + constraint.ballsocketadv(steerPlate, wheel, nil, nil, Vector(0), Vector(0), nil, nil, Vector(-180, 0.1, 0.1), Vector(180, -0.1, -0.1), Vector(0), true, true) + if elasticAddLength ~= 0 then + constraint.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,80))), elasticConst, elasticDamp, nil, nil, false) + constraint.setElasticLength(i, wheel, elasticAddLength + 80) + else + constraint.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,0))), elasticConst, elasticDamp, nil, nil, false) + --constraint.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,0))), elasticConst, 100, nil, nil, true) end + end + + function Build() + timer.create("create", 0.5, 4, CreateProps) SendClientNotification("Use 'Make Spherical' tool on the wheels then dupe and delete the chip", NOTIFY.HINT, 15) print("Use 'Make Spherical' tool on the wheels then dupe and delete the chip") - end net.receive("settings", function() @@ -101,6 +105,8 @@ if CLIENT and player() == owner() then local Ctrl = 0 local Enter = 0 local Alternative = 0 + local KP_PLUS = 0 + local KP_MINUS = 0 hook.add('inputPressed', 'KeyPress', function(key) if key == KEY.UPARROW then @@ -115,6 +121,10 @@ if CLIENT and player() == owner() then Ctrl = 1 elseif key == KEY.ENTER then Enter = 1 + elseif key == KEY.KP_PLUS then + KP_PLUS = 1 + elseif key == KEY.KP_MINUS then + KP_MINUS = 1 elseif key == KEY.SHIFT then Alternative = 1 end @@ -133,8 +143,11 @@ if CLIENT and player() == owner() then Ctrl = 0 elseif key == KEY.ENTER then Enter = 0 - print(1) SendSettings() + elseif key == KEY.KP_PLUS then + KP_PLUS = 0 + elseif key == KEY.KP_MINUS then + KP_MINUS = 0 elseif key == KEY.SHIFT then Alternative = 0 end