Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-25-2002, 03:23 AM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
defining script from string

Ok heres the deal:

1) I set a string like this:

setstring client.Test,##v(this.test)##s(client.Test2);

2) It looks like this in the flag list:

client.Test=#v(this.test)#s(client.Test2)

3) The variable this.test has a value of lets say 5
and string client.Test2=blah

4) I want this code to make it show 5blah
not #v(this.test)#s(client.Test2):

setplayerprop #c,#s(client.Test);

How can I get that to work right, and I have to have it in the string like that so that it will show the current value in the variables and strings
Reply With Quote
  #2  
Old 02-25-2002, 03:28 AM
Goboom Goboom is offline
Pixel Monkey
Goboom's Avatar
Join Date: Dec 2001
Location: Michigan
Posts: 1,702
Goboom is on a distinguished road
Send a message via ICQ to Goboom Send a message via AIM to Goboom Send a message via MSN to Goboom Send a message via Yahoo to Goboom
are you talking about something like this????
NPC Code:

client.test=strtofloat(#s(test));
client.test++;
setstring test,#v(client.test);


didnt understad question that well
__________________
Reply With Quote
  #3  
Old 02-25-2002, 03:34 AM
Faheria_GP2 Faheria_GP2 is offline
Banned
Faheria_GP2's Avatar
Join Date: Oct 2001
Posts: 1,177
Faheria_GP2 is on a distinguished road
he wants message codes to be parsed for message codes...

like if #c contains the chat "#s(***)", #c would read the value of string ***, not literally "#s(***), origianally it was like this, but it caused issues back in 1.31, so message codes no longer act like this
Reply With Quote
  #4  
Old 02-25-2002, 03:36 AM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
like this

NPC Code:

if(playerenters){
timeout=0.05
this.test=5;
setstring client.test,##v(this.test);
}

if(timeout){
timeout=0.05;
this.test++;
setplayerprop #c,#s(client.test);
}




the players text should always show the current value of this.test

dont know how to get that to work right
Reply With Quote
  #5  
Old 02-25-2002, 03:50 AM
Faheria_GP2 Faheria_GP2 is offline
Banned
Faheria_GP2's Avatar
Join Date: Oct 2001
Posts: 1,177
Faheria_GP2 is on a distinguished road
you cant put a message code in a message code

end of story

close thread
Reply With Quote
  #6  
Old 02-25-2002, 03:52 AM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Quote:
Originally posted by Faheria_GP2
you cant put a message code in a message code

end of story

close thread
Nested message codes are allowed, just if message codes from strings cant be used inside other message codes, then it should be a future improvement
Reply With Quote
  #7  
Old 02-25-2002, 03:56 AM
Faheria_GP2 Faheria_GP2 is offline
Banned
Faheria_GP2's Avatar
Join Date: Oct 2001
Posts: 1,177
Faheria_GP2 is on a distinguished road
Quote:
Originally posted by btedji


Nested message codes are allowed, just if message codes from strings cant be used inside other message codes, then it should be a future improvement
nested mesage codes are allowed?

so when #c is #f, then #c is door.gif? no, people were abusing it, so it was "fixed" in version 1.38 or so
Reply With Quote
  #8  
Old 02-25-2002, 05:44 AM
joseyisleet joseyisleet is offline
Registered User
Join Date: Aug 2001
Posts: 378
joseyisleet is on a distinguished road
-=Josey=-
I forgot how to do this whenever I left and came back, but a friend helped me out again.

NPC Code:

if (created||playerenters){
setstring client.test,5;
timeout=.05;
}
if (timeout){
message # strtofloat(#s(client.test));
timeout=.05;
}

__________________
Account used by Josey and Howard.
Ali G: 'Is it cause i Black?'
Reply With Quote
  #9  
Old 02-25-2002, 05:46 AM
joseyisleet joseyisleet is offline
Registered User
Join Date: Aug 2001
Posts: 378
joseyisleet is on a distinguished road
-=Josey=-
Oh yeah, use something like :
setstring client.test, strtofloat(#s(client.test))+1;

I do believe that should work.
__________________
Account used by Josey and Howard.
Ali G: 'Is it cause i Black?'
Reply With Quote
  #10  
Old 02-25-2002, 06:00 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by joseyisleet
-=Josey=-
Oh yeah, use something like :
setstring client.test, strtofloat(#s(client.test))+1;

I do believe that should work.
setstring client.test, #v(strtofloat(#s(client.test))+1);

Reply With Quote
  #11  
Old 02-25-2002, 08:20 PM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Bah! Guess i'll have to change my script, oh well
Reply With Quote
  #12  
Old 02-25-2002, 09:59 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
It would be possible to support it
(the message code stuff is currently parsed
at runtime, but only the first time it is seen).
Problem is that this would crash Graal if
it's producing an endless loop, and people always
do scripting errors, so it's not supported.
Reply With Quote
  #13  
Old 02-25-2002, 10:04 PM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Why would that crash graal, is it a overflow issue?

You should just limit the number of times it can loop, could that work?
Reply With Quote
  #14  
Old 02-25-2002, 10:26 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
Hmm actually if we add a new message code
like #M (to decode a message code) or so then it could
work, then you would only need to keep care that
there is no #M in the string. But I don't know if this
is really needed, it will be hard to support in the new
scripting engine we are planning
Reply With Quote
  #15  
Old 02-25-2002, 10:32 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
Quote:
Originally posted by Kaimetsu

But Stefan, when Graal turns scripts into bytecode, doesn't it lose the variable names and replace them with arbitrary tokens?
Yes somethign like that. It will probably still use variable
names, but with fast lookup, and the message codes
will be pre-parsed so such a recursive message code will
not work.
Reply With Quote
  #16  
Old 02-26-2002, 12:09 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Re: defining script from string

i am not sure, but couldn't you do something like setting them over time?
setstring client.Test,#;
client.Test,#s(client.Test)#v(this.test);
client.Test,#s(client.Test)#;
client.Test,#s(client.Test)#s(client.Test2);
or is # too much of a keyword? There has to be soime way.
Quote:
2) It looks like this in the flag list:

client.Test=#v(this.test)#s(client.Test2)
thats cause it is setting the setting...there really should be some sort of escape characters with graal. Just to reduce it for simpletons.

Quote:
Originally posted by Kaimetsu


I'm guessing things like:

string1=#s(string1)
message #s(string1);
      ^ thats sick man!

I suppose strings are different, since their full names are stored in the flag list, but it could never work for variables, could it?
wouldn't it be stored in an array i believe
char* stringnames[] = {"string"};
char* stringvalue[] = {"value"};
no, probably structs would work better.

Quote:
Originally posted by Kaimetsu

Personally I'd be against it one way or another. It goes against the principles of "real" programming and introduces lots of behind-the-scenes icky stuff.
yes i agree.
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #17  
Old 02-26-2002, 04:54 AM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Quote:
Originally posted by Kaimetsu


I'm guessing things like:

string1=#s(string1)
message #s(string1);

It'd say "Oh, okay, so we'll go look in string1 for the correct value. Oh, alright, string1 points us to string1, so we'll go look there. Oh, alright, string1 points us to..." until it exploded. And obviously this is just a simple example. There are much more complicated possibilities, some of which wouldn't be intuitively obvious.

Personally I'd be against it one way or another. It goes against the principles of "real" programming and introduces lots of behind-the-scenes icky stuff.

But Stefan, when Graal turns scripts into bytecode, doesn't it lose the variable names and replace them with arbitrary tokens? So surely you wouldn't be able to construct a variable's name from strings and still expect it to point to the right place in memory, since the variable name doesn't mean anything anymore? I suppose strings are different, since their full names are stored in the flag list, but it could never work for variables, could it?
Add a timeout our somethin, like say if it loops for 15 seconds or 15 times without a result then cancel the command and go to the next
Reply With Quote
  #18  
Old 02-26-2002, 05:52 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by Kaimetsu


But Stefan, when Graal turns scripts into bytecode, doesn't it lose the variable names and replace them with arbitrary tokens? So surely you wouldn't be able to construct a variable's name from strings and still expect it to point to the right place in memory, since the variable name doesn't mean anything anymore? I suppose strings are different, since their full names are stored in the flag list, but it could never work for variables, could it?
Kai, you scare me ...
Reply With Quote
  #19  
Old 02-27-2002, 09:17 PM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Quote:
Originally posted by Kaimetsu


Workarounds, workarounds, workarounds. You can script whatever you want now, why do you need this extra method?
For super easy customization of a script im making, I have a workaround on it right now, but its not the way I would like it
Reply With Quote
  #20  
Old 02-27-2002, 10:21 PM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Quote:
Originally posted by Kaimetsu


Not to seem harsh, but it seems pointless. It'd probably be slower than the current way anyway.
it would indeed be slower...
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #21  
Old 02-28-2002, 08:02 AM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
bah, i doubt the way i used it, that it would be any slower, oh well
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 01:40 AM.


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