Jump to content




Tornado Alert System

help lua utility

  • You cannot reply to this topic
12 replies to this topic

#1 Trackspeeder

  • Members
  • 10 posts

Posted 12 June 2014 - 10:20 PM

I got the tornado mod shortly after I downloaded CC and I wanted to create something that I can link them with.

I decided to go for a warning system that uses the redstone signal produced from the tornado sensor (part of the tornado mod) and when the computer picks up this signal it says that a tornado warning has been put in place and tells you what Minecraft time it was spotted at, then it tells you a safe place to take cover.

It is great for Role playing games on MC or use it in a mass tornado survival so people in the server have this utility on their
computers.

You must place the tornado sensor on the back of the computer, otherwise you will have to change the code where it gets all the redstone inputs from.

print("Tornado Warning System")
print("Starting up...")
sleep(1)
print("Loading Sensor")
sleep(1)
print("Tornado Warning System is Active")
shell.run('clear')
repeat
redstone.getInput ('back')
print("No tornado warnings in this area")
sleep(0.5)
shell.run('clear')
until redstone.getInput ('back',true)
shell.run('clear')
print("A TORNADO WARNING HAS BEEN PUT IN PLACE")
sleep(1)
local time = os.time()
local formattedTime = textutils.formatTime(time, false)
print("AT" .. formattedTime) print("A TORNADO WARNING WAS PUT IN PLACE")
sleep(1)
print("ALL RESIDENTS SHOULD TAKE COVER")
sleep(1)
print("TAKE COVER IN A TORNADO SHELTER")
sleep(1)
print("IF NO SHELTER IS AVAILABLE")
print("TAKE COVER IN A CENTRAL ROOM IN A HOUSE")
print("THIS ROOM SHOULD BE ON THE LOWER FLOOR OF THE HOUSE")


#2 Sxw

  • Members
  • 306 posts
  • LocationWhenever, Wherever!

Posted 13 June 2014 - 02:49 AM

Any chance of integrating with real life data? Could of been useful this evening.

#3 Trackspeeder

  • Members
  • 10 posts

Posted 13 June 2014 - 09:01 PM

Not sure. That was really what made the idea for this code. I was trying to see if I could make a code by finding codes that would pull data from weather services that would show weather reports in MC or Tekkit on a monitor or normal computer screen.

#4 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 16 June 2014 - 10:57 AM

A small suggestion, Add a clock that shows all the time so that the time the tornado was spotted would be more useful

#5 Trackspeeder

  • Members
  • 10 posts

Posted 22 June 2014 - 02:01 PM

it does that is what this part of the code does:
local time = os.time()
local formattedTime = textutils.formatTime(time, false)
print("AT" .. formattedTime) print("A tornado WARNING WAS PUT IN PLACE")

#6 YoYoYonnY

  • Members
  • 49 posts

Posted 22 June 2014 - 08:27 PM

term.clear()
print("No tornado warnings in this area")
while not redstone.getInput ('back',true) do end
term.clear()
print("A TORNADO WARNING HAS BEEN PUT IN PLACE")
print("AT" .. textutils.formatTime(os.time(), false).."A TORNADO WARNING WAS PUT IN PLACE\nALL RESIDENTS SHOULD TAKE COVER\nTAKE COVER IN A TORNADO SHELTER\nIF NO SHELTER IS AVAILABLE\nTAKE COVER IN A CENTRAL ROOM IN A HOUSE\nTHIS ROOM SHOULD BE ON THE LOWER FLOOR OF THE HOUSE")


#7 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 24 June 2014 - 11:42 PM

View PostTrackspeeder, on 22 June 2014 - 02:01 PM, said:

it does that is what this part of the code does:
local time = os.time()
local formattedTime = textutils.formatTime(time, false)
print("AT" .. formattedTime) print("A tornado WARNING WAS PUT IN PLACE")
You misunderstood me.. that piece of code just prints the time when the tornado was spotted, I meant always drawing the current time

#8 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 25 June 2014 - 09:41 PM

Stick this BEFORE the part when the tornado is detected for a clock. (One that constantly runs instead of every time there is a tornado)
local time = os.time()
local formattedTime = textutils.formatTime(time,false)
term.setCursorPos( <x>,<y> )
term.write( time )
--or
term.write( "["..time.."]" )

Edited by cptdeath58, 25 June 2014 - 09:42 PM.


#9 lebalusch

  • Members
  • 49 posts

Posted 01 July 2014 - 08:25 PM

You could connect this up to the Howler Alarm And put a random number code for the sleep too for some more realism. Along with a rain maker. OR a command block to implement a storm with lightning.

Edited by lebalusch, 01 July 2014 - 08:26 PM.


#10 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 02 July 2014 - 09:45 PM

Well, the tornado mod does provide a siren that is redstone activated.

#11 josh4502

  • New Members
  • 1 posts

Posted 31 May 2016 - 11:23 PM

Easy paste bin download
pastebin get xL0ZSsd2 startup

#12 PossieTV

  • Members
  • 62 posts

Posted 21 June 2016 - 05:30 AM

A few suggestions:

A.) Indent your code- This won't change the function of the program but it will make you seem more experienced as this is a common practice amongst professional programmers
B.) Don't use shell.run('clear')- Again, this won't change the function of the program but will make you seem more experienced
C.) Add a variable at the beginning for the input side so people can change it easier.
D.) Put your code in a while true loop that way you don't have to reset the program after every tornado.
E.) Add support for monitors. For example, when a tornado warning is issued, the computer would put the message on all the monitors it is connected to.

Other than that, good program!

#13 Mumbai

  • Members
  • 62 posts

Posted 21 June 2016 - 03:22 PM

View PostPossieTV, on 21 June 2016 - 05:30 AM, said:

A few suggestions:

A.) Indent your code- This won't change the function of the program but it will make you seem more experienced as this is a common practice amongst professional programmers
B.) Don't use shell.run('clear')- Again, this won't change the function of the program but will make you seem more experienced
C.) Add a variable at the beginning for the input side so people can change it easier.
D.) Put your code in a while true loop that way you don't have to reset the program after every tornado.
E.) Add support for monitors. For example, when a tornado warning is issued, the computer would put the message on all the monitors it is connected to.

Other than that, good program!
Note: if you wish to clear, just use term.clear() to clear the screen





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users