[Site Home] [Forum Home] [Articles] [File DB] [News Archives]

Programming -> Commands


(View original topic)


KukuriChan - Feb-22-2004 server time
The "or" command is condition that includes two or more things. If either of the things are things are satisfied, then it will continue.

Hm... here's an example of an assignment I had to do earlier in the year. Hopefullly you'll get the idea. :

CODE

var strAnswer : string
var intPoint, intCount, intRoll : int
intRoll := 0
intCount := 0

put "Welcome to the simple dice game! First we roll the die to get a value." ..
put "After we "
put "will keeping on rolling until we get the same value or point " ..
put "again."
put ""



loop
   % Asks the user whether or not they want to play
   put "Do you want to play? Answer Y or N."
   get strAnswer
   if strAnswer = "Y" or strAnswer = "y" then
       % Roll to get first value
       delay (500)
       randomize
       randint (intPoint, 1, 6)
   else
       if strAnswer = "N" or strAnswer = "n" then
           put "Goodbye for now!"
           exit
       end if
   end if
   put "Point: ", intPoint
   % Die keeps on rolling
   % Outputs the value of each roll until point is reached again
   loop
       delay (500)
       randint (intRoll, 1, 6)
       put "Roll: ", intRoll
       exit when intRoll = intPoint
       intRoll := intPoint
       intCount := intCount + 1
   end loop
   % Outputs the number of rolls it took
   put "It took ", intCount, " time(s) to get the same value again."
   put ""
end loop


LittleD - Feb-10-2004 server time
Hey, im new here and new to turing, im taking it next year so i can learn about it. my oldest brother taught me some commands but i would like to know all of em and what they do, these are the ones i know:

put " "

var a : string (i only know string)

get a, b, c etc...

delay (time)

im know a bit about the draw command, like drawfillbox and stuff but im not sure how to make em how i want them, and stuff.

if a = " " then

end if

i would like to know about the "or" command so i could put something like: if a = "this" or "that" then, because that would help me a lot... if you guys wanna see what ive done then copy and paste this, i know its not long but oh well...




var a : string
var b : string
var c : string

put "You are in a desert, You can go any way you want, but only one will lead you out... Choose North(n) South (s) east (e) or west(w) and see if you survive..."
get a
if a = "n" then
put "After travelling for while, you see some water. You walk up to it and it is surrounded by Bottles of poison. Will you drink the water? (y or n)"
get b
if b = "y" then
put "You die!"
end if
if b = "n" then
put "You decide not to drink it. You go on some more only to be eaten by a wild snake, that means you die."
end if
end if
if a = "e" then
put "You have been travelling for some time now, you see some people with trucks driving across the desert. Will you ask for a ride? (y or n)"
get c
if c = "y" then
put "You hitch a ride and eventually make it into town where you get a job. After a year you get a promotion, and eventually you are making millions by the hour."
end if
if c = "n" then
put "You walk a little while more until you die of thirst."
end if
end if
if a = "s" then
put "You walk for a long time until you spontaniously combust"
end if
if a = "w" then
put "You begin to walk through the scorching heat. Your leags become tired and soon you can't walk. You begin to crawl because you know nobody is coming for you. You find some water and drink it. You die of hunger."
end if


(Showing 50 last posts, newest on top)