Author Topic: Heads/Tails and Random Letter Scripts...  (Read 1850 times)

0 Members and 1 Guest are viewing this topic.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Heads/Tails and Random Letter Scripts...
« on: October 16, 2007, 12:40:13 pm »
Code: [Select]
function HorT(const Heads: variant; const Tails: variant):variant;
var
  Flip: integer;
begin
  Flip:=Random(0, 1);
  if Flip = 0 then Result:=Heads;
  if Flip = 1 then Result:=Tails;
end;

kinda easy script, it's the heads/tails, I think it works...

as for Random Letter, I think there is an easier way to do it then to make 78 "if then" 's
if there is an easier way, please tell me...
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Hydro

  • Major(1)
  • Posts: 31
Re: Heads/Tails and Random Letter Scripts...
« Reply #1 on: October 16, 2007, 02:02:12 pm »
Code: [Select]
var
   Flip, Flip2: integer;
   x: byte;
   letter:=string; //or char
begin
   Flip:=Random(65,90); // big letters
   Flip2:=Random(97,122); // small letters
   x:=Random(0,1);
   if x = 0 then letter:=chr(Flip);
   if x = 1 then letter:=chr(Flip2);
end;

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Heads/Tails and Random Letter Scripts...
« Reply #2 on: October 16, 2007, 05:13:52 pm »
what are the characters between chr(90) and chr(97) ?

Code: [Select]
function RLetter(const Type: integer):string;
var
  Rand: integer;
begin
  if Type = 0 then Rand:=Random(65,122);
  if Type = 1 then Rand:=Random(65,90);
  if Type = 2 then Rand:=Random(97,122);
  if (Rand < 91) or (Rand > 96) then Result:=Rand;
end;
does this work?
« Last Edit: October 16, 2007, 05:17:42 pm by Kavukamari »
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Hydro

  • Major(1)
  • Posts: 31
Re: Heads/Tails and Random Letter Scripts...
« Reply #3 on: October 18, 2007, 12:20:14 am »
91 [
92 \
93 ]
94 ^
95 _
96 `
Code: [Select]
if ((Rand < 91) or (Rand > 96)) then Result:=Rand;not
Code: [Select]
if (Rand < 91) or (Rand > 96) then Result:=Rand;

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Heads/Tails and Random Letter Scripts...
« Reply #4 on: October 18, 2007, 12:35:10 pm »
what's difference? (will change anyway)

Date Posted: October 18, 2007, 01:32:39 pm
P.S. would you like to help me with my Kills log script? it needs commands to list the kills (in a way that they are not one per line :P)
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Snipufin

  • Camper
  • ***
  • Posts: 281
Re: Heads/Tails and Random Letter Scripts...
« Reply #5 on: October 19, 2007, 09:47:10 am »
what's difference? (will change anyway)
difference: ((blablabla) or (blabla)) will make the IF correspond both blablabla and blabla
Quote
Name:     Snipufin
Posts:    111 (1.11 per day)
Position:    Soldier
Karma:    -11