Pandafuchs

bahnhofFunctions

Sep 29th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. function executeTableFunction(input, funcname, ...)
  2. for k,v in pairs(input) do
  3. if (type(v[funcname]) == "function" ) then
  4. v[funcname](...)
  5. end
  6. end
  7. end
  8.  
  9. function getGleisFromPosX(posArray)
  10. if os.getComputerLabel() == "Bahnhof1" then
  11. if posArray["Y"] ~= 5.5 or posArray["Z"] ~= 7.5 then
  12. return "?"
  13. end
  14.  
  15. posX = posArray["X"]
  16. if posX == -4.5 then return 5
  17. elseif posX == -2.5 then return 4
  18. elseif posX == 1.5 then return 3
  19. elseif posX == 3.5 then return 2
  20. elseif posX == 7.5 then return 1
  21. else return "?"
  22. end
  23. elseif os.getComputerLabel() == "Bahnhof2" then
  24. if posArray["Y"] ~= 2.5 or posArray["X"] ~= 2.5 then
  25. return "?"
  26. end
  27.  
  28. posZ = posArray["Z"]
  29. if posZ == -2.5 then return 5
  30. elseif posZ == -0.5 then return 4
  31. elseif posZ == 5.5 then return 3
  32. elseif posZ == 7.5 then return 2
  33. elseif posZ == 13.5 then return 1
  34. else return "?"
  35. end
  36. end
  37.  
  38. end
  39.  
  40. function fillMyString(myString, fillCount)
  41. local length = string.len(myString)
  42.  
  43. if length > fillCount then
  44. myString = string.sub(myString, 0, fillCount) .. " "
  45. elseif length < fillCount then
  46. for i=length,fillCount do
  47. myString = myString .. " "
  48. end
  49. else
  50. myString = myString .. " "
  51. end
  52. return myString
  53. end
Advertisement
Add Comment
Please, Sign In to add comment