Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

CFS2013 - Room Lua Example

By: ChlorideCull on Jun 26th, 2013  |  syntax: None  |  size: 3.88 KB  |  hits: 70  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SetRoomInfo({
  2.         name = "The Twilight Zone",
  3.         load = function() return 0 end, --init currently done in look which is also called
  4.         look = function()
  5.                 return [[a weird room without walls that looks like it's situated in nowhere. You're freezing. There are a terminal with an eerie cyan glow and a chest made out of corrupted data here. You could probably even venture out in the void if you wanted to. You spot Fluttershy standing a few meters away.]]
  6.         end,
  7.         tick = function()
  8.                 return 0
  9.         end,
  10.         exits = function()
  11.                 return { { void, "devnull" } } --a table of tables that contains the exit name and the cell name
  12.         end,
  13.         objects = function()
  14.                 return {
  15.                         {
  16.                                 command = "chest",
  17.                                 use = function()
  18.                                         SetRoomVar("chest_inv", OpenContainer(GetRoomVar("chest_inv")))
  19.                                 end,
  20.                                 look = function()
  21.                                         return "a chest made out of broken sprites which is hot to the touch."
  22.                                 end
  23.                         }
  24.                         {
  25.                                 command = "terminal",
  26.                                 use = function()
  27.                                         print("You approach the terminal and read off the screen.")
  28.                                         print("")
  29.                                         print("CHLORIDES TERMINAL")
  30.                                         print("STUFF CAN GO WRONG HERE")
  31.                                         print("")
  32.                                         print("Available commands:")
  33.                                         print("(s)ave, (setr)oomvar, (getr)oomvar, (setg)lobalvar, (getg)lobalvar, (getpr)otectedvar, (setpo)nyattribute, (getpo)nyattribute, (a)wardcalories")
  34.                                         io.write("Chloride@DevTerminal /bin#")
  35.                                         io.flush()
  36.                                         local cmd = io.read()
  37.                                         if cmd == "s" or "save" then
  38.                                                 io.write("Savefile: ")
  39.                                                 io.flush()
  40.                                                 SaveGame(io.read("*l"))
  41.                                         elseif cmd == "setr" or "setroomvar" then
  42.                                                 io.write("Variable: ")
  43.                                                 io.flush()
  44.                                                 local one = io.read("*l")
  45.                                                 io.write("Value: ")
  46.                                                 io.flush()
  47.                                                 local two = io.read("*l")
  48.                                                 SetRoomVar(one, two)
  49.                                                 print([[Room variable ']] .. one .. [[' set to ']] .. two .. [['.]])
  50.                                         elseif cmd == "getr" or "getroomvar" then
  51.                                                 io.write("Variable: ")
  52.                                                 io.flush()
  53.                                                 local one = io.read("*l")
  54.                                                 print([[Room variable ']] .. one .. [[' is set to ']] .. GetRoomVar(one) .. [['.]])
  55.                                         elseif cmd == "setg" or "setglobalvar" then
  56.                                                 io.write("Variable: ")
  57.                                                 io.flush()
  58.                                                 local one = io.read("*l")
  59.                                                 io.write("Value: ")
  60.                                                 io.flush()
  61.                                                 local two = io.read("*l")
  62.                                                 SetGlobalVar(one, two)
  63.                                                 print([[Global variable ']] .. one .. [[' set to ']] .. two .. [['.]])
  64.                                         elseif cmd == "getg" or "getglobalvar" then
  65.                                                 io.write("Variable: ")
  66.                                                 io.flush()
  67.                                                 local one = io.read("*l")
  68.                                                 print([[Global variable ']] .. one .. [[' is set to ']] .. GetGlobalVar(one) .. [['.]])
  69.                                         elseif cmd == "getpr" or "getprotectedvar" then
  70.                                                 io.write("Variable: ")
  71.                                                 io.flush()
  72.                                                 local one = io.read("*l")
  73.                                                 print([[Protected variable ']] .. one .. [[' is set to ']] .. GetProtectedVar(one) .. [['.]])
  74.                                         elseif cmd == "setpo" or "setponyattribute" then
  75.                                                 print("Target: fltrshy")
  76.                                                 io.write("Attribute: ")
  77.                                                 io.flush()
  78.                                                 local one = io.read("*l")
  79.                                                 io.write("Value: ")
  80.                                                 io.flush()
  81.                                                 local two = io.read("*l")
  82.                                                 SetPonyAttribute("fltrshy", one, two)
  83.                                                 print([[Pony attribute ']] .. one .. [[' set to ']] .. two .. [['.]])
  84.                                         elseif cmd == "getpo" or "getponyattribute" then
  85.                                                 print("Target: fltrshy")
  86.                                                 io.write("Attribute: ")
  87.                                                 io.flush()
  88.                                                 local one = io.read("*l")
  89.                                                 print([[Pony attribute ']] .. one .. [[' is set to ']] .. GetPonyAttribute("fltrshy", one) .. [['.]])
  90.                                         elseif cmd == "a" or "awardcalories" then
  91.                                                 print("Target: fltrshy")
  92.                                                 io.write("Number: ")
  93.                                                 io.flush()
  94.                                                 local one = io.read("*l")
  95.                                                 AwardCalories("fltrshy", one)
  96.                                         end
  97.                                         print("You leave the terminal.")
  98.                                 end,
  99.                                 look = function()
  100.                                         return "a old terminal with an eerie cyan glow, kinda like Rainbow Dash's coat. There's text on the screen."
  101.                                 end
  102.                         }
  103.                 }
  104.         end,
  105.         ponies = function()
  106.                 return { "fltrshy" }
  107.         end
  108.  
  109. })