repl.it
@MinecraftMrGabe/

stormworks automatic rescue system

Lua

No description

fork
loading
Files
  • main.lua
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--[[
radio
frq = 0
1 = x
2 = y
3 = # of people
4 = criticality (higher if batt life is low or in arcic zone)
]]
--inputs
podx = 100 --podx relitive to cable x
pody = 100 --pody relitive to cable y
compass = 0.5 --compass output
connected = false -- either whether the mag-all is connected or whether the stretcher is occupied
altitude = 10 -- the mag all altitude minus the pod altitude
--program
math = require 'math'
degrees = math.atan2(podx,pody)
target = degrees/2
range = (podx^2+pody^2)^(1/2)
if range>100 then
print(compass-target) --replace this with output 1 for yaw. right is positive
print((range-50)/100)--try this speed and adjust after. this should be output 2 for speed
else
print(compass) --output 1 for yaw
if compass>-0.05 and compass<0.05 then
print(podx) -- output 3 for linear x speed with right being positive
print(pody) -- output 4 for linear z speed with forward being positive
print(altitude>0 and connected==false) -- output for the winch. retract should be the not of this 
end
end