Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-03-2006, 12:51 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
alright how does it work

I see people say prefix.("varname" @ temp.towahth @ "wejthakwlh") = 1;

If this doesn't have anything to do with what I'm about to ask then just pretend I didn't metion it and answer the question anyway:


When you want to declare a value/assign/whatever... nevermind how do I do this:

this.thisismyvarONE = the variable I that I want to edit.

this.varname = "ONE";
this.("thisismyvar" @ this.varname) = 1;


^ please explain how to do because I'm doing it wrong apparently.
Reply With Quote
  #2  
Old 10-03-2006, 02:04 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
What you're doing should work.
Reply With Quote
  #3  
Old 10-04-2006, 05:38 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You could also do this..
PHP Code:
function onCreated() {
 
this.varname "ONE";
 
makevar("this." this.varname) = 1;
 
chat "this.ONE =" SPC this.ONE;

Its just a matter of personal preference I guess..
__________________
Quote:
Reply With Quote
  #4  
Old 10-04-2006, 08:20 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by fowlplay4 View Post
You could also do this..
PHP Code:
function onCreated() {
 
this.varname "ONE";
 
makevar("this." this.varname) = 1;
 
chat "this.ONE =" SPC this.ONE;

Its just a matter of personal preference I guess..
Indeed it is, I'm starting to use makevar, however I prefer to use this.("blah" @ LOLDIE); =(
__________________
Reply With Quote
  #5  
Old 10-04-2006, 09:11 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xAndrewx View Post
Indeed it is, I'm starting to use makevar, however I prefer to use this.("blah" @ LOLDIE); =(
makevar() is untidy and I strongly dislike it when people use it. this.(@ foo) = bar; is the best way in my opinion.
Reply With Quote
  #6  
Old 10-04-2006, 09:37 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
Quote:
Originally Posted by Skyld View Post
this.(@ foo) = bar;

So if I'm going to start the variable's name with the value of another variable, I need to use the @ sign to start it off?

this.(@ varname) = value;
Reply With Quote
  #7  
Old 10-04-2006, 12:36 PM
The Evil Within The Evil Within is offline
I'm Not Chance...Really
The Evil Within's Avatar
Join Date: Aug 2004
Location: Coral Springs, Florida
Posts: 65
The Evil Within is on a distinguished road
Send a message via AIM to The Evil Within
I was on RC when you posted this...why didn't you just ask me? Loser.

Although you wouldn't have gotten as good help, I actually like the way Skyld has it formatted better.
__________________
-CMercy

Delteria Forums
Reply With Quote
  #8  
Old 10-04-2006, 04:46 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by _Z3phyr_ View Post
So if I'm going to start the variable's name with the value of another variable, I need to use the @ sign to start it off?

this.(@ varname) = value;
I think you only need it for a variable name only or if a variable name is first.
PHP Code:
this.(@ foo "bar") = baz
However, I do it out of habit even when a string is first. It is probably good practice for consistency and legibility.
Reply With Quote
  #9  
Old 10-05-2006, 12:58 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
I dunno why people are using makevar
-longer too write
-looks more complicated if you ask me, but isn't

PHP Code:
//#CLIENTSIDE
function onCreated()
{
  
temp."lol";
  
temp.(@ temp."lipop") = "hmm?";
  
player.chat temp.lollipop;

is lesser to write then:
PHP Code:
//#CLIENTSIDE
function onCreated()
{
  
temp."lol";
  
makevar("temp." temp."lipop") = "hmm?";
  
player.chat temp.lollipop;

__________________
Reply With Quote
  #10  
Old 10-06-2006, 01:52 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Ive actually started to use makevar() instead of var.(more stuff) lately. I like it more now, and it feels more.. organized?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #11  
Old 10-07-2006, 01:01 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
*shrug* anyway instead of making a new thread how about I pose another question?

How does...
PHP Code:
if (playerleaves) { 
... translate into GS2?

I know it ain't
PHP Code:
function onPlayerleaves() { 
so what is it?!
Reply With Quote
  #12  
Old 10-07-2006, 05:35 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by xXziroXx View Post
Ive actually started to use makevar() instead of var.(more stuff) lately. I like it more now, and it feels more.. organized?
I always did var.(@ some @ "thing") but when i saw makevar() I thought i was doing it the wrong way
Reply With Quote
  #13  
Old 10-09-2006, 11:26 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
So... >_>
Reply With Quote
  #14  
Old 10-19-2006, 01:20 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
*9 days later*
You guys suck
Reply With Quote
  #15  
Old 10-19-2006, 02:14 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
nobody knows....
Reply With Quote
  #16  
Old 10-19-2006, 09:22 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Playerleaves doesnt exist in GS2, but its not hard to script your own version.


PHP Code:
//#CLIENTSIDE
function onPlayerEnters()
{
  if (
player.level != this.levelname && this.levelname != NULL) {
    
//Oh my gosh, the player changed level!
  
}
  
this.levelname player.level;

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 10-19-2006, 09:33 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
player.level.name.
Reply With Quote
  #18  
Old 10-19-2006, 09:51 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Skyld View Post
player.level.name.
*whistles*
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #19  
Old 10-19-2006, 02:33 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
onPlayerLeaves() should work fine, you are sure it is broken ?
Reply With Quote
  #20  
Old 10-19-2006, 02:40 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Stefan View Post
onPlayerLeaves() should work fine, you are sure it is broken ?
Its not even listed on the Wiki.. only the gs1 version of it is.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #21  
Old 10-20-2006, 09:11 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
apparently it doesn't work.


Anyway lets see if yall can redeem yourselves...

Tell me what I did wrong here. Assume temp.entry is a string and that all arrays and/or variables have been declared before this script comes into play.

PHP Code:
    for (i=1;i<=13;i++) {
  if (
server.arrayprefix_(temp.entry "Suffix")[i]!=null) {
    if (
client.array[i]>=server.arrayprefix_(temp.entry "Suffix")[i]) { 

I've tried saying (@temp.entry@"Suffix") but that doens't work either. If that's the correct answer then maybe I mistyped something.



edit
and yes I know I can jsut say server.array >= client.array but that doesn't answer my question.
Reply With Quote
  #22  
Old 10-20-2006, 09:48 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally Posted by Stefan View Post
onPlayerLeaves() should work fine, you are sure it is broken ?
It works fine.

Quote:
Originally Posted by _Z3phyr_ View Post
apparently it doesn't work.


Anyway lets see if yall can redeem yourselves...

Tell me what I did wrong here. Assume temp.entry is a string and that all arrays and/or variables have been declared before this script comes into play.

PHP Code:
    for (i=1;i<=13;i++) {
  if (
server.arrayprefix_(temp.entry "Suffix")[i]!=null) {
    if (
client.array[i]>=server.arrayprefix_(temp.entry "Suffix")[i]) { 

I've tried saying (@temp.entry@"Suffix") but that doens't work either. If that's the correct answer then maybe I mistyped something.



edit
and yes I know I can jsut say server.array >= client.array but that doesn't answer my question.
You would want to do server.("arrayprefix_" @ temp.entry @ "Suffix")[i].
Reply With Quote
  #23  
Old 10-20-2006, 10:01 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
Roger dodger.
Reply With Quote
  #24  
Old 12-19-2006, 12:24 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
Okay and now how do you translate if (mousedown) to GS2 aka if (leftmousebutton) ?
Reply With Quote
  #25  
Old 12-19-2006, 01:31 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by _Z3phyr_ View Post
Okay and now how do you translate if (mousedown) to GS2 aka if (leftmousebutton) ?
PHP Code:
//#CLIENTSIDE
function onMouseDown() {
 switch(
params[0]) {
  case 
"left"
  case 
"right":
  case 
"middle":
  case 
"double"player.chat "You have just pressed the " params[0] @ " mouse button!"; break;
 }


Last edited by Gambet; 12-19-2006 at 01:49 AM..
Reply With Quote
  #26  
Old 12-20-2006, 01:21 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
lolz hey again yall I need help with this thing will you please help me??? how do you do this but make it work b/c something is wrong
PHP Code:
function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);


Last edited by _Z3phyr_; 12-20-2006 at 03:36 PM.. Reason: gambet expects me to bow before his skillz or he won't help so I have no choice
Reply With Quote
  #27  
Old 12-20-2006, 01:42 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by _Z3phyr_ View Post
dirty showoffs... let's see you show me how to do this


How to make player move in a direction (equivalent to move() command except player instead of NPC)

and don't say
PHP Code:
function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);


Or why don't you stop trying to hide the fact that you're asking for scripts instead of your little "let's see you show me how to do this" scam?

If you need help, ask, like a normal person.
Reply With Quote
  #28  
Old 12-20-2006, 09:36 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by Gambet View Post
Or why don't you stop trying to hide the fact that you're asking for scripts instead of your little "let's see you show me how to do this" scam?
Wow what in the world are you on, its obvious he is asking for help with scripts.

Quote:
If you need help, ask, like a normal person.
It appears its normal for him to ask in those more interesting ways just as its normal for you to critisize and arugue with everyone you come in contact with.
Reply With Quote
  #29  
Old 12-20-2006, 07:07 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
quite


anyway, what's the answer again?
Reply With Quote
  #30  
Old 12-20-2006, 08:31 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by _Z3phyr_ View Post
quite


anyway, what's the answer again?
Quote:
Originally Posted by _Z3phyr_ View Post
PHP Code:
function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);

That would increase the player's x with 0, then by 1, and then by 2..

You could try to add a speed variable, instead of adding the variable of the loop, which is being increased,
(because of the loop speed it would be like, 2 forward, then 1, then 2 forward and 1 forward, would look weird)

To make something near the move() command, but to effect the player, I would use cos, sin and getangle
__________________
Reply With Quote
  #31  
Old 12-20-2006, 10:00 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Andy0687 View Post
Rambling


I don't know what his intentions were, but he put it off as a challenge. Sort of like seeing if people know how to do something, without doing it the way he's done it.

That's the only reason I responded the way I did, else, I'd be glad to help.
Reply With Quote
  #32  
Old 12-20-2006, 11:49 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
This stuff
PHP Code:
function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);

only moves me by whatever i is set to (in this case 0 tiles), so it doesn't work (I said it because it doesn't work -- as a tip that its not the right answer).

And how about an answer in GS2? English doesn't really help me.
Reply With Quote
  #33  
Old 12-28-2006, 04:00 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by _Z3phyr_ View Post
*shrug* anyway instead of making a new thread how about I pose another question?

How does...
PHP Code:
if (playerleaves) { 
... translate into GS2?

I know it ain't
PHP Code:
function onPlayerleaves() { 
so what is it?!
Since GS2 is function onEVENTNAME(params) {

It would be

PHP Code:
function onPlayerLeaves() {
// ...

Quote:
Originally Posted by _Z3phyr_ View Post
I know it ain't
PHP Code:
function onPlayerleaves() { 
It has to be :P
Playerleaves is an event, and read above :P
Reply With Quote
  #34  
Old 01-08-2007, 09:59 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by _Z3phyr_ View Post
This stuff
PHP Code:
function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);

only moves me by whatever i is set to (in this case 0 tiles), so it doesn't work (I said it because it doesn't work -- as a tip that its not the right answer).

And how about an answer in GS2? English doesn't really help me.
Why not just do a for loop that increses the player's X position?

Example:

PHP Code:
function onPlayerTouchsMe()
{

  for ( 
0<= 2i++ )
  {

    
player.x++;

  }


Makes much more sense
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:51 AM.


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