Advertisement
AlertK

Untitled

Dec 27th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. xwk = 1 -- wspolrzedna kierunek (1-polnoc, 2-wschod, 3-poludnie 4-zachod)
  2. xwn = 0 -- wspolrzedna pozioma (polnoc-poludnie)
  3. xww = 0 -- wspolrzedna pozioma (zachod-wschod)
  4. xwp = 0 -- wspolrzedna pionowa (gora-dol)
  5.  
  6. function drukujpolozenie()
  7.   write("wspolrzedna kierunek: ")
  8.   write(xwk)
  9.   print()
  10.  
  11.   write("wspolrzedna pozioma1: ")
  12.   write(xwn)
  13.   print()
  14.  
  15.   write("wspolrzedna pozioma2: ")
  16.   write(xww)
  17.   print()
  18.  
  19.   write("wspolrzedna pionowa:  ")
  20.   write(xwp)
  21.   print()
  22.  
  23. end
  24.  
  25. function obrotwlewo()
  26.   if turtle.turnLeft() then
  27.     xwk=xwk-1
  28.     if xwk==0 then
  29.       xwk=4
  30.     end
  31.     return true
  32.     else
  33.     return false
  34.   end
  35. end
  36.  
  37. function obrotwprawo()
  38.   if turtle.turnRight() then
  39.     xwk=xwk+1
  40.     if xwk==5 then
  41.       xwk=1
  42.     end
  43.     return true
  44.     else
  45.     return false
  46.     end
  47. end
  48.  
  49. function krokdoprzodu()
  50.   if turtle.forward() then
  51.     if xwk==1 then
  52.       xwn=xwn-1
  53.     end
  54.     if xwk==2 then
  55.       xww=xww+1
  56.     end
  57.     if xwk==3 then
  58.       xwn=xwn+1
  59.     end
  60.     if xwk==4 then
  61.       xww=xww-1
  62.     end
  63.   return true
  64.   else return false
  65.   end
  66. end
  67.  
  68. function krokdotylu()
  69.   if turtle.back() then
  70.     if xwk==1 then
  71.       xwn=xwn+1
  72.     end
  73.     if xwk==2 then
  74.       xww=xww-1
  75.     end
  76.     if xwk==3 then
  77.       xwn=xwn-1
  78.     end
  79.     if xwk==4 then
  80.       xww=xww+1
  81.     end
  82.   return true
  83.   else return false
  84.   end
  85. end
  86.  
  87. print(krokdoprzodu())
  88. drukujpolozenie()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement