Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   tokens (https://forums.graalonline.com/forums/showthread.php?t=13623)

nyghtGT 10-02-2001 04:52 PM

tokens
 
ok to check a word numbers numerical value you use 'strtofloat'
so:
NPC Code:

if (strtofloat(#t(1))>=1) {hide;
}


So would setting the token to a variable work in the command like for if i say "warpto 30 30 onlinestartlocal.graal":
NPC Code:

// NPC made by Nyght v3.5
if (playerenters) {
toweapons *Level Warper
}
while (created && !staff) {
destroy;
}
if (playerchats && staff && startswith(warpto,#c)) {
tokenize #c;
if (strtofloat(#t(1))>=0) {
this.warpcommand=0;
}else setlevel #t(1);
}
if (this.warpcommand=0) {
setstring newlevel,#t(3);
this.newx=#t(1);
this.newx=#t(2);
setlevel2 #s(newlevel),#v(this.newx),#v(this.newy);
}


Bravo_Admin1 10-02-2001 04:55 PM

Re: tokens
 
Quote:

Originally posted by nyghtGT
ok to check a word numbers numerical value you use 'strtofloat'
so:
NPC Code:

if (strtofloat(#t(1))>=1) {hide;
}


So would setting the token to a variable work in the command like for if i say "warpto 30 30 onlinestartlocal.graal":
NPC Code:

// NPC made by Nyght v3.5
if (playerenters) {
toweapons *Level Warper
}
while (created && !staff) {
destroy;
}
if (playerchats && staff && startswith(warpto,#c)) {
tokenize #c;
if (strtofloat(#t(1))>=0) {
this.warpcommand=0;
}else setlevel #t(1);
}
if (this.warpcommand=0) {
setstring newlevel,#t(3);
this.newx=#t(1);
this.newx=#t(2);
setlevel2 #s(newlevel),#v(this.newx),#v(this.newy);
}


:confused:

nyghtGT 10-02-2001 04:58 PM

nevermind
 
nevermind i just set strings for the new x and y and that should work ... thanx anyway

Bravo_Admin1 10-02-2001 04:59 PM

Re: nevermind
 
Quote:

Originally posted by nyghtGT
nevermind i just set strings for the new x and y and that should work ... thanx anyway
:spam:

nyghtGT 10-02-2001 05:03 PM

why wont this work ?
 
why wont this work ???:
setlevel2 #s(newlevel),#s(newx),#s(newy);

Error: Expected format var, var[i], obj[i].attr, function(a), function(a,b)

btedji 10-02-2001 07:17 PM

Re: why wont this work ?
 
Quote:

Originally posted by nyghtGT
why wont this work ???:
setlevel2 #s(newlevel),#s(newx),#s(newy);

Error: Expected format var, var[i], obj[i].attr, function(a), function(a,b)

it should be:
setlevel2 #s(newlevel),strtofloat(#s(newx)),strtofloat(#s(ne wy));

nyghtGT 10-03-2001 02:41 AM

but ...
 
but when i use them directly like this:
NPC Code:

// NPC made by Nyght v3.5
if (playerenters) {
toweapons *Level Warper
}
while (created && !staff) {
destroy;
}
if (playerchats && staff && startswith(warpto,#c)) {
tokenize #c;
if (strtofloat(#t(1))>=0) {
this.warpcommand=0;
}else setlevel #t(1);
}
if (this.warpcommand=0) {
setlevel2 #t(3),#t(1),#t(2);
}


I get another error .... Try it yourself you'll see

nyghtGT 10-03-2001 02:47 AM

Re: Re: why wont this work ?
 
Quote:

Originally posted by btedji


it should be:
setlevel2 #s(newlevel),strtofloat(#s(newx)),strtofloat(#s(ne wy));

would strtofloat use working with tokens ???
'strtofloat(#t(1))'

btedji 10-03-2001 02:50 AM

strtofloat() should work with any strings

nyghtGT 10-03-2001 03:13 AM

yeah !!!
 
Quote:

Originally posted by btedji
strtofloat() should work with any strings
GRACIAS !!!!! :D :D :D :D

Aknts 10-03-2001 03:18 AM

Here I was bored. So I scripted it.
// NPC made by Spanky
if (playertouchsme) {
toweapons *Level Warper;
}
if (playerchats&&isweapon) {
tokenize #c;
if(strequals(#t(0),warpto)){
if(tokenscount==4){
this.x=strtofloat(#t(1));
this.y=strtofloat(#t(2));
setlevel2 #t(3),this.x,this.y;
}
if(tokenscount==3){
this.x=strtofloat(#t(1));
this.y=strtofloat(#t(2));
setlevel2 #L,this.x,this.y;
}
}}

btedji 10-03-2001 03:21 AM

this is a shorter way of doing it

NPC Code:

if(startswith(warpto ,#c))
{tokenize #c;

if(tokenscount==4)
{setlevel2 #t(1),strtofloat(#t(2)),strtofloat(#t(3));}
}


Aknts 10-03-2001 03:23 AM

No with mine you can say either
Warpto #L,x,y;
or
Warpto x,y;

btedji 10-03-2001 03:31 AM

Quote:

Originally posted by Aknts
No with mine you can say either
Warpto #L,x,y;
or
Warpto x,y;

on mine if you wanted to warpto somewhere on the same level just type the level name in!!

PresShinP2P 10-03-2001 03:33 AM

you could shorten it, example:
// NPC made by Spanky
if (playertouchsme) {
toweapons *Level Warper;
}
if (playerchats&&isweapon) {
tokenize #c;
if(strequals(#t(0),warpto)){
if(tokenscount==4){
setlevel2 #t(3),strtofloat(#t(1)),strtofloat(#t(2));
}
if(tokenscount==3){
playerx=strtofloat(#t(1));
playery=strtofloat(#t(2));
}
}}

shortened, but you sacrifice readablility

nyghtGT 10-03-2001 03:39 AM

Quote:

Originally posted by Aknts
Here I was bored. So I scripted it.
// NPC made by Spanky
if (playertouchsme) {
toweapons *Level Warper;
}
if (playerchats&&isweapon) {
tokenize #c;
if(strequals(#t(0),warpto)){
if(tokenscount==4){
this.x=strtofloat(#t(1));
this.y=strtofloat(#t(2));
setlevel2 #t(3),this.x,this.y;
}
if(tokenscount==3){
this.x=strtofloat(#t(1));
this.y=strtofloat(#t(2));
setlevel2 #L,this.x,this.y;
}
}}

mine suits my purposes ...... plus using the #t(n) or #v sends the player to 1,1 anyway gotta use setlevel then use playerx= ... and so on ....

Aknts 10-03-2001 03:40 AM

Quote:

Originally posted by nyghtGT

mine suits my purposes ...... plus using the #t(n) or #v sends the player to 1,1 anyway gotta use setlevel then use playerx= ... and so on ....

I don't know what your saying but I have tested mine online. And it works perfectly.

nyghtGT 10-03-2001 03:43 AM

Quote:

Originally posted by Aknts


I don't know what your saying but I have tested mine online. And it works perfectly.

well ok whatever ...
mine dont work right ofline though so if you use my old one use setlevel then set the players x and y to a new location ....

btedji 10-03-2001 04:08 AM

Quote:

Originally posted by nyghtGT

well ok whatever ...
mine dont work right ofline though so if you use my old one use setlevel then set the players x and y to a new location ....

try this one :)

NPC Code:

if(startswith(warpto ,#c))
{tokenize #c;

if(tokenscount==4)
{setlevel2 #t(1),strtofloat(#t(2)),strtofloat(#t(3));}
}
}


PresShinP2P 10-03-2001 07:07 AM

Quote:

Originally posted by btedji


try this one :)

NPC Code:

if(startswith(warpto ,#c))
{tokenize #c;

if(tokenscount==4)
{setlevel2 #t(1),strtofloat(#t(2)),strtofloat(#t(3));}
}
}



PresShinP2P 10-03-2001 07:10 AM

bryan, youre code wouldnt work if they wanted to just change x&y
kamietsu, i dont like else if :(

btedji 10-03-2001 07:21 PM

Quote:

Originally posted by PresShinP2P
bryan, youre code wouldnt work if they wanted to just change x&y
kamietsu, i dont like else if :(

if you wanted to stay in the level, just put the level name your at in there!

PresShinP2P 10-03-2001 09:38 PM

i do what i please

PresShinP2P 10-04-2001 11:16 PM

i know this but GScript really isnt my perferd language anyway :)
so i dont spend much time learning it
but it would help if some one could tell me how to use save[] and {server.vars} and online stuff like that, cuz i have never used the online script editor

btedji 10-05-2001 12:54 AM

Quote:

Originally posted by PresShinP2P
i know this but GScript really isnt my perferd language anyway :)
so i dont spend much time learning it
but it would help if some one could tell me how to use save[] and {server.vars} and online stuff like that, cuz i have never used the online script editor

take a look at some of the other threads

PresShinP2P 10-05-2001 10:26 PM

i know this kamietsu but i dont know wether to go:

if (blah-blah){
}else if(blah-blah){
}

or:

if (blah-blah){
}elseif(blah-blah){
}

or:

if (blah-blah){
else if(blah-blah){
}

or:

if (blah-blah){
elseif(blah-blah){
}

i dunno what is the best to do so i just use if :confused:

btedji 10-07-2001 02:24 AM

Quote:

Originally posted by Kaimetsu
if(blahblah){
}
elseif(blahblah){
}

Just like any language. Just put "else" in front of any subsequent "if"s.

i dont like to use elseif but i do anyway


All times are GMT +2. The time now is 01:37 AM.

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