Advertisement
Serpwidgets

ManiaPlugin-hex coords of cursor

Nov 9th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. #RequireContext CGameCtnEditorPluginScriptHandler
  2.  
  3. Text CreateManialink()
  4. {
  5. declare MLText =
  6. """
  7. <script><!--
  8. Void UpdateValues() {
  9. declare CursorX for Page = "";
  10. declare CursorY for Page = "";
  11. declare CursorZ for Page = "";
  12. declare CursorDirectionText for Page = "";
  13. declare LblCursorXValue <=> (Page.GetFirstChild("CursorXValue") as CGameManialinkLabel);
  14. declare LblCursorYValue <=> (Page.GetFirstChild("CursorYValue") as CGameManialinkLabel);
  15. declare LblCursorZValue <=> (Page.GetFirstChild("CursorZValue") as CGameManialinkLabel);
  16. declare LblCursorDirectionValue <=> (Page.GetFirstChild("CursorDirectionValue") as CGameManialinkLabel);
  17. LblCursorXValue.SetText("" ^ CursorX);
  18. LblCursorYValue.SetText("" ^ CursorY);
  19. LblCursorZValue.SetText("" ^ CursorZ);
  20. LblCursorDirectionValue.SetText(CursorDirectionText);
  21. }
  22. main () {
  23. declare BoxOffset = 0;
  24. while(True) {
  25. yield;
  26. UpdateValues();
  27. }
  28. }
  29. --></script>
  30. <frame>
  31. <quad id="CursorCoordBox" posn="140 35 -1" sizen="20 28" style="Bgs1" substyle="BgList" ScriptEvents="1"/>
  32. <label id="CursorXLabel" text="HEX" posn="142 33"/>
  33. <label id="CursorXLabel" text="D" posn="142 28"/>
  34. <label id="CursorDirectionValue" text="XXX" posn="148 28"/>
  35. <label id="CursorXLabel" text="X" posn="142 23"/>
  36. <label id="CursorXValue" text="XXX" posn="148 23"/>
  37. <label id="CursorYLabel" text="Y" posn="142 18"/>
  38. <label id="CursorYValue" text="XXX" posn="148 18"/>
  39. <label id="CursorZLabel" text="Z" posn="142 13"/>
  40. <label id="CursorZValue" text="XXX" posn="148 13"/>
  41.  
  42. </frame>
  43. """;
  44. return MLText;
  45. }
  46.  
  47. //make lookup for hex conversion
  48. Text hexLookup(Integer v)
  49. {
  50. declare Text ret;
  51. switch(v){
  52. case 0: ret= "00";
  53. case 1: ret= "01";
  54. case 2: ret= "02";
  55. case 3: ret= "03";
  56. case 4: ret= "04";
  57. case 5: ret= "05";
  58. case 6: ret= "06";
  59. case 7: ret= "07";
  60. case 8: ret= "08";
  61. case 9: ret= "09";
  62. case 10: ret= "0A";
  63. case 11: ret= "0B";
  64. case 12: ret= "0C";
  65. case 13: ret= "0D";
  66. case 14: ret= "0E";
  67. case 15: ret= "0F";
  68. case 16: ret= "10";
  69. case 17: ret= "11";
  70. case 18: ret= "12";
  71. case 19: ret= "13";
  72. case 20: ret= "14";
  73. case 21: ret= "15";
  74. case 22: ret= "16";
  75. case 23: ret= "17";
  76. case 24: ret= "18";
  77. case 25: ret= "19";
  78. case 26: ret= "1A";
  79. case 27: ret= "1B";
  80. case 28: ret= "1C";
  81. case 29: ret= "1D";
  82. case 30: ret= "1E";
  83. case 31: ret= "1F";
  84. case 32: ret= "20";
  85. case 33: ret= "21";
  86. case 34: ret= "22";
  87. case 35: ret= "23";
  88. case 36: ret= "24";
  89. case 37: ret= "25";
  90. case 38: ret= "26";
  91. case 39: ret= "27";
  92. case 40: ret= "28";
  93. }
  94. return ret;
  95. }
  96.  
  97. /////////////////////////////////////
  98. // Main
  99. /////////////////////////////////////
  100. main()
  101. {
  102. log("CursorCoords.Script starts");
  103.  
  104. declare CursorAction for ManialinkPage = 0;
  105. declare CursorX for ManialinkPage = "";
  106. declare CursorY for ManialinkPage = "";
  107. declare CursorZ for ManialinkPage = "";
  108. declare CursorDirectionText for ManialinkPage = "";
  109.  
  110. ManialinkText = CreateManialink();
  111.  
  112. while(True) {
  113. yield;
  114. // update ManialinkPage variables
  115. CursorX = hexLookup(CursorCoord[0]+1);
  116. CursorY = hexLookup(CursorCoord[1]);
  117. CursorZ = hexLookup(CursorCoord[2]+1);
  118. switch(CursorDir) {
  119. case ::CardinalDirections::North: CursorDirectionText = "00";
  120. case ::CardinalDirections::East: CursorDirectionText = "01";
  121. case ::CardinalDirections::South: CursorDirectionText = "02";
  122. case ::CardinalDirections::West: CursorDirectionText = "03";
  123. default: CursorDirectionText = "DirError";
  124. }
  125. }
  126. }
  127.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement