Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   New scripting engine fixes (https://forums.graalonline.com/forums/showthread.php?t=59077)

Admins 05-24-2005 02:20 AM

New scripting engine fixes
 
Today a new npcserver has been uploaded which fixes several things. Restart it to update it to the latest version:

- player.triggerclient(weaponscript [,params]) has been added, works like triggeraction(0,0,"clientside",params)
- object.trigger("action",params) is also accepting single parameters (was only accepting parameters before if there were at least 2 of them)
- when a script is run for a player (e.g. if you player.join("myclass")) then the current player is correctly set and functions like setlevel2 should work correctly
- npc.save[] can correctly be accessed on clientside
- if a variable is not an array (size()==0) then you can access the content of the variable also with "var[0]", which is the same like using "var" then; this is for compatibility with old Graal script.
- in compound statements like "if (var) { this.test = 1; drawunderplayer}" it is now accepting old style graal commands (e.g. drawunderplayer) without semicolon if it's used directly before the closing bracket }. This is for compatibility with old Graal script.
- arrays like npcs[] and players[] can now be assigned to normal variables (still using a link to the originial array so no speed problems), like
e = level.npcs;
echo("npc count: " @ e.size());
- assigning a sub array to the array variable is not crashing the npcserver anymore, so you can do stuff like this now:
this.arr = {{1,2},3,4};
this.arr = this.arr[0];

Kaimetsu 05-24-2005 02:29 AM

Quote:

Originally Posted by Stefan
- arrays like npcs[] and players[] can now be assigned to normal variables (still using a link to the originial array so no speed problems)

That sounds pretty interesting. If Graal can use aliases to variables then could we maybe have an option to pass function arguments by reference? Or to manually create links between variables?

Quote:

- assigning a sub array to the array variable is not crashing the npcserver anymore, so you can do stuff like this now:
this.arr = {{1,2},3,4};
this.arr = this.arr[0];
:D

xAndrewx 05-24-2005 07:48 AM

npc.save[]
What does this do?

CheeToS2 05-24-2005 07:52 AM

Quote:

Originally Posted by xAndrewx
npc.save[]
What does this do?

save[] variables are accessible on clientside and serverside, EX:

if (created || timeout) {
save[0]++;
timeout = 1;
}
//#CLIENTSIDE
if (created || timeout) {
setcharprop #c,#v(save[0]); // will increase
timeout = 1;
}

xAndrewx 05-24-2005 07:58 AM

I mean what does it actually do? save npcs o_o?
and how would you use it in a script what would benefit the player/npc server?

Rick 05-24-2005 08:21 AM

Quote:

Originally Posted by Stefan
- player.triggerclient(weaponscript [,params]) has been added, works like triggeraction(0,0,"clientside",params)

Yay!

CheeToS2 05-24-2005 08:38 AM

Quote:

Originally Posted by xAndrewx
I mean what does it actually do? save npcs o_o?
and how would you use it in a script what would benefit the player/npc server?

It's an array (hence the []s), not a function. It makes it easy to pass information between clientside and serverside without needing to deal with triggeractions. It doesn't save the npc, it just saves numbers. If there was some kind of setting done on clientside, you wouldn't want to use a triggeraction every time to find out what it is when you could simply reference a variable.

xAndrewx 05-24-2005 09:41 AM

Oh,cool :D.
Thanks for clearing that up.

Admins 05-24-2005 01:10 PM

Quote:

Originally Posted by Kaimetsu
That sounds pretty interesting. If Graal can use aliases to variables then could we maybe have an option to pass function arguments by reference? Or to manually create links between variables?

Well you have the object.link() function which passes a link to the object, and doesn't necessary copy it. Gui objects, players and npcs are always passed as links. But it can also be good if you have huge arrays.

Fry 05-24-2005 01:24 PM

Some great stuff there, but:
Quote:

Originally Posted by Stefan
- player.triggerclient(weaponscript [,params]) has been added, works like triggeraction(0,0,"clientside",params)

Are we going to get triggerserver(weapon, parameters) too? Or is there any replacement for going through the player's weapons and using callweapon(..) I don't know of? I would trigger the weapon directly, but it isn't working.
EDIT: Ah, it's different, .trigger works with the current player, but if you trigger on another player, e.g. with findplayer(..) or players[i] it isn't working.


Quote:

Originally Posted by Stefan
- arrays like npcs[] and players[] can now be assigned to normal variables (still using a link to the originial array so no speed problems), like
e = level.npcs;
echo("npc count: " @ e.size());

level.npcs works, but level.players never works, even if you access it directly.

Kaimetsu 05-24-2005 05:39 PM

Quote:

Originally Posted by Stefan
Well you have the object.link() function which passes a link to the object, and doesn't necessary copy it

Oh, awesome. That's gonna be pretty useful.

Admins 05-24-2005 07:29 PM

Quote:

Originally Posted by Fry
but level.players never works, even if you access it directly.

Because it's not existing yet

Fry 05-24-2005 07:44 PM

Quote:

Originally Posted by Stefan
Because it's not existing yet

The "yet" sounds good, I hope for it to arrive soon, because the raw "players[i]" isn't working very reliable.

Kaimetsu 05-25-2005 12:32 AM

Quote:

Originally Posted by Stefan
Well you have the object.link() function which passes a link to the object, and doesn't necessary copy it

Hm. What about things like obj.substring(...)? Is it necessary to use something like this?

NPC Code:
text = obj.substring(...);
myfunction (text.link());



Also, it's not really relevant to the thread, but is it possible that we could get clipboard access from within scripts? Mostly for scripted chat bars and suchlike.

Velox Cruentus 05-25-2005 01:11 PM

It might be abused for that one (Some people copy and paste their passwords when it's new, and going on a server with that in clipboard may serve as a vulnerbility to the actual player).

Admins 05-25-2005 01:16 PM

Quote:

Originally Posted by Kaimetsu
Hm. What about things like obj.substring(...)? Is it necessary to use something like this?

NPC Code:
text = obj.substring(...);
myfunction (text.link());



Also, it's not really relevant to the thread, but is it possible that we could get clipboard access from within scripts? Mostly for scripted chat bars and suchlike.

If you pass the parameter as link then the function should be able to change the content of the original variable (not tested that a lot yet though).

About clipboard: the question is security yes, may be we could make some onClipboardInsert event that is called when you do Ctrl+V or Shift+Insert

Kaimetsu 05-25-2005 04:09 PM

Quote:

Originally Posted by Velox Cruentus
It might be abused for that one (Some people copy and paste their passwords when it's new, and going on a server with that in clipboard may serve as a vulnerbility to the actual player).

Well, like Stefan said, the scripts wouldn't be able to access the clipboard contents at any arbitrary time. They'd just catch the copy and paste events.

Quote:

Originally Posted by Stefan
If you pass the parameter as link then the function should be able to change the content of the original variable

I might be doing something wrong, but I can't seem to get it to work under v3. If I do the following:

NPC Code:
a = 1;
b=a.link();
b++;
player.chat = a;



Then my chat is set to '1', meaning that altering b had no effect on a :confused:

Skyld 05-25-2005 05:05 PM

Quote:

Originally Posted by Stefan
About clipboard: the question is security yes, may be we could make some onClipboardInsert event that is called when you do Ctrl+V or Shift+Insert

Perhaps it should be an option in the client on whether to allow access to the clipboard. I can imagine that not everyone would like other people's scripts to have access to their clipboard.

Kaimetsu 05-25-2005 05:17 PM

Quote:

Originally Posted by Skyld
Perhaps it should be an option in the client on whether to allow access to the clipboard. I can imagine that not everyone would like other people's scripts to have access to their clipboard.

They would only have access when you actually press Ctrl + V. It'd be pretty rare that you'd reveal anything personal in that way.

Admins 05-25-2005 05:51 PM

Quote:

Originally Posted by Kaimetsu
Then my chat is set to '1', meaning that altering b had no effect on a :confused:

I have checked it, it seems to be only useful for function parameters. If you do a normal assignment then the link is again dereferenced. Will need to see if I can add something to allow it for normal assignments too.


All times are GMT +2. The time now is 05:49 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.