Creation/Dev/GScript2: Difference between revisions

From Graal Bible
No edit summary
 
(19 intermediate revisions by 11 users not shown)
Line 1: Line 1:
GScript 2 is the new scripting engine for [[Graal]]
[[Category:Scripting Reference]]
 
What was formerly called [[Creation/Dev/Old GScript|GScript]] has now been replaced as '''GScript2''', [[Creation/Dev/GScript|Graal's scripting language]].
== Old Script Compatibility ==
 
=== Removed functionality ===
 
<ul>
<li>toinventory
<li>followplayer
<li>playersays()
<li>setbackpal
</ul>
 
=== Supported old scripting commands & their mapping to new script ===
 
<dl>
<dt>addstring oldstring, oldstring;
<dd>addstring(string,string);
 
<dt>addtiledef oldstring, oldstring, float;
<dd>addtiledef(string,string,float);
 
<dt>addtiledef2 oldstring, oldstring, float, float;
<dd>addtiledef2(string,string,float,float);
 
<dt>attachplayertoobj float, float;
<dd>attachplayertoobj(float,float);
 
<dt>blockagain;
<dd>                                blockagain();
<dt>blockagainlocal;
<dd>                                blockagainlocal();
<dt>callnpc float, oldstring;
<dd>                                callnpc(float,string);
<dt>callweapon float, oldstring;
<dd>                                callweapon(float,string);
<dt>canbecarried;
<dd>                                canbecarried();
<dt>canbepulled;
<dd>                                canbepulled();
<dt>canbepushed;
<dd>                                canbepushed();
<dt>cannotbecarried;
<dd>                                cannotbecarried();
<dt>cannotbepulled;
<dd>                                cannotbepulled();
<dt>cannotbepushed;
<dd>                                cannotbepushed();
<dt>canwarp;
<dd>                                canwarp();
<dt>canwarp2;
<dd>                                canwarp2();
<dt>carryobject oldstring;
<dd>                                carryobject(string);
<dt>changeimgcolors float, float, float, float, float;
<dd>                                changeimgcolors(float,float,float,float,float);
<dt>changeimgmode float, float;
<dd>                                changeimgmode(float,float);
<dt>changeimgpart float, float, float, float, float;
<dd>                                changeimgpart(float,float,float,float,float);
<dt>changeimgvis float, float;
<dd>                                changeimgvis(float,float);
<dt>changeimgzoom float, float;
<dd>                                changeimgzoom(float,float);
<dt>deletestring oldstring, float;
<dd>                                deletestring(string,float);
<dt>destroy;
<dd>                                destroy();
<dt>detachplayer;
<dd>                                detachplayer();
<dt>disabledefmovement;
<dd>                                disabledefmovement();
<dt>disablemap;
<dd>                                disablemap();
<dt>disablepause;
<dd>                                disablepause();
<dt>disableselectweapons;
<dd>                                disableselectweapons();
<dt>disableweapons;
<dd>                                disableweapons();
<dt>dontblock;
<dd>                                dontblock();
<dt>dontblocklocal;
<dd>                                dontblocklocal();
<dt>drawaslight;
<dd>                                drawaslight();
<dt>drawoverplayer;
<dd>                                drawoverplayer();
<dt>drawunderplayer;
<dd>                                drawunderplayer();
<dt>enabledefmovement;
<dd>                                enabledefmovement();
<dt>enablefeatures float;
<dd>                                enablefeatures(float);
<dt>enablemap;
<dd>                                enablemap();
<dt>enablepause;
<dd>                                enablepause();
<dt>enableselectweapons;
<dd>                                enableselectweapons();
<dt>enableweapons;
<dd>                                enableweapons();
<dt>explodebomb float;
<dd>                                explodebomb(float);
<dt>followplayer;
<dd>                                followplayer();
<dt>freezeplayer float;
<dd>                                freezeplayer(float);
<dt>freezeplayer2;
<dd>                                freezeplayer2();
<dt>hide;
<dd>                                hide();
<dt>hideimg float;
<dd>                                hideimg(float);
<dt>hideimgs float, float;
<dd>                                hideimgs(float,float);
<dt>hidelocal;
<dd>                                hidelocal();
<dd>
<dt>hitcompu float, float, float, float;
<dd>                                hitcompu(float,float,float,float);
<dt>hitnpc float, float, float, float;
<dd>                                hitnpc(float,float,float,float);
<dt>hitobjects float, float, float;
<dd>                                hitobjects(float,float,float);
<dt>hideplayer float;
<dd>                                hideplayer(float);
<dt>hidesword float;
<dd>                                hidesword(float);
<dt>hitplayer float, float, float, float;
<dd>                                hitplayer(float,float,float,float);
<dt>hurt float;
<dd>                                hurt(float);
<dt>insertstring oldstring, float, oldstring;
<dd>                                insertstring(string,float,string);
<dt>join oldstring;
<dd>                                join(string);
<dt>lay oldstring;
<dd>                                lay(string);
<dt>lay2 oldstring, float, float;
<dd>                                lay2(string,float,float);
<dt>loadmap oldstring;
<dd>                                loadmap(string);
<dt>message oldstring;
<dd>                                message(string);
<dt>move float, float, float, float;
<dd>                                move(float,float,float,float);
<dt>noplayerkilling;
<dd>                                noplayerkilling();
<dt>openurl oldstring;
<dd>                                openurl(string);
<dt>openurl2 oldstring, float, float;
<dd>                                openurl2(string,float,float);
<dt>play oldstring;
<dd>                                play(string);
<dt>play2 oldstring, float, float, float;
<dd>                                play2(string,float,float,float);
<dt>playlooped oldstring;
<dd>                                playlooped(string);
<dt>putbomb float, float, float;
<dd>                                putbomb(float,float,float);
<dt>putcomp oldstring, float, float;
<dd>                                putcomp(string,float,float);
<dt>putexplosion float, float, float;
<dd>                                putexplosion(float,float,float);
<dt>putexplosion2 float, float, float, float;
<dd>                                putexplosion2(float,float,float,float);
<dt>puthorse oldstring, float, float;
<dd>                                puthorse(string,float,float);
<dt>putleaps float, float, float;
<dd>                                putleaps(float,float,float);
<dt>putnewcomp oldstring, float, float, oldstring, float;
<dd>                                putnewcomp(string,float,float,string,float);
<dt>putnpc oldstring, oldstring, float, float;
<dd>                                putnpc(string,string,float,float);
<dt>putnpc2 float, float, oldstring;
<dd>                                putnpc2(float,float,string);
<dt>reflectarrow float;
<dd>                                reflectarrow(float);
<dt>removearrow float;
<dd>                                removearrow(float);
<dt>removebomb float;
<dd>                                removebomb(float);
<dt>removecompus;
<dd>                                removecompus();
<dt>removeexplo float;
<dd>                                removeexplo(float);
<dt>removehorse float;
<dd>                                removehorse(float);
<dt>removeitem float;
<dd>                                removeitem(float)
<dt>removestring oldstring, oldstring;
<dd>                                removestring(string,string);
<dt>removetiledefs oldstring;
<dd>                                removetiledefs(string);
<dt>replaceani oldstring, oldstring;
<dd>                                replaceani(string,string);
<dt>replacestring oldstring, float, oldstring;
<dd>                                replacestring(string,float,string);
<dt>resetfocus;
<dd>                                resetfocus();
<dt>savelog oldstring;
<dd>                                savelog(string);
<dt>savelog2 oldstring, oldstring;
<dd>                                savelog2(string,string);
<dt>say float;
<dd>                                say(float);
<dt>say2 oldstring;
<dd>                                say2(string);
<dt>sendrpgmessage oldstring;
<dd>                                sendrpgmessage(string);
<dt>sendpm oldstring;
<dd>                                sendpm(string);
<dt>sendtonc oldstring;
<dd>                                sendtonc(string);
<dt>sendtorc oldstring;
<dd>                                sendtorc(string);
<dt>serverwarp oldstring;
<dd>                                serverwarp(string);
<dt>set oldstring;
<dd>                                set(string);
<dt>setani oldstring, oldstring;
<dd>                                setani(string,string);
<dt>setarray float, float;
<dd>                                setarray(var,float);
<dt>setbeltcolor oldstring;
<dd>                                setbeltcolor(string);
<dt>setbow oldstring;
<dd>                                setbow(string);
<dt>setcharani oldstring, oldstring;
<dd>                                setcharani(string,string);
<dt>setchargender oldstring;
<dd>                                setchargender(string);
<dt>setcharprop oldstring, oldstring;
<dd>                                string = string;
<dt>setcoatcolor oldstring;
<dd>                                setcoatcolor(string);
<dt>setcoloreffect float, float, float, float;
<dd>                                setcoloreffect(float,float,float,float);
<dt>setcursor float;
<dd>                                setcursor(float);
<dt>setcurcor2 oldstring;
<dd>                                setcursor2(string);
<dt>seteffect float, float, float, float;
<dd>                                seteffect(float,float,float,float);
<dt>seteffectmode float;
<dd>                                seteffectmode(float);
<dt>setfocus float, float;
<dd>                                setfocus(float,float);
<dt>setgender oldstring;
<dd>                                setgender(string);
<dt>sethead oldstring;
<dd>                                sethead(string);
<dt>setlevel oldstring;
<dd>                                setlevel(string);
<dt>setlevel2 oldstring, float, float;
<dd>                                setlevel2(string,float,float);
<dt>setmap oldstring, oldstring, float, float;
<dd>                                setmap(string,string,float,float);
<dt>setminimap oldstring, oldstring, float, float;
<dd>                                setminimap(string,string,float,float);
<dt>setmusicvolume float, float;
<dd>                                setmusicvolume(float,float);
<dt>setimg oldstring;
<dd>                                setimg(string);
<dt>setimgpart oldstring, float, float, float, float;
<dd>                                setimgpart(string,float,float,float,float);
<dt>setletters oldstring;
<dd>                                setletters(string);
<dt>setplayerdir oldstring;
<dd>                                setplayerdir(string);
<dt>setplayerprop oldstring, oldstring;
<dd>                                string = string;
<dt>setpm oldstring;
<dd>                                setpm(string);
<dt>setshape float, float, float;
<dd>                                setshape(float,float,float);
<dt>setshape2 float, float, float;
<dd>                                setshape2(float,float,float);
<dt>setshield oldstring, float;
<dd>                                setshield(string,float);
<dt>setshoecolor oldstring;
<dd>                                setshoecolor(string);
<dt>setshootparams oldstring;
<dd>                                setshootparams(string);
<dt>setskincolor oldstring;
<dd>                                setskincolor(string);
<dt>setsleevecolor oldstring;
<dd>                                setsleevecolor(string);
<dt>setstring oldstring, oldstring;
<dd>                                setstring(string,string);
<dt>setsword oldstring, float;
<dd>                                setsword(string,float);
<dt>seturllevel oldstring;
<dd>                                seturllevel(string);
<dt>setz float, float, float, float, float, float, float, float;
<dd>                                setz(float,float,float,float,float,float,float,float);
<dt>setzoomeffect float;
<dd>                                setzoomeffect(float);
<dt>shoot float, float, float, float, float, float, oldstring, oldstring;
<dd>                                shoot(float,float,float,float,float,float,string,string);
<dt>shootarrow float;
<dd>                                shootarrow(float);
<dt>shootball;
<dd>                                shootball();
<dt>shootfireball float;
<dd>                                shootfireball(float);
<dt>shootfireblast float;
<dd>                                shootfireblast(float);
<dt>shootnuke float;
<dd>                                shootnuke(float);
<dt>show;
<dd>                                show();
<dt>showani float, float, float, float, oldstring;
<dd>                                showani(float,float,float,float,string);
<dt>showani2 float, float, float, float, float, oldstring;
<dd>                                showani2(float,float,float,float,float,string);
<dt>showcharacter;
<dd>                                showcharacter();
<dt>showfile oldstring;
<dd>                                showfile(string);
<dt>showimg float, oldstring, float, float;
<dd>                                showimg(float,string,float,float);
<dt>showimg2 float, oldstring, float, float, float;
<dd>                                showimg2(float,string,float,float,float);
<dt>showlocal;
<dd>                                showlocal();
<dt>showpoly float, float;
<dd>                                showpoly(float,array);
<dt>showpoly2 float, float;
<dd>                                showpoly2(float,array);
<dt>showstats float;
<dd>                                showstats(float);
<dt>showtext float, float, float, oldstring, oldstring, oldstring;
<dd>                                showtext(float,float,float,string,string,string);
<dt>showtext2 float, float, float, float, oldstring, oldstring, oldstring;
<dd>                                showtext2(float,float,float,float,string,string,string);
<dt>sleep float;
<dd>                                sleep(float);
<dt>spyfire float, float;
<dd>                                spyfire(float,float);
<dt>stopmidi;
<dd>                                stopmidi();
<dt>stopsound oldstring;
<dd>                                stopsound(string);
<dt>take oldstring;
<dd>                                take(string);
<dt>take2 float;
<dd>                                take2(float);
<dt>takehorse float;
<dd>                                takehorse(float);
<dt>takeplayercarry;
<dd>                                takeplayercarry();
<dt>takeplayerhorse;
<dd>                                takeplayerhorse();
<dt>throwcarry;
<dd>                                throwcarry();
<dt>timereverywhere;
<dd>                                timereverywhere();
<dt>timershow;
<dd>                                timershow();
<dt>toinventory oldstring;
<dd>                                toinventory(string);
<dt>tokenize oldstring;
<dd>                                tokens = string.tokenize();
<dt>tokenize2 oldstring, oldstring;
<dd>                                tokens = string.tokenize(" ," @ string);
<dt>toweapons oldstring;
<dd>                                toweapons(string);
<dt>triggeraction float, float, oldstring, oldstring;
<dd>                                triggeraction(float,float,string,string);
<dt>unfreezeplayer;
<dd>                                unfreezeplayer();
<dt>unset oldstring;
<dd>                                unset(string);
<dt>updateboard float, float, float, float;
<dd>                                updateboard(float,float,float,float);
<dt>updateterrain;
<dd>                                updateterrain();
<dt>wraptext float, oldstring, oldstring;
<dd>                                tokens = wraptext(float," ," @ string,string);
<dt>wraptext2 float, float, oldstring, oldstring;
<dd>                                tokens = wraptext2(float,float," ," @ string,string);
</dl>
 
=== Supported old string operations ===
 
These old string operators can be used in string parameters for the old commands, also you can use them directly as operators, e.g.<br/>
<pre>#c = "hello"</pre>
is actually doing<br/>
<pre>player.chat = "hello"</pre>
 
<pre>
#a            player.account
#a(float)    players[float].account
#m            player.ani
              ani
#m(float)    players[float].ani
#K(float)    ascii(float)
#8            player.bodyimg
              bodyimg
#8(float)    players[float].bodyimg
#c            player.chat
              chat
#c(float)    players[float].chat
#C0          player.colors[0]
              colors[0]
#C0(float)    players[float].colors[0]
#C1          player.colors[1]
              colors[1]
#C1(float)    players[float].colors[1]
#C2          player.colors[2]
              colors[2]
#C2(float)    players[float].colors[2]
#C3          player.colors[3]
              colors[3]
#C3(float)    players[float].colors[3]
#C4          player.colors[4]
              colors[4]
#C4(float)    players[float].colors[4]
#C5          player.colors[5]
              colors[5]
#C5(float)    players[float].colors[5]
#D            downloadfile()
#E            emoticonchar()
#e(float,float,oldstring)
              string.substring(float,float)
#g            player.guild
              guild
#g(float)    players[float].guild
#3            player.headimg
              headimg
#3(float)    players[float].headimg
#5            player.horseimg
              horseimg
#5(float)    players[float].horseimg
#k(float)    keyname(float)
#L            player.level
#I(oldstring,float)
              getstring(string)[float]
#n            player.nick
              nick
#n(float)    players[float].nick
#f            image
#f(float)    npcs[float].image
#F            level
#p(float)    params[float]
#P(float)    player.attr[float]
              attr[float]
#P(float,float)
              players[float].attr[float]
#P1          player.attr[1]
              attr[1]
#P1(float)    players[float].attr[1]
#P2          player.attr[2]
              attr[2]
#P2(float)    players[float].attr[2]
#P3          player.attr[3]
              attr[3]
#P3(float)    players[float].attr[3]
#P4          player.attr[4]
              attr[4]
#P4(float)    players[float].attr[4]
#P5          player.attr[5]
              attr[5]
#P5(float)    players[float].attr[5]
#P6          player.attr[6]
              attr[6]
#P6(float)    players[float].attr[6]
#P7          player.attr[7]
              attr[7]
#P7(float)    players[float].attr[7]
#P8          player.attr[8]
              attr[8]
#P8(float)    players[float].attr[8]
#P9          player.attr[9]
              attr[9]
#P9(float)    players[float].attr[9]
#R(oldstring) string.random()
#2            player.shieldimg
              shieldimg
#2(float)    players[float].shieldimg
#s(oldstring) getstring(string)
#1            player.swordimg
              swordimg
#1(float)    players[float].swordimg
#S            player.sword.script
#t(float)    tokens[float]
#T(oldstring) string.trim()
#v(float)    float
#W            player.weapon.icon
#W(float)    weapons[float].icon
#w            player.weapon.script
#w(float)    weapons[float].script
</pre>
 
Compatibility note:
When you use the command setcharprop then the first parameter
is handled differently: instead of changing 'player.chat' it
is changing 'chat', the chat text of the npc. So 'setcharprop #c,hello'
would be translated into
chat = "hello"
while 'setplayerprop #c,hello' is translated into
player.chat = "hello"
In the list above both possibilities are listed.
 
== Old Script Compatibility ==
 
=== Operators ===
<pre>
Addition                  a + b
Substraction              a - b
Mulitplication            a * b
Division                  a / b
Modulus                  a % b
Power                    a ^ b
String Concationation    a @ b
Bool-And                  a && b
Bool-Or                  a || b
Bool-Not                  !a
Negative                  -a
Equal                    a == b
Not-Equal                a != b
Less                      a < b
Greater                  a > b
Less-Equal                a <= b,  a =< b
Greater-Equal            a >= b,  a => b
In-Range                  a in <b,c>, a in |b,c>, a in <b,c|, a in |b,c|
In-Array                  a in {b,c,...}, {a,b,...} in {c,d,...}
Array-Constructor        {a,b,...}
Empty Array              new [count]
Array Member              a[index]
Function call            a(), a(b,c,...)
Object Attribute          a.b, a.(b)
Post Increment            a++
Post Decrement            a--
Pre Increment            ++a
Pre Decrement            --a
Old String Function      #a
Conditional              a? b : c
Assignment                a = b, a := b
Additive Assignment      a += b
Substractive Assignment  a -= b
Multiplicative Assignment a *= b
Division Assignment      a /= b
Modulus Assignment        a %= b
Power Assignment          a ^= b
String Append            a @= b
</pre>
 
=== Accessing Variables ===
 
Graal Script variables are 'variant', that means they are objects
that hold values of different types.
When you assign a value to the variable then it automatically
switches to the right type:
 
Numeric (floating point):
  var = 1;
String:
  var = "hello";
Object link:
  var = player;
Array (list of objects):
  var = {1,2,3};
 
You can check the current type with the
type()-function - obj.type() returns
0,1,2,3 for numeric, string, object or array.
 
=== Standard Object Functions ===
<pre>
obj.name
obj.type()  - gets the type of the var (float 0, string 1, object 2, array 3)
obj.length() - string length
obj.trim()
obj.tokenize([delimiters])
obj.charat(pos)
obj.pos(substring)
obj.begins(string)
obj.endson(string)
obj.substring(index[,length])
obj.size() - array length
obj.index(obj2) - position of obj2 in the array
obj.clear()
obj.add(obj2)
obj.delete(index)
obj.remove(obj2)
obj.replace(index,obj2)
obj.insert(index,obj2)
obj.getvarnames() - list of the object attributes
obj.geteditvarnames()
obj.loadstring(filename)
obj.loadlines(filename)
obj.loadvars(filename)
obj.savestring(filename,mode)
obj.savelines(filename,mode)
obj.savevars(filename,mode)
</pre>
==== NPCs ====
<pre>
npc.actionplayer - integer, read only
npc.ani - object, read only
npc.anistep - integer, read only
npc.ap - integer
npc.attr - array
npc.attached - boolean, read only
npc.attachid - integer, read only
npc.attachtype - integer, read only
npc.body - object
npc.bodyimg - string
npc.bombs - integer
npc.chat - string
npc.colors - array
npc.darts - integer
npc.dir - integer
npc.glovepower - integer
npc.gralats - integer
npc.head - object
npc.headimg - string
npc.headset - integer
npc.hearts - floating point value, better use npc.hp
npc.height - floating point value, read only
npc.horseimg - string
npc.hp - floating point value
npc.hurtdx - floating point value
npc.hurtdy - floating point value
npc.id - integer, read only
npc.isfemale - boolean, read only
npc.ismale - boolean, read only
npc.isweapon - boolean, read only
npc.layer - integer
npc.mp - integer
npc.nick - string
npc.peltwithnpc - boolean, read only
npc.peltwithbush - boolean, read only
npc.peltwithsign - boolean, read only
npc.peltwithvase - boolean, read only
npc.peltwithstone - boolean, read only
npc.peltwithblackstone - boolean, read only
npc.rupees - integer, better use npc.gralats
npc.shield - object
npc.shieldimg - string
npc.shieldpower - integer
npc.sprite - integer
npc.sword - object
npc.swordimg - string
npc.swordpower - integer
npc.timeout - floating point value
npc.visible - boolean
npc.width - floating point value, read only
npc.x - floating point value
npc.y - floating point value
npc.z - floating point value
 
npc.blockagain()
npc.blockagainlocal()
npc.canbecarried()
npc.cannotbecarried()
npc.canbepushed()
npc.cannotbepushed()
npc.canbepulled()
npc.cannotbepulled()
npc.carryobject(name)
npc.catchevent(object name,event,function)
npc.changeimgcolors(index,red,green,blue,alpha)
npc.changeimgmode(index,mode)
npc.changeimgpart(index,x,y,width,height)
npc.changeimgvis(index,layer)
npc.changeimgzoom(index,zoom factor)
npc.destroy()
npc.dontblock()
npc.dontblocklocal()
npc.drawaslight()
npc.drawoverplayer()
npc.drawunderplayer()
npc.getimageforsprite(sprite) - returns image
npc.getsprite(string) - returns sprite
npc.getspriteforspritepos(spritepos) - returns sprite
npc.hide()
npc.hidelocal()
npc.hideimg(index)
npc.hideimgs(startindex,endindex)
npc.hurt(power)
npc.ignoreevent(object name,event)
npc.ignoreevents(object name)
npc.lay(item name)
npc.message(text)
npc.move(delta x,delta y,time,options)
npc.setbow(image name)
npc.setcharani(ani name,parameters)
npc.setchargender("male" or "female")
npc.setcoloreffect(red,green,blue,alpha)
npc.seteffectmode(mode)
npc.setimg(image name)
npc.setimgpart(image name,x,y,width,height)
npc.setshape(type,pixelwidth,pixelheight)
npc.setshape2(tilewidth,tileheight,tilearray)
npc.setzoomeffect(zoom factor)
npc.shootarrow(direction)
npc.shootball()
npc.shootfireball(direction)
npc.shootfireblast(direction)
npc.shootnuke(direction)
npc.show()
npc.showani(index,x,y,direction,ani name,parameters)
npc.showani2(index,x,y,z,direction,ani name,parameters)
npc.showcharacter()
npc.showimg(index,image name,x,y)
npc.showimg2(index,image name,x,y,z)
npc.showlocal()
npc.showpoly(index,array)
npc.showpoly2(index,array)
npc.showtext(index,x,y,font,style,text)
npc.showtext2(index,x,y,z,font,style,text)
npc.take(item name)
npc.take2(item index)
npc.takehorse(horse index)
npc.throwcarry()
npc.timereverywhere()
npc.timershow()
npc.toweapons(weapon name)
</pre>
 
==== Players ====
<pre>
player.account - string, read only
player.ani - object, read only
player.anistep - integer, read only
player.ap - integer
player.attached - boolean, read only
player.attachid - integer, read only
player.attachtype - integer, read only
player.attr - array
player.body - object
player.bodyimg - string
player.bombs - integer
player.chat - string
player.colors - array
player.darts - integer
player.dir - integer
player.freezetime - floating point value, only valid for local players
player.fullhearts - integer, read only, better use player.maxhp
player.glovepower - integer
player.gralats - integer
player.head - object
player.headimg - string
player.headset - integer
player.hearts - floating point value, only editable for local players, better use player.hp
player.horseimg - string, only editable for local players
player.hp - floating point value, only editable for local players
player.hurt - boolean, read only, only valid for local players
player.hurtdx - floating point value, read only, only valid for local players
player.hurtdy - floating point value, read only, only valid for local players
player.hurted - boolean, read only, only valid for local players, better use player.hurt
player.hurtpower - floating point value, read only, only valid for local players
player.id - integer, read only
player.isfemale - boolean, read only
player.ismale - boolean, read only
player.letters - object, only valid for local players
player.level - object, read only
player.map - boolean, only valid for local players
player.maxhp - integer, read only
player.mp - integer
player.nick - string, read only for local players
player.onhorse - boolean, read only, only valid for local players
player.online - boolean, read only, only valid for local players
player.paused - boolean, read only, only valid for local players
player.reading - boolean, read only, only valid for local players
player.rupees - integer, better use player.gralats
player.shield - object
player.shieldimg - string
player.shieldpower - integer, read only
player.sprite - integer
player.swimming - boolean, read only, only valid for local players
player.sword - object
player.swordimg - string
player.swordpower - integer, read only
player.weapon - object, read only, only valid for local players
player.weapons - array, read only, only valid for local players
player.x - floating point value
player.y - floating point value
player.z - floating point value
 
player.getimageforsprite(sprite) - returns object
player.getsprite(string) - returns object
player.getspriteforspritepos(spritepos) - returns object
</pre>
 
==== Levels ====
==== Ganis ====
<pre>
e.g. player.ani
ani.name
ani.sprites[]
ani.steps[]
ani.continuous
ani.singledirection
ani.looping
ani.ismovie
ani.setbackto
ani.ganitype
ani.getsprite(id)
ani.addsprite(id) returns the added sprite
ani.deletesprite(id)
ani.addstep()
ani.insertstep(index)
ani.deletestep(index)
 
sprites:
sprite.spriteindex
sprite.image
sprite.imagetype
sprite.x
sprite.y
sprite.width
sprite.height
sprite.red
sprite.green
sprite.blue
sprite.alpha
sprite.zoom
sprite.mode
sprite.surface
sprite.attachments[]
sprite.addattachment()
sprite.insertattachment(index)
sprite.deleteattachment(index)
 
attachment:
attachment.sprite
attachment.dx
attachment.dy
attachment.behind
 
step:
step.spritespos[][]
step.sounds[]
step.delay
step.addpos(dir)
step.insertpos(dir,index)
step.deletepos(dir,index)
 
spritepos:
spritepos.sprite
spritepos.param
spritepos.attr
spritepos.dx
spritepos.dy
 
sound:
sound.sound
sound.dx
sound.dy
sound.delay
 
also the gani owners (players, npcs) have those functions:
getimageforsprite(sprite)
getsprite(string)
getspriteforspritepos(spritepos)
</pre>
 
=== Standard functions ===
<pre>
format(format,parameters,...) - formats a "%s %d" string, inserts the parameters, and returns a string
int(a)
abs(a)
random(rangestart,rangeend)
sin(a)
cos(a)
arctan(a)
exp(a)
log(base,a)
min(a,b)
max(a,b)
getangle(delta x,delta y)
getdir(delta x,delta y)
vecx(direction)
vecy(direction)
</pre>
 
=== Standard variables ===
 
== GUI ==
 
=== GUI controls ===
 
=== GUI events ===
<pre>
All controls:
onAdd() when added to the parent
onRemove() when removed from the parent
onWake() when activated
onSleep() when deactivated
onResize(w,h)
onMove(x,y)
onMouseEnter(modifier,x,y,clickcount)
onMouseLeave(modifier,x,y,clickcount)
onMouseDown(modifier,x,y,clickcount)
onMouseUp(modifier,x,y,clickcount)
onMouseDragged(modifier,x,y,clickcount)
onMouseMove(modifier,x,y,clickcount)
onRightMouseDown(modifier,x,y,clickcount)
onRightMouseUp(modifier,x,y,clickcount)
onRightMouseDragged(modifier,x,y,clickcount)
onMouseWheelUp(modifier,x,y,clickcount)
onMouseWheelDown(modifier,x,y,clickcount)
onKeyDown(keycode,string)
onKeyUp(keycode,string)
onKeyRepeat(keycode,string)
 
GuiMLTextCtrl:
onResize(w,h) when reflowing
onURL(url) when clicked on url
 
GuiTextEditCtrl:
onTabComplete()
onAction(text) when return key pressed
 
GuiTextListCtrl:
onSelect(id,text) when row selected
onDblClick(id) when double-click on row or return key pressed
onDeleteKey(id) when delete key pressed
onIconResized(w,h) when setIconSize() called
onOpenMenu(0,index,text) when an item was right-clicked
 
GuiPopUpMenuCtrl:
onSelect(id,text) when menu option choosen
onCancel() when menu is closed without action
onOpenMenu(0,index,text) when an item was right-clicked
 
GuiMenuBar:
onMenuSelect(menuid,menutext)
onMenuItemSelect(menuid,menutext,itemid,itemtext)
 
GuiTreeViewCtrl:
onSelect(id,rightmouse) when row selected
onUnselect(id) when row de-selected
onInspect(id) when clicked on the name of an item
onOpenMenu(0,index,text) when an item was right-clicked
onContextMenu("x y",id) when clicked with right-mouse key on row
</pre>

Latest revision as of 02:02, 12 September 2009

What was formerly called GScript has now been replaced as GScript2, Graal's scripting language.