75 lines
1.6 KiB
Lua
75 lines
1.6 KiB
Lua
-- @name Steering
|
|
-- @author DarkSupah
|
|
-- @server
|
|
-- @include ./steering_controller.txt
|
|
-- @include ./steer_axle.txt
|
|
-- @include ../libs/constants.txt
|
|
-- @include ../libs/table.txt
|
|
require("./steering_controller.txt")
|
|
require("./steer_axle.txt")
|
|
require("../libs/constants.txt")
|
|
require("../libs/table.txt")
|
|
|
|
local frontConfig = {
|
|
Camber = -5,
|
|
Caster = 5,
|
|
Ackermann = 1.1,
|
|
Lock = 50,
|
|
CorrectionOn = 0.8,
|
|
CorrectionOff = 0.2
|
|
}
|
|
local rearConfig = {
|
|
Camber = -5,
|
|
Caster = -5,
|
|
Ackermann = 1.2,
|
|
Lock = 5,
|
|
CorrectionOn = 0.8,
|
|
CorrectionOff = 0.2
|
|
}
|
|
|
|
-- Fucking slaves, get you ass back here
|
|
local _slaves = {
|
|
E1 = "entity",
|
|
E2 = "entity",
|
|
E3 = "entity",
|
|
E4 = "entity"
|
|
}
|
|
|
|
local _axles = {SteerAxle:new(frontConfig, wire.ports.E1, wire.ports.E2),
|
|
SteerAxle:new(rearConfig, wire.ports.E3, wire.ports.E4)}
|
|
|
|
local _inputs = {
|
|
Base = "entity",
|
|
Seat = "entity"
|
|
}
|
|
|
|
local _outputs = {
|
|
SteerNormalized = "number",
|
|
Driver = "entity"
|
|
}
|
|
|
|
local _allInputs = table.merge(_inputs, _slaves)
|
|
|
|
wire.adjustPorts(_allInputs, _outputs)
|
|
|
|
local steeringController = SteeringController:new(wire.ports.Base)
|
|
|
|
hook.add("PlayerEnteredVehicle", "onEnter", function(ply, veh)
|
|
if veh == steeringController.seat then
|
|
steeringController:setDriver(ply)
|
|
end
|
|
end)
|
|
|
|
hook.add("PlayerLeaveVehicle", "onLeave", function(ply, veh)
|
|
if veh == steeringController.seat then
|
|
steeringController:setDriver(NULL_ENTITY)
|
|
end
|
|
end)
|
|
|
|
hook.add("think", "update", function()
|
|
steeringController.seat = wire.ports.Seat
|
|
wire.ports.Driver = steeringController.driver
|
|
|
|
steeringController:update()
|
|
end)
|