SRL Archive - Outdated Tutorials

Randoms And If...Thens Put Together


turkeyidfool

2007-07-06 18:24:39

*~How To Make The Simple Script~*


Okay Ima try to make this as simple as possible.
In order to set randoms you need to know a little about Variables.
In order to create if…then you need to know a little about over all scripting.

if you a newb then GO TO A NEWBIE TUT UNTIL YOU KNOW THIS CRAP:duh:

RANDOMS AND IF…THENS TOGETHER


So lets say you need to decide who will be the one who jumps in the river butt naked. So you and your buddies write your name down on sheets of paper and toss them into a baggie. You shake up the baggie and you draw a name. That is basicly what I am going to teach you to do all except you will learn how to tell your SCAR program to do it for you.

Okay now ima put in a simplified version of my script. [Ima post the whole thing in the other scripts section;) )

My MonkeyButt Script
And the script is not made by drunken wutever.. i don't rlly get why it duz that…


program MonkeyButt;

var
MonkeyButt: integer;

begin

MonkeyButt:= Random(8)

if(MonkeyButt = 0)then
WriteLN('Joe Is The Monkey Butt!')
else
WriteLN('Joe Is Not The Monkey Butt And');

if(MonkeyButt = 1)then
WriteLN('Billy Bob Is!');

if(MonkeyButt = 2)then
WriteLN('Bobby Ray Is!');

if(MonkeyButt = 3)then
WriteLN('Billey Jean Is!');

if(MonkeyButt = 4)then
WriteLN('Bo Jangles Is!');

if(MonkeyButt = 5)then
WriteLN('Eric Is!');

if(MonkeyButt = 6)then
WriteLN('Fez Is!')

if(MonkeyButt = 7)then
WriteLN('Everyone Else Is!!! Muahahahahahahahahahahaa!!!!')
end.

What this script does is determine who is the MonkeyButt(Duh). Lets take a look at it.
There is a variable called "monkeybutt" and it has been declared as an integer(number)

MonkeyButt is declared as a random. Being labeled as a "random(8)" means that scar will randomly make it worth any one of the numbers 0 through 7.

Then there is a ton of if then statement where it says that if monkeybutt equals a certain number then write whatever it says to beneath it.

And there's also a cleardebug command but that only clears the debug box so i doesn't get crowded. I hate it when the debug box gets crowded:duh:

So lets say you wanted to make a script that answered a yes or no question.

you would start off:


program New;

var YesOrNo: Integer;

begin;

YesOrNo:= Random(2)

If(YesOrNo = 0)then
WriteLN('Yes')

if(YesOrNo = 1)then
WriteLN('No')

end.
and if you like you can add "cleardebug" under begin, too. that way it loox better :D

So that pretty much covered randoms and if thens that are rigged to randoms.

Rep me if i helped and search for my skript in the "other scripts" section!
And if you can't find any good beginner scar TUTs:google:

3Garrett3

2007-07-08 17:43:31

Immature much? Monkeybutt? Real cool…

Ps- this is definately not for intermediates…

BobboHobbo

2007-07-08 21:26:53

Yea this doesnt seem to intermediatish. Should go in begginers, but very well explained.

joerobo

2007-07-24 16:31:18

sorry if this is a slight bump :duh: … what about using case instead, all the 'ifs' look very clumsy.

WhiteShadow

2007-07-24 17:21:19

*~How To Make The Simple Script~*

Should be:

How To Make A Simple Script

Scar script tags were created by DrunkenOldMa.

Standards, please.

program MonkeyButt;

var
MonkeyButt: integer;

begin
MonkeyButt:= random(8)
if(MonkeyButt = 0)then
Writeln('Joe Is The Monkey Butt!')
else
Writeln('Joe Is Not The Monkey Butt And');
if(MonkeyButt = 1)then
Writeln('Billy Bob Is!');
if(MonkeyButt = 2)then
Writeln('Bobby Ray Is!');
if(MonkeyButt = 3)then
Writeln('Billey Jean Is!');
if(MonkeyButt = 4)then
Writeln('Bo Jangles Is!');
if(MonkeyButt = 5)then
Writeln('Eric Is!');
if(MonkeyButt = 6)then
Writeln('Fez Is!')
if(MonkeyButt = 7)then
Writeln('Everyone Else Is!!! Muahahahahahahahahahahaa!!!!')
end.
You could've used a different example. Using so many if-then's is so nubby. :]

Try:
const
PeoplePlaying = 8;
var
Monkeybutt, i: integer;
begin
MonkeyButt := random(PeoplePlaying)
for i := 0 to PeoplePlaying - 1 do
begin
if (i = MonkeyButt)then
Writeln('Person number '+IntToStr(Monkeybutt)+' is the monkeyass');
end;
end.

If you really wanted to incorporate separate names then:

const
PeoplePlaying = 8;
var
Monkeybutt: integer;
begin
MonkeyButt := random(PeoplePlaying)
case MonkeyButt of
0 : Writeln('Name here is the monkeyass');
1 : Writeln('Name here is the monkeyass');
2 : Writeln('Name here is the monkeyass');
3 : Writeln('Name here is the monkeyass');
4 : Writeln('Name here is the monkeyass');
5 : Writeln('Name here is the monkeyass');
6 : Writeln('Name here is the monkeyass');
7 : Writeln('Name here is the monkeyass');
end;
end.

For an if-then tutorial I suggest something more like

if (thiscondition)then
begin
end;

Using perhaps, color statements, ect.
But, lol. :) haha.