AnonymusHochgenuss

timetable

Jun 3rd, 2024 (edited)
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. tArgs = { ... }
  2.  
  3. -- Usage if a Command is wrong
  4. function usage()
  5.  print("usage:   timetable x name newname")
  6.  print("example: timetable 1 name newname")
  7. end
  8.  
  9. -- finding Train Station
  10. if peripheral.find("Create_Station") then
  11.  trainstation = peripheral.find("Create_Station")
  12. else
  13.  print("no trainstation found")
  14.  return
  15. end
  16.  
  17. -- checking if enough arguments are present
  18. if #tArgs <= 2 then
  19.  if #tArgs == 1 then
  20.   if tArgs[1] == "get" then
  21.   else
  22.    usage()
  23.    return
  24.   end
  25.  else
  26.   usage()
  27.   return
  28.  end
  29. end
  30.  
  31. -- setting variables to get the chaos sorted
  32. entry = tonumber(tArgs[1])
  33. object = tArgs[2]
  34. new = tArgs[3]
  35.  
  36. -- checking the arguments and respond if right
  37. -- getting train schedule
  38. schedule = trainstation.getSchedule()
  39. if object == "name" then
  40.  print("actual name: "..schedule.entries[entry].instruction.data.text)
  41.  schedule.entries[entry].instruction.data.text = new
  42.  trainstation.setSchedule(schedule)
  43.  print("New Station Name of Entry "..entry.." is "..new)
  44. elseif tArgs[1] == "get" then
  45.  print(#schedule.entries.." Entries Found")
  46.  entrys=#schedule.entries
  47.  for i=1,entrys do
  48.   print("Station "..i..": "..schedule.entries[i].instruction.data.text)
  49.  end
  50. else
  51.  print(entry)
  52.  print(object)
  53.  print(new)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment