Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Monowheel Controller
- @inputs W A S D Space Shift Alt R Active
- @inputs BASE:entity BRAKEPLATE:entity WHEEL:entity DRIVERSEAT:entity PASSENGERSEAT:entity
- @outputs Lock Eject HydraulicLength HydraulicStrength HydraulicDamping
- @persist Direction Parked RollSpeed ROLL_FORCE SELF:entity OWNER:entity
- @trigger
- function park(Val:number){
- if (Val){
- Parked = 1
- HydraulicLength = 40
- HydraulicStrength = 100000
- HydraulicDamping = 2000
- BRAKEPLATE:setMass(500)
- #BRAKEPLATE:propNotSolid(0)#
- }
- else{
- Parked = 0
- HydraulicLength = 0
- HydraulicStrength = 1000
- HydraulicDamping = 100
- BRAKEPLATE:setMass(0.1)
- #BRAKEPLATE:propNotSolid(0)#
- }
- }
- if (first()|dupefinished()){
- #define variables here
- SELF = entity()
- OWNER = owner()
- Direction = 0
- WheelAngle = ang(0, 0, 0)
- ROLL_FORCE = 1000
- RollSpeed = 1
- WHEEL:propSetFriction(1000)
- park(1)
- runOnTick(1)
- }
- elseif (tickClk()){
- if (!Parked){
- Angle = ang(0,Direction,0)
- AppForce = (BASE:toLocal(Angle)*ang(250,250,250) - BASE:angVel()*25)*shiftL(ang(BASE:inertia()))
- BASE:applyAngForce(AppForce)
- if (W) {
- WHEEL:applyTorque(-vec(ROLL_FORCE * RollSpeed * WHEEL:mass(), 0, 0))
- }
- if (S) {
- WHEEL:applyTorque(vec(ROLL_FORCE * RollSpeed * WHEEL:mass(), 0, 0))
- }
- if (A) {
- Direction += 1.5
- }
- if (D) {
- Direction -= 1.5
- }
- }
- }
- elseif (~Alt & Alt){
- if (Lock) { Lock = 0
- DRIVERSEAT:hintDriver("Unlocked passenger seat", 2)
- PASSENGERSEAT:setColor(255, 255, 255) }
- else { Lock = 1
- DRIVERSEAT:hintDriver("Locked passenger seat", 2)
- PASSENGERSEAT:setColor(255, 0, 0)}
- }
- elseif (~R & R){
- Eject = R
- DRIVERSEAT:hintDriver("Ejected passenger", 2)
- }
- elseif (~Active){
- if (!Active){
- park(1)
- }
- else{
- park(0)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement