Slicksilver555

Blockland Client-Side Scripting Reference

Oct 10th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. Clientsided Server-Interaction Reference
  2.  
  3. ! Important notes will be presented like this
  4.  
  5. # Working code will be presented like this
  6.  
  7. ##
  8. Code blocks will be surrounded by two hash symbols
  9. ##
  10.  
  11. == Subject breaks will be presented like this
  12.  
  13.  
  14.  
  15. == ServerConnection
  16.  
  17. ! ServerConnection is a GameConnection object that is spawned when you join a server and it is the main focus
  18.  
  19. Useful methods:
  20. GameConnection::getControlObject() - returns the object you are controlling (usually player)
  21. GameConnection::getCount() - The amount of objects currently ghosted to your client
  22. GameConnection::getObject(index) - returns an object of the given index
  23.  
  24. ! Every object that is ghosted to your client is part of this group. Every brick. Every emitter. Everything.
  25.  
  26. Example (returns closest brick):
  27.  
  28. ##
  29. %myPosition = ServerConnection.getControlObject().getPosition();
  30. for(%i = 0; %i < ServerConnection.getCount(); %i++)
  31. {
  32. %object = ServerConnection.getObject(%i);
  33. if(%object.getClassname() $= "fxDTSBrick")
  34. {
  35. %position = %object.getPosition();
  36. %distance = vectorDist(%myPosition, %position);
  37. if(%distance < %closestDistance || %closestDistance $= "")
  38. {
  39. %closestDistance = %distance;
  40. %closestBrick = %object;
  41. }
  42. }
  43. }
  44. ##
  45.  
  46. ! Some objects such as players and projectiles may not have their positions retrieved client-side through getPosition. This is to prevent aimbots and such.
  47.  
  48. == Aiming
  49.  
  50. Aiming is usually done through two variables:
  51. $mvYaw - (-3.14159) through 3.14159
  52. $mvPitch - (-3.14159) through 3.14159
  53.  
  54. ! $mvYaw and $mvPitch accept radians not 0-360 degree euler rotational values. Use eulerToAxis and axisToEuler to convert.
  55. ! Entering values outside their domain will result in limitation.
  56.  
  57. Aiming code is given here, just provide position to aim at:
  58.  
  59. ##
  60. function aimAtPos(%pos)
  61. {
  62. %player = serverConnection.getControlObject();
  63. %fv = %player.getMuzzleVector(0);
  64. %x = getWord(%fv,0);
  65. %y = getWord(%fv,1);
  66. %vv = vectorNormalize(vectorSub(%pos,%player.getPosition()));
  67. %xx = getWord(%vv,0);
  68. %yy = getWord(%vv,1);
  69. $mvYaw = mATan(%xx,%yy)-mATan(%x,%y);
  70. $mvPitch = mATan(getWord(%fv,2),mSqrt(%x*%x+%y*%y))-mATan(getWord(%vv,2),mSqrt(%xx*%xx+%yy*%yy));
  71. }
  72. ##
  73.  
  74. ! It may be necessary to run this twice to ensure proper alignment.
  75.  
  76. == Movement / Interaction
  77.  
  78. Movement is done through functions or variables:
  79. $mvForwardAction - Boolean - Move forward
  80. $mvBackwardAction - Boolean - Move backward
  81. $mvRightAction - Boolean - Move right
  82. $mvLeftAction - Boolean - Move left
  83. $mvTriggerCount2 - Boolean - Jump
  84. $mvTriggerCount3 - Boolean - Crouch
  85. $mvTriggerCount4 - Boolean - Jet
  86. $mvTriggerCount0 - Boolean - Fire main weapon
  87. $mvTriggerCount1 - Boolean - Fire alt. weapon
  88. moveForward() - Boolean - Move fowrad
  89. moveBackward() - Boolean - Move backward
  90. moveLeft() - Boolean - Move left
  91. moveRight() - Boolean - Move right
  92. Jump() - Boolean - Jump
  93. Crouch - Boolean - Crouch
  94. Jet() - Boolean - Jet
  95. mouseFire() - Boolean - Fire main weapon
  96. altTrigger() - Boolean - Fire alt. weapon
  97.  
  98. ! All of these are toggleable boolean values, the following are valid:
  99. ## $mvForwardAction = true;
  100. ## $mvForwardAction = false;
  101. ## Jet(1);
  102. ## Jet(0);
  103.  
  104. == Building
  105.  
  106. Building can be done through server commands or clientside functions. I perfer server commands:
  107. shiftBrick - Vector (3-arguments) - Shift the brick normally
  108. superShiftBrick - Vector (3-arguments) - Super Shift the brick
  109. rotateBrick - Integer - Amount of times to rotate the brick (negative for rotating left)
  110. plantBrick - Void - Plant the brick. No argument required.
  111.  
  112.  
  113. ! The following can be used through this method:
  114. commandToServer('serverCommandHere', "arguments", "go", "here");
  115.  
  116. ! serverCmdShiftBrick and serverCmdSuperShiftBrick both use 3 arguments, like so:
  117. # commandToServer('shiftBrick', 0, 0, 3);
  118.  
  119. == Credits / Contact Me
  120. Slicksilver555
  121. Centhra Game Design, etc.
  122.  
  123. If you believe I have forgotten anything or improperly stated something, or any reason at all you want to contact me, please use the above method. Other methods such as Private Messages are not guaranteed to reach me.
Advertisement
Add Comment
Please, Sign In to add comment