Pandafuchs

bahnhofFunctions V2

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