Stormworks: Build and Rescue

Stormworks: Build and Rescue

Navigation Map with Autopilot
SeaWeed  [developer] 18 Aug, 2024 @ 5:22am
2nd LUA Script (Unminified Code)
I=input
IGB=I.getBool
IGN=I.getNumber
O=output
OSB=O.setBool
OSN=O.setNumber
M=math
S=screen
SC=S.setColor
DL=S.drawLine
DR=S.drawRect
DRF=S.drawRectF
DTX=S.drawText

R = property.getNumber('Colour Scheme (Red Value)')
G = property.getNumber('Colour Scheme (Green Value)')
B = property.getNumber('Colour Scheme (Blue Value)')

UILe = 0
UIRe = 0
zoom = 25
zooms = 25

function inRect(x,y,rectX,rectY,rectW,rectH)
return x >= rectX and y >= rectY and x < rectX+rectW and y < rectY+rectH
end

function onTick()
if page == 1 then
touch = IGB(1)
else
touch = false
end
cntr = IGB(2)

w = IGN(1)
h = IGN(2)
touchPX = IGN(3)
touchPY = IGN(4)
page = IGN(8)
mapX = IGN(10)
mapY = IGN(11)
wpNo = IGN(12)

keypad = touch and inRect(touchPX,touchPY,1+UIL,1,7,7)
waypoint = touch and inRect(touchPX,touchPY,1+UIL,9,7,7)
del = touch and inRect(touchPX,touchPY,1+UIL,17,7,7)
clr = touch and inRect(touchPX,touchPY,1+UIL,25,7,7)
centre = touch and inRect(touchPX,touchPY,1+UIL,h-24,7,7)
hide = touch and inRect(touchPX,touchPY,1+UIL,h-16,7,7)
settings = touch and inRect(touchPX,touchPY,1+UIL,h-8,7,7)
zoomIn = touch and inRect(touchPX,touchPY,w-6+UIR,1,5,5)
zoomOut = touch and inRect(touchPX,touchPY,w-6+UIR,h-6,5,5)
zoomSet = touch and inRect(touchPX,touchPY,w-6+UIR,7,5,h-14)

if page == 1 then
if keypad then
keypadC = true
else
if keypadC then
showKeypad = true
end
keypadC = false
end

if wpNo > 0 then
if del then
delC = true
else
if delC then
delete = true
end
delC = false
end
end

if wpNo > 1 then
if clr then
clrC = true
else
if clrC then
clear = true
end
clrC = false
end
end

if not cntr then
if waypoint then
waypointC = true
else
if waypointC then
wp = true
end
waypointC = false
end

if centre then
centreC = true
else
if centreC then
cntrS = true
end
centreC = false
end
end

if settings then
settingsC = true
else
if settingsC then
showSettings = true
end
settingsC = false
end

if hide then
hideC = true
else
if hideC then
hideUI = true
end
hideC = false
end

if zoomIn then
if zoom > 0.1 then
zoom = zoom-0.2
zooms = zoom
end
end
if zoom < 0.1 then
zoom = 0.1
zooms = zoom
end

if zoomOut then
if zoom < 50 then
zoom = zoom+0.2
zooms = zoom
end
end
if zoom > 50 then
zoom = 50
zooms = zoom
end

if zoomSet then
adjZoom = true
else
if adjZoom then
zooms = (touchPY-7)*49.9/(h-15)+0.1
end
adjZoom = false
end
end


if page == 0 then
UILs = -9
UIRs = 7
else
UILs = 0
UIRs = 0
end
UILe = UILe+(UILs-UILe)*0.1
UIRe = UIRe+(UIRs-UIRe)*0.1
UIL = M.ceil(UILe-0.5)
UIR = M.ceil(UIRe-0.5)

zoomBar = (zoom-0.1)*(h-15)/49.9
zoom = zoom+(zooms-zoom)*0.1
zoomE = 0.1*(500^(1/49.9))^(zoom-0.1)

OSB(1,cntrS)
OSB(2,wp)
OSB(3,hideUI)
OSB(4,delete)
OSB(5,clear)
OSB(6,showSettings)
OSB(7,showKeypad)
cntrS = false
wp = false
hideUI = false
delete = false
clear = false
showSettings = false
showKeypad = false

OSN(1,zoomE)
OSN(2,UIL)
OSN(3,UIR)
end


function onDraw()
SC(R*0.04,G*0.04,B*0.04)
DRF(0+UIL,0,9,h)
DRF(w+UIR,0,-7,h)

if keypad then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,1,7,7)
if wpNo > 0 then
if del then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,17,7,7)
end
if wpNo > 1 then
if clr then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,25,7,7)
end
if not cntr then
if waypoint then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,9,7,7)
if centre then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,h-24,7,7)
end
if hide then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,h-16,7,7)
if settings then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(1+UIL,h-8,7,7)

if zoomIn then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(w-6+UIR,1,5,5)
if zoomOut then
SC(R*0.5,G*0.5,B*0.5)
else
SC(R*0.15,G*0.15,B*0.15)
end
DRF(w-6+UIR,h-6,5,5)

SC(R*0.15,G*0.15,B*0.15)
DRF(w-6+UIR,7,5,h-14)

if zoomSet then
SC(R*0.5,G*0.5,B*0.5)
DR(w-6+UIR,touchPY,4,0)
end
SC(200,200,200)
DRF(2+UIL,2,1,1)
DRF(2+UIL,4,1,1)
DRF(2+UIL,6,1,1)
DL(4+UIL,2,7+UIL,2)
DL(4+UIL,4,7+UIL,4)
DL(4+UIL,6,7+UIL,6)

if wpNo > 0 then
DL(2+UIL,18,7+UIL,23)
DL(2+UIL,22,7+UIL,17)
end

if wpNo > 1 then
DTX(2+UIL,26,"C")
end

if not cntr then
DR(3+UIL,10,2,2)
DRF(4+UIL,13,1,2)

DR(2+UIL,h-21,1,0)
DR(5+UIL,h-21,1,0)
DR(4+UIL,h-23,0,1)
DR(4+UIL,h-20,0,1)
end

DL(2+UIL,h-13,7+UIL,h-13)
DL(2+UIL,h-13,5+UIL,h-16)
DL(2+UIL,h-13,5+UIL,h-10)

DR(3+UIL,h-6,2,2)
DR(2+UIL,h-5,1,0)
DR(5+UIL,h-5,1,0)
DR(4+UIL,h-7,0,1)
DR(4+UIL,h-4,0,1)

DR(w-5+UIR,3,2,0)
DR(w-4+UIR,2,0,2)
DR(w-5+UIR,h-4,2,0)

DR(w-6+UIR,7+zoomBar,4,0)
end
Last edited by SeaWeed; 18 Aug, 2024 @ 8:33am