From 59a655e4c7130104922a7983749f586a2a613920 Mon Sep 17 00:00:00 2001 From: silvernode Date: Sun, 18 Mar 2018 05:24:17 -0700 Subject: [PATCH] basic navigation, add unlimited string in input --- lib/io.jl | 2 +- lib/s1Stations.jl | 7 ++++ src/spacer.jl | 93 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 lib/s1Stations.jl diff --git a/lib/io.jl b/lib/io.jl index 987d764..07c860f 100644 --- a/lib/io.jl +++ b/lib/io.jl @@ -1,4 +1,4 @@ -function input(prompt::AbstractString="") +function input(prompt::AbstractString="",x...) print(prompt) return chomp(readline()) end diff --git a/lib/s1Stations.jl b/lib/s1Stations.jl new file mode 100644 index 0000000..f6fdf10 --- /dev/null +++ b/lib/s1Stations.jl @@ -0,0 +1,7 @@ +include("../lib/io.jl") +global function mirStation() + + println("You havearrived in Mir") + + return +end \ No newline at end of file diff --git a/src/spacer.jl b/src/spacer.jl index 2694b85..8e3dcea 100755 --- a/src/spacer.jl +++ b/src/spacer.jl @@ -1,43 +1,92 @@ #!/usr/bin/julia using TerminalMenus include("../lib/io.jl") +include("../lib/s1Stations.jl") -function sectors() - local sector1 = ["Moon Plaza", "Hoover", "Mir", "Aloomis", "Caldari"] - local defMessage = "You have not moved" - return sector1 -end -function stations(stationName) + +function sec1Stations(stationName) if stationName == "Mir" - println("You arrive at Mir") + #println("You arrive at ", stationName) + mirStation() elseif stationName == "Hoover" - println("You have arrived at Hoover") + println("You have arrived at ", stationName) elseif stationName == "Aloomis" - println("You have arrived in Aloonis") + println("You have arrived in ", stationName) elseif stationName == "Caldari" - println("You have arrived in Caldari") + println("You have arrived in ", stationName) elseif stationName == "Moon Plaza" - println("You have arrived at Moon Plaza") + println("You have arrived at ", stationName) + end + + return stationName +end + + +function sec2Stations(stationName) + if stationName == "Eejypt" + println("You have arrived in ", stationName) + + elseif stationName == "Eden" + println("You have arrived in ", stationName) + end + +end + +function sectors(number) + + local sector1 = ["Moon Plaza", "Hoover", "Mir", "Aloomis", "Caldari"] + local sector2 = ["Eejypt", "Eden",] + + if number == "1" + sec1StatMenu = RadioMenu(sector1, pagesize=10) + + + local choice = request("Warp to Station: ", sec1StatMenu) + + if choice != -1 + sec1Stations(sector1[choice]) + + else + println("Cancelled") + end + + + elseif number == "2" + + sec2StatMenu = RadioMenu(sector2, pagesize=10) + + local choice2 = request("Warp to station: ", sec2StatMenu) + + if choice2 != -1 + sec2Stations(sector2[choice2]) + + else + println("Cancelled") + end + + else + println("Sector ", number, " does not exist!") + end end +while true + println("1 : Sector 1") + println("2 : Sector 2") + println("q : Quit") + choice = input("Please choose a sector: ") -sector = sectors() -menu = RadioMenu(sector, pagesize=10) -println("You are in sector 1") -choice = request("Warp to Station: ", menu) - -if choice != -1 - stations(sector[choice]) - -else - println("Cancelled") -end + if choice == "q" + exit(0) + else + sectors(choice) + end +end \ No newline at end of file