Advertisement
Guest User

test

a guest
Apr 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. function generateGrid takes rect baseRect returns nothing
  2. local real y
  3. local real x
  4. local real x_step
  5. local real y_step
  6. local integer x_step_count
  7. local integer y_step_count
  8. local integer width
  9. local rect array grid_store
  10. local integer i
  11. local integer j
  12. local real minx
  13. local real miny
  14. local integer step
  15. local boolean switch
  16. set switch = FALSE
  17. set step = 132
  18. set minx = GetRectMinX(baseRect)
  19. set miny = GetRectMinY(baseRect)
  20. set y = GetRectHeightBJ(baseRect)
  21. set x = GetRectWidthBJ(baseRect)
  22. set x_step = x / step
  23. set y_step = y / step
  24. set x_step_count = R2I(x_step)
  25. set y_step_count = R2I(y_step)
  26. set width = x_step_count
  27. set i = 0
  28. set j = 0
  29. call DisplayTextToForce( GetPlayersAll(), R2S(x) + " " + R2S(y) )
  30. call DisplayTextToForce( GetPlayersAll(), I2S(x_step_count) + " " + I2S(y_step_count) )
  31. call DisplayTextToForce( GetPlayersAll(), R2S(x_step) + " " + R2S(y_step) )
  32. loop
  33. exitwhen i >= x_step_count
  34. loop
  35. //call DisplayTextToForce( GetPlayersAll(), I2S(i) + " " + I2S(j) )
  36. exitwhen j >= y_step_count
  37. set grid_store[i + width * j] = Rect(minx + i*step, miny + j*step, minx + (i+1)*step, miny + (j+1)*step)
  38. call CreateTextTagLocBJ( I2S(i + width * j), GetRectCenter(grid_store[i + width * j]), 0, 10, 100, 100, 100, 0 )
  39. if switch then
  40. call SetTerrainTypeBJ( GetRectCenter(grid_store[i + width * j]), 'Lgrd', -1, 1, 1 )
  41. set switch = FALSE
  42. else
  43. call SetTerrainTypeBJ( GetRectCenter(grid_store[i + width * j]), 'Lrok', -1, 1, 1 )
  44. set switch = TRUE
  45. endif
  46. set j = j + 1
  47. endloop
  48. set j = 0
  49. set i = i + 1
  50. if switch then
  51. set switch=FALSE
  52. else
  53. set switch=TRUE
  54. endif
  55. endloop
  56.  
  57. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement