iMagicBae

GS2 Documentation

Apr 24th, 2020
1,917
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. 1. Introduction
  3.  
  4. 1.1. Why scripts
  5.  
  6. Scripts bring life into objects and make it easy to
  7. customize the game. Instead of just placing a stone
  8. into your world, you can make it so that the stone
  9. can be lifted or kicked. Instead of being limited to
  10. some fixed player movement you can rescript it
  11. to let the player jump, strafe and duck. To let the
  12. player inspect and organize his/her items you can
  13. create some dialogs and display those by script,
  14. e.g. when the player presses a special key.
  15.  
  16. In Graal the scripting is done in 'Graal Script',
  17. it's looking like Java/C++, but brings some
  18. additional features for making things easier
  19. for game creators, while on the other hand
  20. running in a sandbox and limiting access to
  21. game-related stuff only.
  22.  
  23. Graal Script is almost fully compatible to
  24. the 'old' Graal script used in Graal v1.0 - 3.0,
  25. and is partially compatible to Torque script.
  26.  
  27. 1.2. NPCs and 'weapons'
  28.  
  29. There are generally two types of objects in Graal
  30. which have scripts: The first type are the
  31. non-player-characters (NPCs). The name 'NPC' is
  32. actually used for all visible objects in the game:
  33. monsters, stones, bushes, houses, ships, plants etc.
  34. Scripts for npcs are most of the time containing
  35. code for moving the npc or for reacting to
  36. activities of the player, e.g. giving money to
  37. the player when he grabs the npc.
  38. The other type of script-holding objects are the
  39. 'weapons'. Those are items in the inventory of
  40. the player, not necessary being weapons. Most of
  41. the time they are actually just scripts which
  42. control the movement of the player, display weapon
  43. graphics, or display menus.
  44.  
  45. So there are objects in the game which have
  46. their own script, and players which have a set
  47. of scripts in their invisible backpack.
  48.  
  49. 1.3. Server-side and client-side
  50.  
  51. Graal is an online game, and there are differences
  52. to standard scripting in offline games.
  53. In offline programs you have access to everything,
  54. anytime. In online games everything is divided
  55. into two parts: the server-side which controls
  56. most things in the game, and the client-side which
  57. displays the game to the player.
  58. Since the client only displays things, it is not
  59. possible to cheat by hacking the client. On client-side
  60. you mainly have code for displaying special effects,
  61. for displaying the GUI (windows, status bars, item menus),
  62. playing sound effects and music. Also the player
  63. movement is done on client-side.
  64. On the server-side scripts are used to do the more
  65. secure parts of the game engine are implemented,
  66. and things that are the same for all players -
  67. npcs are added, moved, npcs interact with players,
  68. the stats of the players are calculated, the
  69. communication between players is handled.
  70.  
  71. All scripts for npcs and weapons can contain
  72. server-side code and client-side code. The server-side
  73. code is executed directly on the server, the
  74. client-side code is sent to the client when he
  75. logins and executed separately for each player on
  76. their own computer. Usually the two parts of the script
  77. are divided by line that only contains "//#CLIENTSIDE",
  78. like this:
  79.  
  80. // Server-side part which is setting the image
  81. // of the npc when it is created
  82. function onCreated() {
  83.   setimg("door.png");
  84. }
  85.  
  86. //#CLIENTSIDE
  87.  
  88. // Here follows the client-side part,
  89. // which plays a sound effect when the player
  90. // touchs the npc
  91. function onPlayerTouchsme() {
  92.   play("chest.wav");
  93. }
  94.  
  95.  
  96. 1.4. Events
  97.  
  98. In general scripts are made for reacting to
  99. events - when the npc is created then the script
  100. initializes the attributes of the npc,
  101. when the player says something then the npc is
  102. moving to the player, when the player grabs the
  103. npc then the npc is giving the player some money etc.
  104. So the script is basicly a collection of actions
  105. that are done when special events are happening.
  106. Events can e.g. be the "created" event when the npc
  107. is created, the "playertouchsme" event when the
  108. player touchs the npc, or the "playerchats" event
  109. when the player says something. To write code reacts
  110. to one of those event, you define an event
  111. function like this:
  112.  
  113. function onEVENTNAME() {
  114.   // actions
  115. }
  116.  
  117. When the event is happening, then Graal executes
  118. that scripting function and all commands you
  119. have added there.
  120. Sometimes the event gives some parameters to the
  121. event function, then change your function to:
  122.  
  123. function onEVENTNAME(parameter1, paramater2, ...) {
  124.   // actions
  125. }
  126.  
  127. By accessing 'parameter1' etc. (you can name
  128. them differently) you can react to the event more
  129. exactly.
  130.  
  131. Instead of reacting to events, the npcs and
  132. weapons can also invoke new events. That way
  133. you can let other npcs doing things. You also
  134. need that if you want to coninuously doing things -
  135. use timeout event for that.
  136.  
  137. function onCreated() {
  138.   timeout = 1;
  139. }
  140.  
  141. function onTimeout() {
  142.   // actions
  143.   timeout = 1;
  144. }
  145.  
  146. In the onCreated event function the script is
  147. setting the timer to 1 second. When that second is
  148. over, then the "timeout" event is invoked on the
  149. npc and the onTimeout event function is executed.
  150. Because it is setting the timeout to 1 second
  151. again, the onTimeout even will occur again after
  152. one second, and so on.
  153.  
  154.  
  155.  
  156. Compatibility note:
  157. In older Graal scripts you will also find the
  158. deprecated way of receiving events:
  159.  
  160. if (EVENTNAME) {
  161.   // actions
  162. }
  163.  
  164. That is an if-command outside of any brackets. If
  165. Graal sees that you use such an if-command, then
  166. it will execute the whole script so that the actions
  167. you have written inside the if-command will be
  168. executed too.
  169.  
  170.  
  171. 2. Basics
  172.  
  173. 2.1. Accessing variables
  174.  
  175. Graal Script variables are 'variant', that means they are objects
  176. that hold values of different types.
  177. When you assign a value to the variable then it automatically
  178. switches to the right type:
  179.  
  180. Numeric (floating point):
  181.   var = 1;
  182. String:
  183.   var = "hello";
  184. Object link:
  185.   var = player;
  186. Array (list of objects):
  187.   var = {1,2,3};
  188.  
  189. You can check the current type with the
  190. type()-function - obj.type() returns
  191. 0,1,2,3 for numeric, string, object or array.
  192.  
  193. 2.2. Operators
  194.  
  195. Addition                  a + b
  196. Substraction              a - b
  197. Mulitplication            a * b
  198. Division                  a / b
  199. Modulus                   a % b
  200. Power                     a ^ b
  201. String Concationation     a @ b
  202. Bool-And                  a && b
  203. Bool-Or                   a || b
  204. Bool-Not                  !a
  205. Negative                  -a
  206. Equal                     a == b
  207. Not-Equal                 a != b
  208. Less                      a < b
  209. Greater                   a > b
  210. Less-Equal                a <= b,  a =< b
  211. Greater-Equal             a >= b,  a => b
  212. In-Range                  a in <b,c>, a in |b,c>, a in <b,c|, a in |b,c|
  213. In-Array                  a in {b,c,...}, {a,b,...} in {c,d,...}
  214. Bitwise-Or                a | b
  215. Bitwise-And               a & b
  216. Bitwise-Shift left        a << b
  217. Bitwise-Shift right       a >> b
  218. Bitwise-Invert            ~a
  219. Bitwise-Xor               a xor b (operator ^ already used for power)
  220. Array-Constructor         {a,b,...}
  221. Empty Array               new [count]
  222. Array Member              a[index]
  223. Function call             a(), a(b,c,...)
  224. Object Attribute          a.b, a.(b)
  225. Post Increment            a++
  226. Post Decrement            a--
  227. Pre Increment             ++a
  228. Pre Decrement             --a
  229. Old String Function       #a
  230. Conditional               a? b : c
  231. Assignment                a = b, a := b
  232. Additive Assignment       a += b
  233. Substractive Assignment   a -= b
  234. Multiplicative Assignment a *= b
  235. Division Assignment       a /= b
  236. Modulus Assignment        a %= b
  237. Power Assignment          a ^= b
  238. Bitwise-Or Assignment     a |= b
  239. Bitwise-And Assignment    a &= b
  240. Shift Left Assignment     a <<= b
  241. Shift Right Assignment    a >>= b
  242. String Append             a @= b
  243.  
  244. 2.3. Standard object functions
  245.  
  246. For a complete list of functions and attributes of objects
  247. see docu_graalscriptfunctions.txt. The base type of all
  248. objects is "TGraalVar". You can also get the latest list by
  249. calling the executale with "-listscriptfunctions" as
  250. command-line parameter.
  251. Here only of the built-in functions:
  252.  
  253. obj.type()  - gets the type of the var (float 0, string 1, object 2, array 3)
  254. obj.length() - string length
  255. obj.trim()
  256. obj.tokenize([delimiters])
  257. obj.charat(pos)
  258. obj.pos(substring)
  259. obj.starts(string)
  260. obj.ends(string)
  261. obj.substring(index[,length])
  262. obj.size() - array length
  263. obj.subarray(index[,length])
  264. obj.addarray(obj2)
  265. obj.insertarray(index,obj2)
  266. obj.index(obj2) - position of obj2 in the array
  267. obj.clear()
  268. obj.add(obj2)
  269. obj.delete(index)
  270. obj.remove(obj2)
  271. obj.replace(index,obj2)
  272. obj.insert(index,obj2)
  273.  
  274. 2.4. Standard functions
  275.  
  276. format(format,parameters,...) - formats a "%s %d" string, inserts the parameters, and returns a string
  277. int(a)
  278. abs(a)
  279. random(rangestart,rangeend)
  280. sin(a)
  281. cos(a)
  282. arctan(a)
  283. exp(a)
  284. log(base,a)
  285. min(a,b)
  286. max(a,b)
  287. getangle(delta x,delta y)
  288. getdir(delta x,delta y)
  289. vecx(direction)
  290. vecy(direction)
  291.  
  292. 3. Events
  293.  
  294. 3.1. Gui controls
  295.  
  296. onAdd() when added to the parent
  297. onRemove() when removed from the parent
  298. onWake() when activated
  299. onSleep() when deactivated
  300. onResize(w,h)
  301. onMove(x,y)
  302. onMouseEnter(modifier,x,y,clickcount)
  303. onMouseLeave(modifier,x,y,clickcount)
  304. onMouseDown(modifier,x,y,clickcount)
  305. onMouseUp(modifier,x,y,clickcount)
  306. onMouseDragged(modifier,x,y,clickcount)
  307. onMouseMove(modifier,x,y,clickcount)
  308. onRightMouseDown(modifier,x,y,clickcount)
  309. onRightMouseUp(modifier,x,y,clickcount)
  310. onRightMouseDragged(modifier,x,y,clickcount)
  311. onMouseWheelUp(modifier,x,y,clickcount)
  312. onMouseWheelDown(modifier,x,y,clickcount)
  313. onKeyDown(keycode,string)
  314. onKeyUp(keycode,string)
  315. onKeyRepeat(keycode,string)
  316.  
  317. 3.1.1. GuiMLTextCtrl:
  318.  
  319. onReflow(w,h) when the text has changed
  320. onURL(url) when clicked on url
  321. onSelectTag(tagid) when clicked on an image
  322.  
  323. Text-Tags:
  324. The text of multi-line text controls can contain
  325. a few HTML-tags and Torque-tags, you can use both
  326. of those tag types to define colors and fonts
  327. or to include images. Currently following tags
  328. are available:
  329.  
  330. HTML:
  331. <a href=url> text </a> - when the user clicks on 'text' then
  332.   a web browser is opened for the specified url
  333. <br> - line break
  334. <font face=fontname size=textsize color=colorname or #rrggbb> text </font>
  335.   - draws text with a special font, size and color; you only
  336.   need to define one of those 3 attributes
  337. <ignorelinebreaks> </ignorelinebreaks> - go into normal HTML mode where
  338.   you need to insert <br> to do a linebreak
  339. <img src=filename id=integer> - an image is displayed, you
  340.   can also specify a tagid if you want to get onSelectTag-events
  341.   for this image
  342. <p align=left/center/right> - sets the align of the following text
  343. <span style="width=100; height=100;" id=integer> </span> - for
  344.   displaying a subpage, you can also specifiy an id for
  345.   onSelectTag-events; instead of <span> you can also use <div> tags
  346.  
  347. Torque:
  348. <a:url> text </a> - when the user clicks on 'text' then
  349.   a web browser is opened for the specified url
  350. <bitmap:filename> - an image is displayed
  351. <color:rrggbb> - sets the color of the text (hexadecimal value)
  352. <lmargin:pixels> - sets the left margin for the text
  353. <lmargin%:percent> - sets the size of the left margin depending
  354.   on the width of the whole control
  355. <linkcolor:rrggbb> - sets the color of links (the <a>-tag)
  356. <linkcolorhl:rrggbb> - sets the highlighted color, when
  357.   the user moves the mouse over a link
  358. <just:left/center/right> - sets the align of the following text
  359. <rmargin:pixels> - sets the right margin for the text
  360. <rmargin%:percent> - sets the size of the right margin depending
  361.   on the width of the whole control
  362. <sbreak> - line break
  363. <spush> - switches to a new style (like <font>)
  364. <spop> - switches back to the last saved style (like </font>)
  365. <tab:tab1,tab2,..> - sets the position of where tabulators should
  366.   be displayed if you have text like 'Apple \t Egg \t Chicken'
  367. <tag:id> - inserts an invisible tag which can be used
  368.   for the scrollToTag(id) function (beside image-tags)
  369.  
  370.  
  371. 3.1.2. GuiTextEditCtrl:
  372.  
  373. onTabComplete()
  374. onAction(text) when return key pressed
  375.  
  376. 3.1.3. GuiTextListCtrl:
  377.  
  378. onSelect(id,text) when row selected
  379. onDblClick(id) when double-click on row or return key pressed
  380. onDeleteKey(id) when delete key pressed
  381. onIconResized(w,h) when setIconSize() called
  382. onOpenMenu(0,index,text) when an item was right-clicked
  383.  
  384. 3.1.4. GuiPopUpMenuCtrl:
  385.  
  386. onSelect(id,text) when menu option choosen
  387. onCancel() when menu is closed without action
  388. onOpenMenu(0,index,text) when an item was right-clicked
  389.  
  390. 3.1.5. GuiMenuBar:
  391.  
  392. onMenuSelect(menuid,menutext)
  393. onMenuItemSelect(menuid,menutext,itemid,itemtext)
  394.  
  395. 3.1.6. GuiTreeViewCtrl:
  396.  
  397. onSelect(id,rightmouse) when row selected
  398. onUnselect(id) when row de-selected
  399. onInspect(id) when clicked on the name of an item
  400. onOpenMenu(0,index,text) when an item was right-clicked
  401. onContextMenu("x y",id) when clicked with right-mouse key on row
  402.  
  403.  
  404. 4. Old script compatibility
  405.  
  406. 4.1. Removed functionality
  407.  
  408. - toinventory
  409. - followplayer
  410. - playersays()
  411. - setbackpal
  412.  
  413. 4.2. Supported old scripting commands & their mapping to new script
  414.  
  415. addstring oldstring, oldstring;
  416.                                 addstring(string,string);
  417. addtiledef oldstring, oldstring, float;
  418.                                 addtiledef(string,string,float);
  419. addtiledef2 oldstring, oldstring, float, float;
  420.                                 addtiledef2(string,string,float,float);
  421. attachplayertoobj float, float;
  422.                                 attachplayertoobj(float,float);
  423. blockagain;
  424.                                 blockagain();
  425. blockagainlocal;
  426.                                 blockagainlocal();
  427. callnpc float, oldstring;
  428.                                 callnpc(float,string);
  429. callweapon float, oldstring;
  430.                                 callweapon(float,string);
  431. canbecarried;
  432.                                 canbecarried();
  433. canbepulled;
  434.                                 canbepulled();
  435. canbepushed;
  436.                                 canbepushed();
  437. cannotbecarried;
  438.                                 cannotbecarried();
  439. cannotbepulled;
  440.                                 cannotbepulled();
  441. cannotbepushed;
  442.                                 cannotbepushed();
  443. canwarp;
  444.                                 canwarp();
  445. canwarp2;
  446.                                 canwarp2();
  447. carryobject oldstring;
  448.                                 carryobject(string);
  449. changeimgcolors float, float, float, float, float;
  450.                                 changeimgcolors(float,float,float,float,float);
  451. changeimgmode float, float;
  452.                                 changeimgmode(float,float);
  453. changeimgpart float, float, float, float, float;
  454.                                 changeimgpart(float,float,float,float,float);
  455. changeimgvis float, float;
  456.                                 changeimgvis(float,float);
  457. changeimgzoom float, float;
  458.                                 changeimgzoom(float,float);
  459. deletestring oldstring, float;
  460.                                 deletestring(string,float);
  461. destroy;
  462.                                 destroy();
  463. detachplayer;
  464.                                 detachplayer();
  465. disabledefmovement;
  466.                                 disabledefmovement();
  467. disablemap;
  468.                                 disablemap();
  469. disablepause;
  470.                                 disablepause();
  471. disableselectweapons;
  472.                                 disableselectweapons();
  473. disableweapons;
  474.                                 disableweapons();
  475. dontblock;
  476.                                 dontblock();
  477. dontblocklocal;
  478.                                 dontblocklocal();
  479. drawaslight;
  480.                                 drawaslight();
  481. drawoverplayer;
  482.                                 drawoverplayer();
  483. drawunderplayer;
  484.                                 drawunderplayer();
  485. enabledefmovement;
  486.                                 enabledefmovement();
  487. enablefeatures float;
  488.                                 enablefeatures(float);
  489. enablemap;
  490.                                 enablemap();
  491. enablepause;
  492.                                 enablepause();
  493. enableselectweapons;
  494.                                 enableselectweapons();
  495. enableweapons;
  496.                                 enableweapons();
  497. explodebomb float;
  498.                                 explodebomb(float);
  499. followplayer;
  500.                                 followplayer();
  501. freezeplayer float;
  502.                                 freezeplayer(float);
  503. freezeplayer2;
  504.                                 freezeplayer2();
  505. hide;
  506.                                 hide();
  507. hideimg float;
  508.                                 hideimg(float);
  509. hideimgs float, float;
  510.                                 hideimgs(float,float);
  511. hidelocal;
  512.                                 hidelocal();
  513.  
  514. hitcompu float, float, float, float;
  515.                                 hitcompu(float,float,float,float);
  516. hitnpc float, float, float, float;
  517.                                 hitnpc(float,float,float,float);
  518. hitobjects float, float, float;
  519.                                 hitobjects(float,float,float);
  520. hideplayer float;
  521.                                 hideplayer(float);
  522. hidesword float;
  523.                                 hidesword(float);
  524. hitplayer float, float, float, float;
  525.                                 hitplayer(float,float,float,float);
  526. hurt float;
  527.                                 hurt(float);
  528. insertstring oldstring, float, oldstring;
  529.                                 insertstring(string,float,string);
  530. join oldstring;
  531.                                 join(string);
  532. lay oldstring;
  533.                                 lay(string);
  534. lay2 oldstring, float, float;
  535.                                 lay2(string,float,float);
  536. loadmap oldstring;
  537.                                 loadmap(string);
  538. message oldstring;
  539.                                 message(string);
  540. move float, float, float, float;
  541.                                 move(float,float,float,float);
  542. noplayerkilling;
  543.                                 noplayerkilling();
  544. openurl oldstring;
  545.                                 openurl(string);
  546. openurl2 oldstring, float, float;
  547.                                 openurl2(string,float,float);
  548. play oldstring;
  549.                                 play(string);
  550. play2 oldstring, float, float, float;
  551.                                 play2(string,float,float,float);
  552. playlooped oldstring;
  553.                                 playlooped(string);
  554. putbomb float, float, float;
  555.                                 putbomb(float,float,float);
  556. putcomp oldstring, float, float;
  557.                                 putcomp(string,float,float);
  558. putexplosion float, float, float;
  559.                                 putexplosion(float,float,float);
  560. putexplosion2 float, float, float, float;
  561.                                 putexplosion2(float,float,float,float);
  562. puthorse oldstring, float, float;
  563.                                 puthorse(string,float,float);
  564. putleaps float, float, float;
  565.                                 putleaps(float,float,float);
  566. putnewcomp oldstring, float, float, oldstring, float;
  567.                                 putnewcomp(string,float,float,string,float);
  568. putnpc oldstring, oldstring, float, float;
  569.                                 putnpc(string,string,float,float);
  570. putnpc2 float, float, oldstring;
  571.                                 putnpc2(float,float,string);
  572. reflectarrow float;
  573.                                 reflectarrow(float);
  574. removearrow float;
  575.                                 removearrow(float);
  576. removebomb float;
  577.                                 removebomb(float);
  578. removecompus;
  579.                                 removecompus();
  580. removeexplo float;
  581.                                 removeexplo(float);
  582. removehorse float;
  583.                                 removehorse(float);
  584. rmeoveitem float;
  585.                                 removeitem(float)
  586. removestring oldstring, oldstring;
  587.                                 removestring(string,string);
  588. removetiledefs oldstring;
  589.                                 removetiledefs(string);
  590. replaceani oldstring, oldstring;
  591.                                 replaceani(string,string);
  592. replacestring oldstring, float, oldstring;
  593.                                 replacestring(string,float,string);
  594. resetfocus;
  595.                                 resetfocus();
  596. savelog oldstring;
  597.                                 savelog(string);
  598. savelog2 oldstring, oldstring;
  599.                                 savelog2(string,string);
  600. say float;
  601.                                 say(float);
  602. say2 oldstring;
  603.                                 say2(string);
  604. sendrpgmessage oldstring;
  605.                                 sendrpgmessage(string);
  606. sendpm oldstring;
  607.                                 sendpm(string);
  608. sendtonc oldstring;
  609.                                 sendtonc(string);
  610. sendtorc oldstring;
  611.                                 sendtorc(string);
  612. serverwarp oldstring;
  613.                                 serverwarp(string);
  614. set oldstring;
  615.                                 set(string);
  616. setani oldstring, oldstring;
  617.                                 setani(string,string);
  618. setarray float, float;
  619.                                 setarray(var,float);
  620. setbeltcolor oldstring;
  621.                                 setbeltcolor(string);
  622. setbow oldstring;
  623.                                 setbow(string);
  624. setcharani oldstring, oldstring;
  625.                                 setcharani(string,string);
  626. setchargender oldstring;
  627.                                 setchargender(string);
  628. setcharprop oldstring, oldstring;
  629.                                 string = string;
  630. setcoatcolor oldstring;
  631.                                 setcoatcolor(string);
  632. setcoloreffect float, float, float, float;
  633.                                 setcoloreffect(float,float,float,float);
  634. setcursor float;
  635.                                 setcursor(float);
  636. setcurcor2 oldstring;
  637.                                 setcursor2(string);
  638. seteffect float, float, float, float;
  639.                                 seteffect(float,float,float,float);
  640. seteffectmode float;
  641.                                 seteffectmode(float);
  642. setfocus float, float;
  643.                                 setfocus(float,float);
  644. setgender oldstring;
  645.                                 setgender(string);
  646. sethead oldstring;
  647.                                 sethead(string);
  648. setlevel oldstring;
  649.                                 setlevel(string);
  650. setlevel2 oldstring, float, float;
  651.                                 setlevel2(string,float,float);
  652. setmap oldstring, oldstring, float, float;
  653.                                 setmap(string,string,float,float);
  654. setminimap oldstring, oldstring, float, float;
  655.                                 setminimap(string,string,float,float);
  656. setmusicvolume float, float;
  657.                                 setmusicvolume(float,float);
  658. setimg oldstring;
  659.                                 setimg(string);
  660. setimgpart oldstring, float, float, float, float;
  661.                                 setimgpart(string,float,float,float,float);
  662. setletters oldstring;
  663.                                 setletters(string);
  664. setplayerdir oldstring;
  665.                                 setplayerdir(string);
  666. setplayerprop oldstring, oldstring;
  667.                                 string = string;
  668. setpm oldstring;
  669.                                 setpm(string);
  670. setshape float, float, float;
  671.                                 setshape(float,float,float);
  672. setshape2 float, float, float;
  673.                                 setshape2(float,float,float);
  674. setshield oldstring, float;
  675.                                 setshield(string,float);
  676. setshoecolor oldstring;
  677.                                 setshoecolor(string);
  678. setshootparams oldstring;
  679.                                 setshootparams(string);
  680. setskincolor oldstring;
  681.                                 setskincolor(string);
  682. setsleevecolor oldstring;
  683.                                 setsleevecolor(string);
  684. setstring oldstring, oldstring;
  685.                                 setstring(string,string);
  686. setsword oldstring, float;
  687.                                 setsword(string,float);
  688. seturllevel oldstring;
  689.                                 seturllevel(string);
  690. setz float, float, float, float, float, float, float, float;
  691.                                 setz(float,float,float,float,float,float,float,float);
  692. setzoomeffect float;
  693.                                 setzoomeffect(float);
  694. shoot float, float, float, float, float, float, oldstring, oldstring;
  695.                                 shoot(float,float,float,float,float,float,string,string);
  696. shootarrow float;
  697.                                 shootarrow(float);
  698. shootball;
  699.                                 shootball();
  700. shootfireball float;
  701.                                 shootfireball(float);
  702. shootfireblast float;
  703.                                 shootfireblast(float);
  704. shootnuke float;
  705.                                 shootnuke(float);
  706. show;
  707.                                 show();
  708. showani float, float, float, float, oldstring;
  709.                                 showani(float,float,float,float,string);
  710. showani2 float, float, float, float, float, oldstring;
  711.                                 showani2(float,float,float,float,float,string);
  712. showcharacter;
  713.                                 showcharacter();
  714. showfile oldstring;
  715.                                 showfile(string);
  716. showimg float, oldstring, float, float;
  717.                                 showimg(float,string,float,float);
  718. showimg2 float, oldstring, float, float, float;
  719.                                 showimg2(float,string,float,float,float);
  720. showlocal;
  721.                                 showlocal();
  722.  
  723. showpoly float, float;
  724.                                 showpoly(float,array);
  725. showpoly2 float, float;
  726.                                 showpoly2(float,array);
  727. showstats float;
  728.                                 showstats(float);
  729. showtext float, float, float, oldstring, oldstring, oldstring;
  730.                                 showtext(float,float,float,string,string,string);
  731. showtext2 float, float, float, float, oldstring, oldstring, oldstring;
  732.                                 showtext2(float,float,float,float,string,string,string);
  733. sleep float;
  734.                                 sleep(float);
  735. spyfire float, float;
  736.                                 spyfire(float,float);
  737. stopmidi;
  738.                                 stopmidi();
  739. stopsound oldstring;
  740.                                 stopsound(string);
  741. take oldstring;
  742.                                 take(string);
  743. take2 float;
  744.                                 take2(float);
  745. takehorse float;
  746.                                 takehorse(float);
  747. takeplayercarry;
  748.                                 takeplayercarry();
  749. takeplayerhorse;
  750.                                 takeplayerhorse();
  751. throwcarry;
  752.                                 throwcarry();
  753. timereverywhere;
  754.                                 timereverywhere();
  755. timershow;
  756.                                 timershow();
  757. toinventory oldstring;
  758.                                 toinventory(string);
  759. tokenize oldstring;
  760.                                 tokens = string.tokenize();
  761. tokenize2 oldstring, oldstring;
  762.                                 tokens = string.tokenize(" ," @ string);
  763. toweapons oldstring;
  764.                                 toweapons(string);
  765. triggeraction float, float, oldstring, oldstring;
  766.                                 triggeraction(float,float,string,string);
  767. unfreezeplayer;
  768.                                 unfreezeplayer();
  769. unset oldstring;
  770.                                 unset(string);
  771. updateboard float, float, float, float;
  772.                                 updateboard(float,float,float,float);
  773. updateterrain;
  774.                                 updateterrain();
  775. wraptext float, oldstring, oldstring;
  776.                                 tokens = wraptext(float," ," @ string,string);
  777. wraptext2 float, float, oldstring, oldstring;
  778.                                 tokens = wraptext2(float,float," ," @ string,string);
  779.  
  780. 4.3. Supported old scripting functions & their mapping to new script
  781.  
  782. 4.4. Supported old string operations
  783.  
  784. These old string operators can be used in string parameters
  785. for the old commands, also you can use them directly as operators, e.g.
  786. #c = "hello"
  787. is actually doing
  788. player.chat = "hello"
  789.  
  790. #a            player.account
  791. #a(float)     players[float].account
  792. #m            player.ani
  793.               ani
  794. #m(float)     players[float].ani
  795. #K(float)     getascii(float)
  796. #8            player.bodyimg
  797.               bodyimg
  798. #8(float)     players[float].bodyimg
  799. #c            player.chat
  800.               chat
  801. #c(float)     players[float].chat
  802. #C0           player.colors[0]
  803.               colors[0]
  804. #C0(float)    players[float].colors[0]
  805. #C1           player.colors[1]
  806.               colors[1]
  807. #C1(float)    players[float].colors[1]
  808. #C2           player.colors[2]
  809.               colors[2]
  810. #C2(float)    players[float].colors[2]
  811. #C3           player.colors[3]
  812.               colors[3]
  813. #C3(float)    players[float].colors[3]
  814. #C4           player.colors[4]
  815.               colors[4]
  816. #C4(float)    players[float].colors[4]
  817. #C5           player.colors[5]
  818.               colors[5]
  819. #C5(float)    players[float].colors[5]
  820. #D            downloadfile()
  821. #E            emoticonchar()
  822. #e(float,float,oldstring)
  823.               string.substring(float,float)
  824. #g            player.guild
  825.               guild
  826. #g(float)     players[float].guild
  827. #3            player.headimg
  828.               headimg
  829. #3(float)     players[float].headimg
  830. #5            player.horseimg
  831.               horseimg
  832. #5(float)     players[float].horseimg
  833. #k(float)     keyname(float)
  834. #L            player.level
  835. #I(oldstring,float)
  836.               getstring(string)[float]
  837. #n            player.nick
  838.               nick
  839. #n(float)     players[float].nick
  840. #f            image
  841. #f(float)     npcs[float].image
  842. #F            level
  843. #p(float)     params[float]
  844. #P(float)     player.attr[float]
  845.               attr[float]
  846. #P(float,float)
  847.               players[float].attr[float]
  848. #P1           player.attr[1]
  849.               attr[1]
  850. #P1(float)    players[float].attr[1]
  851. #P2           player.attr[2]
  852.               attr[2]
  853. #P2(float)    players[float].attr[2]
  854. #P3           player.attr[3]
  855.               attr[3]
  856. #P3(float)    players[float].attr[3]
  857. #P4           player.attr[4]
  858.               attr[4]
  859. #P4(float)    players[float].attr[4]
  860. #P5           player.attr[5]
  861.               attr[5]
  862. #P5(float)    players[float].attr[5]
  863. #P6           player.attr[6]
  864.               attr[6]
  865. #P6(float)    players[float].attr[6]
  866. #P7           player.attr[7]
  867.               attr[7]
  868. #P7(float)    players[float].attr[7]
  869. #P8           player.attr[8]
  870.               attr[8]
  871. #P8(float)    players[float].attr[8]
  872. #P9           player.attr[9]
  873.               attr[9]
  874. #P9(float)    players[float].attr[9]
  875. #R(oldstring) string.random()
  876. #2            player.shieldimg
  877.               shieldimg
  878. #2(float)     players[float].shieldimg
  879. #s(oldstring) getstring(string)
  880. #1            player.swordimg
  881.               swordimg
  882. #1(float)     players[float].swordimg
  883. #S            player.sword.script
  884. #t(float)     tokens[float]
  885. #T(oldstring) string.trim()
  886. #v(float)     float
  887. #W            player.weapon.icon
  888. #W(float)     weapons[float].icon
  889. #w            player.weapon.script
  890. #w(float)     weapons[float].script
  891.  
  892. Compatibility note:
  893. When you use the command setcharprop then the first parameter
  894. is handled differently: instead of changing 'player.chat' it
  895. is changing 'chat', the chat text of the npc. So 'setcharprop #c,hello'
  896. would be translated into
  897. chat = "hello"
  898. while 'setplayerprop #c,hello' is translated into
  899. player.chat = "hello"
  900. In the list above both possibilities are listed.
  901.  
  902. */
  903. public function destroy() {
  904.   temp.stack = getCallStack();
  905.   temp.npc = stack[stack.size()-2].scriptcallobject.name;
  906.  
  907.   echo("[NPC Error]: '"@ npc @"' tried to delete '"@ this.name @"'");
  908. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment