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 08-18-2008, 12:22 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Help with random texts

Trying to test my GUI skills, since I haven't for a LONG time.
So I have a confirmation code that is supposed to come out random from 3 sets of letters/numbers. I have all of those as this.beg, this.mid, this.end and I set up the temp.confCode as follows
PHP Code:
temp.confCode int(random(this.beg11)) @ int(random(this.mid9)) @ int(random(this.end11)); 
When I go on player and try to use it, the GUI comes up and everything's fine, but it's coming out as numbers.
One example is "035"
How can I get it to display as TEXT?

And on a side note:
How do I set text to save as a log/*.txt file from a serverside script?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #2  
Old 08-18-2008, 12:37 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
If I remember correctly, random(start, end) will only return a random number within [start, end)

It's a bit different to generate a random character. Here's one way to generate a random upper-case letter:
PHP Code:
char(int(random(6591))); 
You can look at an ascii table to see where I get the 65 and 91 from. You could also look at an ascii table to get the ranges for lower-case letters.

Or, you could predefine an array of all the characters you want to include in your random strings, then use randomstring().
Example:
PHP Code:
temp.chars = {"A""B""C""D""a"123};  //Put all characters in here.
temp.confCode randomstring(temp.chars) @ randomstring(temp.chars) @ randomstring(temp.chars); 
And, to save as a log/*.txt file you can use savelog2
Example:
PHP Code:
savelog2("snaps.txt""The boy bought the basketball"); 
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #3  
Old 08-18-2008, 01:04 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by napo_p2p View Post
If I remember correctly, random(start, end) will only return a random number within [start, end)

It's a bit different to generate a random character. Here's one way to generate a random upper-case letter:
PHP Code:
char(int(random(6591))); 
You can look at an ascii table to see where I get the 65 and 91 from. You could also look at an ascii table to get the ranges for lower-case letters.

Or, you could predefine an array of all the characters you want to include in your random strings, then use randomstring().
Example:
PHP Code:
temp.chars = {"A""B""C""D""a"123};  //Put all characters in here.
temp.confCode randomstring(temp.chars) @ randomstring(temp.chars) @ randomstring(temp.chars); 
And, to save as a log/*.txt file you can use savelog2
Example:
PHP Code:
savelog2("snaps.txt""The boy bought the basketball"); 
Ah, thanks a lot
++rep if i could. gotta spread

edit: I did temp.confCode=randomString(this.beg) etc., and it didn't work.
It shows up as blank in the GUI.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #4  
Old 08-18-2008, 02:09 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Switch View Post
edit: I did temp.confCode=randomString(this.beg) etc., and it didn't work.
It shows up as blank in the GUI.
What is in this.beg?

randomstring() takes in an array of strings and outputs a random element.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 08-18-2008, 02:10 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
PHP Code:
  this.beg = { "iA""Pq""oa""cQ""Vu""zC""Gd""jE",
    
"aT""fg""io""mv" };
  
this.mid = { 123456789};
  
this.end = { "io""vb""cH""pA""oA""oa""ua""Ac",
    
"iA""Co""Op""In" }; 
That's all the arrays I'm using.

Edit:
Found the problem!
Had to use thiso.confCode inside of the GuiMLTextCtrl, and put the randomize setter outside of the GUI.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 08-18-2008 at 02:22 AM..
Reply With Quote
  #6  
Old 08-21-2008, 12:12 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
just so its out there, you can also savelog2 folder types [always give the NPC server additional rights though!]

savelog2("items/hugeasslog.txt", "wurr");
savelog2("staff/xAndrewx", "hot damn");

etc
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 02:45 PM.


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