Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Old Scripting Engine (GS1) (https://forums.graalonline.com/forums/forumdisplay.php?f=154)
-   -   Random Scripts (https://forums.graalonline.com/forums/showthread.php?t=74108)

sam_is_me 05-21-2007 05:46 PM

Random Scripts
 
So, since I have to do this offline, its in gs1. I need to figure out how to put a random script, instead of numbers, into names. heres what I have so far:
NPC Code:

if(playerchats && strequals(#c,:choose)){
setcharprop #c,var(int(random(1,5)));
sleep1;
message ;
}



If that's wrong, sorry, I'm trying to remember what I have, and GraalEditor isnt working at the moment, but yeah, i have a working random number script tiggered by the player saying :choose..

But how do I assign numbers to NAMES, do I use flags, or what...
:]
thanks

DustyPorViva 05-21-2007 07:49 PM

PHP Code:

if (playerchats && strequals(#c,:choose)) {
  
tokenize "Hello World!" "Boo ya!" "Whoop whoop." ":D";
  
setplayerprop #c,#t(int(random(0,tokenscount)));



Deadly_Killer 05-21-2007 08:08 PM

You should not overload your event-statements

PHP Code:

if (playerchats)
{
  if (
strequals(#c,:choose))
  
{
    
// etc
  
}



DustyPorViva 05-21-2007 08:12 PM

You say it with such enthusiasm as though he's going to break something. It's preference really, and as they're highly related, I don't see the problem.

Deadly_Killer 05-21-2007 08:21 PM

http://forums.graal2001.com/forums/s...ad.php?t=46557

DustyPorViva 05-21-2007 08:42 PM

Funny you should post that:
"Similarly to rule three, do not combine unrelated conditional statements. Instead of writing shambling messes like this:"

sam_is_me 05-22-2007 04:36 AM

What does the 0,Tokenscount
do?
I dont know what they stand for..
Everything else I get.

DustyPorViva 05-22-2007 04:55 AM

That would be the random statement, getting a random chunk of text. 0 would be the minimum, and tokenscount would be the max(tokenscount is the number of tokens when using tokenize).

Rapidwolve 05-22-2007 06:03 AM

Quote:

Originally Posted by sam_is_me (Post 1310515)
What does the 0,Tokenscount
do?
I dont know what they stand for..
Everything else I get.

0, tokenscount.

Heres a tip, you must ALWAYS pay attention to comma's (unless they are wrapped in quotes)

Deadly_Killer 05-22-2007 06:08 AM

Aren't you supposed to do tokenscount + 1? ( random shouldn't pick the highest number)

Or does tokenscount not start with 0?

sam_is_me 05-22-2007 05:35 PM

Oh, I get it.
Couldn't you use
tokenscount,tokenscount
though?

DustyPorViva 05-22-2007 05:57 PM

tokenscount doesn't start with 0, because it's giving you the actual number of tokens, so if you have four words, it will return 4.
And tokenscount,tokenscount wouldn't work because it'd always pick the last option for text. You used the same method in your script as well. I want to pick between the first text, and the last, randomly. 0-tokenscount means it will randomly pick between the first token and the last.

zokemon 05-22-2007 06:00 PM

Quote:

Originally Posted by sam_is_me (Post 1310676)
Oh, I get it.
Couldn't you use
tokenscount,tokenscount
though?

Thats like saying random(1, 1)
As stated, the 0 is the minimum meaning it is the lowest possible number to be rolled.
tokenscount is the maximum meaning it is the highest number (actually, random never "reaches" the highest number, it just comes close).

DustyPorViva 05-22-2007 06:07 PM

Quote:

Originally Posted by zokemon (Post 1310681)
(actually, random never "reaches" the highest number, it just comes close).

I know, sucks :/

zokemon 05-22-2007 06:10 PM

Quote:

Originally Posted by DustyPorViva (Post 1310684)
I know, sucks :/

I find that to be a good thing when you are dealing with intergers. There used to be a glitch where it could possibly reach the maximum value which screwed up alot of random intergers.


All times are GMT +2. The time now is 05:30 AM.

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