Merge remote-tracking branch 'origin/master'

This commit is contained in:
Nikita Kruglickiy 2023-05-22 19:06:32 +03:00
commit 9fb68001f1

View File

@ -1,26 +1,27 @@
--@name susp builder --@name suspension builder 0.1
--@author loh kakoito --@author loh kakoito
--@shared --@shared
if SERVER then if SERVER then
--Settings --Settings
local elasticConst = 15000 local elasticConst = 30000
local elasticDamp = 2000 local elasticDamp = 2000
local elasticAddLength = 0
local suspenionArm = 300
local baseMass = 700 local baseMass = 700
local wheelMass = 65 local wheelMass = 65
local suspenionArm = 300
local wheelModel = "models/sprops/trans/wheel_b/t_wheel30.mdl" 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() local base = chip():isWeldedTo()
base:setAngles(Angle(0,90,0)) base:setAngles(Angle(0,90,0))
base:setMass(baseMass) base:setMass(baseMass)
base:setNocollideAll(true)
local errorSound = "buttons/button10.wav" local errorSound = "buttons/button10.wav"
local hintSound = "buttons/button15.wav" local hintSound = "buttons/button15.wav"
@ -32,8 +33,8 @@ if SERVER then
net.writeEntity(base) net.writeEntity(base)
net.writeString(wheelModel) net.writeString(wheelModel)
net.send(Player) net.send(Player)
timer.create("plateCheck", 1, 0, CheckSteerPlates) init()
end end
end) end)
@ -47,41 +48,44 @@ if SERVER then
sounds.create(chip(), type == NOTIFY.HINT and hintSound or errorSound):play() sounds.create(chip(), type == NOTIFY.HINT and hintSound or errorSound):play()
end end
function CheckSteerPlates() function init()
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")
print("Arrows to move it") print("Arrows to move it")
print("Enter to send settings and spawn") print("Enter to send settings and spawn")
SendClientNotification('Arrows to move it', NOTIFY.HINT, 5) SendClientNotification('Arrows to move it', NOTIFY.HINT, 7)
else SendClientNotification('Enter to send settings and spawn', NOTIFY.HINT, 7)
print("Connect steering plates")
SendClientNotification('Connect steering plates', NOTIFY.ERROR, 5)
end
end end
local Positions = {} local Positions = {}
local Angles = {} local Angles = {}
local i = 0
function Build() function CreateProps()
for i = 1, 4 do i = i + 1
plates[i]:setAngles(base:getAngles()) 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)
local wheel = prop.create(Positions[i], Angles[i], wheelModel, true) steerPlate:setNocollideAll(true)
wheel:setMass(wheelMass) steerPlate:enableGravity(false)
wheel:enableSphere(true) local wheel = prop.create(Positions[i], Angles[i], wheelModel, true)
wheel:setMass(wheelMass)
constraint.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true) sounds.create(chip(), "buttons/button24.wav"):play()
constraint.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(-suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true) --wheel:enableSphere(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.rope(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(suspenionArm,-suspenionArm,0))), nil, nil, nil, nil, nil, true)
constraint.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,0))), elasticConst, elasticDamp, 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.elastic(i, wheel, base, nil, nil, Vector(0), base:worldToLocal(wheel:localToWorld(Vector(0,0,0))), elasticConst, 100, 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
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) 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") print("Use 'Make Spherical' tool on the wheels then dupe and delete the chip")
end end
net.receive("settings", function() net.receive("settings", function()
@ -101,6 +105,8 @@ if CLIENT and player() == owner() then
local Ctrl = 0 local Ctrl = 0
local Enter = 0 local Enter = 0
local Alternative = 0 local Alternative = 0
local KP_PLUS = 0
local KP_MINUS = 0
hook.add('inputPressed', 'KeyPress', function(key) hook.add('inputPressed', 'KeyPress', function(key)
if key == KEY.UPARROW then if key == KEY.UPARROW then
@ -115,6 +121,10 @@ if CLIENT and player() == owner() then
Ctrl = 1 Ctrl = 1
elseif key == KEY.ENTER then elseif key == KEY.ENTER then
Enter = 1 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 elseif key == KEY.SHIFT then
Alternative = 1 Alternative = 1
end end
@ -133,8 +143,11 @@ if CLIENT and player() == owner() then
Ctrl = 0 Ctrl = 0
elseif key == KEY.ENTER then elseif key == KEY.ENTER then
Enter = 0 Enter = 0
print(1)
SendSettings() SendSettings()
elseif key == KEY.KP_PLUS then
KP_PLUS = 0
elseif key == KEY.KP_MINUS then
KP_MINUS = 0
elseif key == KEY.SHIFT then elseif key == KEY.SHIFT then
Alternative = 0 Alternative = 0
end end