SRL Archive - Discussions and Debates

A Way to encourage scripting!


Daniel

2008-06-03 23:37:02

How about, for one whole week, all our (SRL Members) posts are SCAR Scripts? Like name it something like SCAR week or something. The idea is as follows:

Someone:Hello, i'm new to this forums.
SRL Member:

program WelcomeMember;

var
Leacher: Boolean;

begin
Leacher:=False;
case (Leacher) of
True: Writeln('You''re not welcome here if you''re going to become a leacher');
False: begin
Status('Hey, welcome');
Writeln('Don''t be a leacher otherwise you''ll be dis-liked');
end;
end;
end.

Or something similar? Should make the scripts not too hard, but it is a way to encourage scripting. But not using all those Writelns or Status, things that contain strings for sentences.

Well, what do you guys think?

Macrosoft

2008-06-04 00:43:46

Lol, this is a fun idea. Other users might start to use it because they think its cool. Then they will unknowingly practice their scripting skills.

I might get too lazy though…

R0b0t1

2008-06-04 01:54:25

I think this deserves a pretty big yellow corncob for corny…


But its a thought, we really need to refine the idea. :)

Daniel

2008-06-04 05:59:53

I'm just trying to come up with ways to encourage scripting for SRL.

@Macrosoft:
You could just probably do functions or procedures instead of a whole script if it's too long for you to write :p

SonOfSheep

2008-06-27 12:19:47


//Run Script to view post :P
program SonOfSheepCryptoReplyThing;
var CryptoMsg : string;

{---------------------------------------------------------------------]
+ DecryptString: Function which uses a String as Input and decrypts it
+ resulting in a decrypted string as the return value.
{---------------------------------------------------------------------}
function DecryptString(EncryptedStr : string) : string;
var i : Integer; //32 bit signed integer. Ranges from -2147483648-2147483647. 31 bits without sign.
CharCode : Byte; //8 bit positive (unsigned) integer Ranges from 0-255.
DecryptedStr : string; //string of bytes that represents text
begin
//Loop through the positions in the string
//Positions start with 0
for i := 1 to Length(EncryptedStr) do
begin
//Implements a simple 2 way cipher. (2 way because you can use this to decrypt as well!)
CharCode := Ord(StrGet(EncryptedStr, i)); //Get the original charcode
CharCode := CharCode xor 105; //Bitwise operation. Google it.
DecryptedStr := DecryptedStr + Chr(CharCode); //Add to Decrypted String
end;
Result := DecryptedStr; //Output DecryptedStr as result
end;


begin
//The encrypted message lies here
CryptoMsg := Chr(32) + Chr(73) + Chr(29) + Chr(6) + Chr(29) + Chr(8) + Chr(5) + Chr(5) + Chr(16) + Chr(73) + Chr(8) + Chr(14) + Chr(27) + Chr(12) + Chr(12) + Chr(71) + Chr(73) + Chr(44) + Chr(31) + Chr(12) + Chr(27) + Chr(16) + Chr(11) + Chr(6) + Chr(13) + Chr(16) + Chr(73) + Chr(26) + Chr(1) + Chr(6) + Chr(28) + Chr(5) + Chr(13) + Chr(73) + Chr(10) + Chr(6) + Chr(4) + Chr(25) + Chr(5) + Chr(12) + Chr(29) + Chr(12) + Chr(5) + Chr(16) + Chr(73) + Chr(10) + Chr(6) + Chr(4) + Chr(4) + Chr(12) + Chr(7) + Chr(29) + Chr(73) + Chr(12) + Chr(31) + Chr(12) + Chr(27) + Chr(16) + Chr(73) + Chr(25) + Chr(6) + Chr(26) + Chr(29) + Chr(73) + Chr(8) + Chr(26) + Chr(73) + Chr(30) + Chr(12) + Chr(5) + Chr(5) + Chr(71) + Chr(73) + Chr(48) + Chr(6) + Chr(28) + Chr(73) + Chr(4) + Chr(28) + Chr(26) + Chr(29) + Chr(73) + Chr(30) + Chr(27) + Chr(0) + Chr(29) + Chr(12) + Chr(73) + Chr(8) + Chr(73) + Chr(10) + Chr(5) + Chr(12) + Chr(31) + Chr(12) + Chr(27) + Chr(73) + Chr(26) + Chr(10) + Chr(27) + Chr(0) + Chr(25) +
Chr(29) + Chr(73) + Chr(15) + Chr(6) + Chr(27) + Chr(73) + Chr(12) + Chr(8) + Chr(10) + Chr(1) + Chr(73) + Chr(25) + Chr(6) + Chr(26) + Chr(29) + Chr(69) + Chr(73) + Chr(1) + Chr(6) + Chr(30) + Chr(12) + Chr(31) + Chr(12) + Chr(27) + Chr(71) + Chr(73) + Chr(32) + Chr(73) + Chr(1) + Chr(8) + Chr(13) + Chr(73) + Chr(8) + Chr(5) + Chr(6) + Chr(29) + Chr(73) + Chr(6) + Chr(15) + Chr(73) + Chr(15) + Chr(28) + Chr(7) + Chr(73) + Chr(4) + Chr(8) + Chr(2) + Chr(0) + Chr(7) + Chr(14) + Chr(73) + Chr(29) + Chr(1) + Chr(0) + Chr(26) + Chr(73) + Chr(26) + Chr(10) + Chr(27) + Chr(0) + Chr(25) + Chr(29) + Chr(73) + Chr(8) + Chr(7) + Chr(13) + Chr(73) + Chr(6) + Chr(29) + Chr(1) + Chr(12) + Chr(27) + Chr(26) + Chr(73) + Chr(10) + Chr(6) + Chr(28) + Chr(5) + Chr(13) + Chr(73) + Chr(5) + Chr(12) + Chr(8) + Chr(27) + Chr(7) + Chr(73) + Chr(8) + Chr(5) + Chr(6) + Chr(29) + Chr(73) + Chr(15) + Chr(27) + Chr(6) + Chr(4) + Chr(73) + Chr(0) + Chr(29) + Chr(71);
WriteLn(DecryptString(CryptoMsg));
end.



Bwahaha :stirthepot:

Markus

2008-06-27 15:46:28


program RC4Cypher;
var
s : array [0 .. 255] of byte;
i, j : integer;
const cyphertext = 'elH7D/OOPh9pAW4zZWaFPxb9ZRk2G/m0qT+dkWMLMQ/zoB5iAMPx3NSnskNReHbqzKo5kOBMygxqiIEVlgF/ZTeLxW0e+TGEeoCoziqfzSQ=';
Key = 'SRLFtw';
decrypt = true;

const
Base64Code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ 'abcdefghijklmnopqrstuvwxyz'
+ '0123456789+/';
Pad = '=';


function StrTobase64( Buf: string ): string;
var
// B3 : string[3];
i : integer;
x1, x2, x3, x4: byte;
PadCount : integer;
begin
PadCount := 0;

// we need at least 3 input bytes...
while length( Buf ) < 3 do
begin
Buf := Buf + #0;
inc( PadCount );
end;

// ...and all input must be an even multiple of 3
while ( length( Buf ) mod 3 ) <> 0 do
begin
Buf := Buf + #0; // if not, zero padding is added
inc( PadCount );
end;

Result := '';
i := 1;

// process 3-byte blocks or 24 bits
while i <= length( Buf ) - 2 do
begin
// each 3 input bytes are transformed into 4 index values
// in the range of 0..63, by taking 6 bits each step

// 6 high bytes of first char
x1 := ( Ord( Buf[i] ) shr 2 ) and $3F;

// 2 low bytes of first char + 4 high bytes of second char
x2 := ( ( Ord( Buf[i] ) shl 4 ) and $3F )
or Ord( Buf[i + 1] ) shr 4;

// 4 low bytes of second char + 2 high bytes of third char
x3 := ( ( Ord( Buf[i + 1] ) shl 2 ) and $3F )
or Ord( Buf[i + 2] ) shr 6;

// 6 low bytes of third char
x4 := Ord( Buf[i + 2] ) and $3F;

// the index values point into the code array
Result := Result
+ Base64Code[x1 + 1]
+ Base64Code[x2 + 1]
+ Base64Code[x3 + 1]
+ Base64Code[x4 + 1];
incex( i, 3 );
end;

// if needed, finish by forcing padding chars ('=')
// at end of string
if PadCount > 0 then
for i := Length( Result ) downto 1 do
begin
Result[i] := Pad;
dec( PadCount );
if PadCount = 0 then BREAK;
end;
end;

function Char2IDx( c: char ): byte;
var
i : integer;
begin
for i := 1 to Length( Base64Code ) do
if Base64Code[i] = c then
begin
Result := pred( i );
EXIT;
end;
Result := Ord( Pad );
end;

//*****************************************************************************
function Base64ToStr( B64: string ): string;
var
i,
PadCount : integer;
Block : string;
x1, x2, x3 : byte;
begin
SetLength(Block, 3);
// input _must_ be at least 4 chars long,
// or multiple of 4 chars
if ( Length( B64 ) < 4 )
or ( Length( B64 ) mod 4 <> 0 ) then
begin
writeln('COULD NOT CONVERT INVALID LENGTH');
exit;
end;
//
PadCount := 0;
i := Length( B64 );
// count padding chars, if any
while (B64[i] = Pad)
and (i > 0 ) do
begin
inc( PadCount );
dec( i );
end;
//
Result := '';
i := 1;
SetLength( Block, 3 );
while i <= Length( B64 ) - 3 do
begin
// reverse process of above
x1 := ( Char2Idx( B64[i] ) shl 2 ) or ( Char2IDx( B64[i + 1] ) shr 4 );
Result := Result + Chr( x1 );
x2 := ( Char2Idx( B64[i + 1] ) shl 4 ) or ( Char2IDx( B64[i + 2] ) shr 2 );
Result := Result + Chr( x2 );
x3 := ( Char2Idx( B64[i + 2] ) shl 6 ) or ( Char2IDx( B64[i + 3] ) );
Result := Result + Chr( x3 );
incex( i, 4 );
end;

// delete padding, if any
while PadCount > 0 do
begin
Delete( Result, Length( Result ), 1 );
dec( PadCount );
end;

end;
procedure InitRandomGen(key : string);
begin
for i := 0 to 255 do
S[i] := i;
for i := 0 to 255 do
begin
j := (j + S[i] + (ord(key[(i mod (length(key))+1)]))) mod 256;
swap(S[i],S[j])
end;
i := 0;
j := 0;
end;
function GenerateByte : byte;
begin
i := (i + 1) mod 256;
j := (j + S[i]) mod 256;
swap(s[i], s[j]);
result := S[(s[i]+s[j]) mod 256];
end;
function EncryptRC4(text, key : string; Decrypt : boolean) : string;
var CC, LL : integer;
begin
if (decrypt) then
text := base64tostr(text);
LL := length(text);
InitRandomGen(key);
result := text;
for CC := 1 to LL do
begin
result[CC] := chr((ord(text[cc])) xor GenerateByte);
end;
if (not(decrypt)) then
result := StrTobase64(result);
end;
begin
writeln(EncryptRC4(cyphertext, key, decrypt));
end.

mixster

2008-06-27 17:38:30

I think it's a nice idea, though long posts may become a problem when the Writeln's have to be split onto multiple lines…
Anyway, any dates set or thought of yet? I'm thinking some time soon would be nice, but not much interest has been shown so may want to leave it longer and try to get mroe support :)

richk1693

2008-06-28 00:46:57

I like this idea. Sounds fun.

Daniel

2008-06-28 00:55:26

We'll need one of the admins and see if they agree with it first, then it should occurr someday!

Starblaster100

2008-06-30 17:02:41

feel free to do it lol, it might be a bit of fun

SonOfSheep

2008-07-08 13:20:34

You guys NEED to run this script. It is amazing. Also look through the code. PLEASE.

This is fun i should post all of my posts like this. It takes a long time to write these though :eek:

program Encrypt;
var Text1, Text2, Text3, Text4 : string;

//Setup const Here
const Encrypt = False; //just replaces special characters
const Password = 'Srl Forums RULE!!!!!!!1111!1!111one one exclamation point eleven eleven';

//Set up the text
procedure SetupTextvariables;
begin
Text1:= 'g%U%éQ' + Chr(16) + '¼+y(' + Chr(10) + '-AnåM_¼/<pdK(K!ëGN¼:!56C4' + Chr(7) + ',ýQOªzn|)' + Chr(10) + '%K"óUOøn:zdX-WnèJOï+n&dB%T&õLM¼/"r+X-S&ñQ';
Text2:= 'cdM;ïV' + Chr(10) + 'ñ/*pd^,N=¼ACì&+gdN!F"å' + Chr(2) + '^ô'' rj' + Chr(10) + 'U+èVS¼-!z(' + Chr(10) + ',R&£' + Chr(2) + 'c¼:&`*AdN:¼WZ¼#7f!F"' + Chr(9) + '';
Text3:= '~,N=¼VEó%nx!' + Chr(10) + '0O+¼@Oè:+gdZ%U:¼ML¼/ 5,E1UnèM' + Chr(10) + 'ë<''a!' + Chr(10) + '&R:¼LEën''5''K*' + Chr(0) + ':¼VBõ %5+LdF å' + Chr(2) + 'Mó!*50B-I)ï';
Text4:= '^+' + Chr(7) + '=ý[' + Chr(4) + '¼' + Chr(7) + 'ny+\!' + Chr(7) + ':ôKY¼''*p%' + Chr(10) + '0O!éEB²n' + Chr(13) + 'g=Z0H)îCZô7n|7' + Chr(10) + '"R;éW_ò`';
end;

{--------------------------------------------]
| These 3 hashing algorithms are not mine, |
| they are just a few simple ones i found on |
| the internet. |
[--------------------------------------------}
function Hash1(const Str : String) : Cardinal;
var
i : Integer;
begin
Result := 1315423911;
for i := 1 to Length(Str) do
begin
Result := Result xor ((Result shl 5) + Ord(Str[i]) + (Result shr 2));
end;
end;

function Hash2(const Str : String) : Cardinal;
var
i : Cardinal;
x : Cardinal;
begin
Result := 0;
for i := 1 to Length(Str) do
begin
Result := (Result shl 4) + Ord(Str[i]);
x := Result and $F0000000;
if (x <> 0) then
begin
Result := Result xor (x shr 24);
end;
Result := Result and (not x);
end;
end;

function Hash3(const Str : String) : Cardinal;
var
i : Cardinal;
begin
Result := $AAAAAAAA;
for i := 1 to Length(Str) do
begin
if ((i - 1) and 1) = 0 then
Result := Result xor ((Result shl 7) xor Ord(Str[i]) * (Result shr 3))
else
Result := Result xor (not((Result shl 11) + Ord(Str[i]) xor (Result shr 5)));
end;
end;
{--------------------------------------------]
| End of hashing algorithms. |
| |
| Note: |
| The following code is dangerously random. |
| I am not responsible for loss of sanity or|
| otherwise resulting from trying to make |
| sense of the code. |
[--------------------------------------------}


//Seriously just a bunch of random shit that looked good at the time
//Don't ask me what it all is for i just thought it might be slightly
//more secure. But hey i am not a cryptography expert.
function Hash(str: string) : string;
var cHash1, cHash2, cHash3 :Cardinal;
begin
//combining some hash algorithms boi
cHash1 := Hash1(str) xor (Hash2(str) * Hash3(str));
cHash2 := (Hash1(str) * Hash3(str)) xor Hash2(str);
cHash3 := Hash2(str) xor Hash3(str);
//let's shift em left and right why don't we?
cHash1 := (cHash1 shr 3) or (cHash1 shl 29);
cHash2 := (cHash1 shr 7) or (cHash1 shl 25);
cHash3 := (cHash1 shr 31) or (cHash1 shl 1);

//fucking around with the bits and then putting out a string output
Result := Chr((cHash2 shr 16) and $FF) + Chr((cHash3 shr 8) and $FF) + Chr(cHash3 shr 24) + Chr(cHash1 and $FF) +
Chr(cHash2 shr 24) + Chr((cHash3 shr 16) and $FF) + Chr(cHash1 shr 24) + Chr(cHash2 and $FF) +
Chr((cHash2 shr 8) and $FF) + Chr((cHash1 shr 16) and $FF) + Chr(cHash3 and $FF) + Chr((cHash1 shr 8) and $FF);
end;

//this code actually makes sense
function Cipher(str, pass: string) : string;
var HashedPass : string;
c: Char;
i : integer;
begin
HashedPass := Hash(pass);
for i:= 1 to Length(str) do
begin
c := Chr(Ord(str[i]) xor Ord(HashedPass[i mod Length(HashedPass) + 1]));

if (Ord(c) < 20) and Encrypt then
Result := Result + ''' + Chr(' + IntToStr(Ord(c)) + ') + '''
else if (c = '''') and Encrypt then
Result := Result + ''''''
else
Result := Result + c;
end;
end;

begin
SetupTextvariables;
Writeln('');
Writeln('');
Writeln('');
Writeln('**POST BEGIN**');
Writeln('** ' + Cipher(Text1, Password));
Writeln('** ' + Cipher(Text2, Password));
Writeln('** ' + Cipher(Text3, Password));
Writeln('** ' + Cipher(Text4, Password));
end.

Pure1993

2008-07-08 14:32:20

Yeah, great idea! Even if it won't go further than this, it already gave me enough encouragement and material to learn basic en-/decrypting. :D

[Offtopic]urgh, one question already…. what does "cardinal" stand for? for exmaple in:
function Hash1(const Str : String) : Cardinal;
? ^^[/OffTopic]

SonOfSheep

2008-07-08 14:53:32

From: Pure1993
Yeah, great idea! Even if it won't go further than this, it already gave me enough encouragement and material to learn basic en-/decrypting. :D

[Offtopic]urgh, one question already…. what does "cardinal" stand for? for exmaple in:
function Hash1(const Str : String) : Cardinal;
? ^^[/OffTopic]


Oh that's simple :spot:

A cardinal is pascal's base unsigned int type. In scar, Cardinals are 32 bit unsigned integers, meaning they range in value from 0 to 4294967295, or 2^32 different numbers.

you are going to want to remember Ord and Chr, as they are basic in any scripting application. Ord is the value of a single character and will output a value of 0-255 corresponding to the ASCII value of the input. Chr is the oppisite of Ord and outputs the character corresponding to the input value.

A useful type when working with characters can be Byte because each character is represented with 1 byte. A Word is 2 bytes and a Cardinal is 4 bytes. Shr and Shl are to Shift right and Shift left, respectively.


I always make a cryptography program in every language i learn because as you do so you can learn alot about the language. It is a great exercise for any programmer learning a language or just as a little refresher! :) Everybody needs a refresher after working in a different language for a while. ;)



Edit to stay on topic:
This is already encouraging others to script!

Camaro'

2008-07-09 11:51:40

i like this idea! im making one now

//Run me!!
program New;//New is the name.. change it to whatever you want no spaces though..

Const//Const is declaring something at the beginninng of the script.. like how many loads you want to do
// or what tree to cut.. ect...

WhatHasHappened='Joined SRL';//Just one of my const.. choices are below
Leecher=True;//are you a leecher..

{
JoinedSRL
Funnypost
GoodPost
AmazingScript
ThanksAdmin
}

Procedure Whathappened;//what happened is the name no spaces.. a procedure is telling thescript to
//do something..
begin//for every begin u need an end.
case whathashappened of// means like .. for what you typed in the what has happened.. it will do something..
'JoinedSRL':begin
If (Leecher) then//If you wrote in you were a leecher..
begin
writeln('Leave srl and dont come back you stupid leecher');
exit;
end
else
Writeln('************Welcome to SRL, Enjoy your stay..************');
exit;
end;
'FunnyPost':begin
Writeln('************LOL that was so funny..************');
exit;
end;
'GoodPost': begin
writeln('************Good post!!************');
end;
'AmazingScript':begin
writeln('************THIS IS AN AMAZING SCRIPT!************');
end;
'ThanksAdmin': begin
writeln('************Thanks for releasing the new SRL Revision************');
end;
end;
end;



begin//of main loop
Whathappened;//we have to call our procedure..!
terminatescript;
end.

Dusk412

2008-07-09 14:35:00

you don't need a terminatescript at the end of your main loop? lol

Camaro'

2008-07-12 17:19:20

From: Dusk412
you don't need a terminatescript at the end of your main loop? lol


lol idk :D

SonOfSheep

2008-07-16 09:28:48

From: cnr sport
lol idk :D


You should know :D

And the truth is you don't. TerminateScript is for terminating the script early. Say something bad happens in the script like some bug you never fixed. Means that you should TERMINATE the script. My good friend the terminator has a little thing he likes to say:

Arrrrrgh My muscles are huuuuuge I need to TERMINATE BAD SCRIPTS. CNR SPORT!!!!! Why do you call on me to terminate your scripts!!! I want to KILL!!!

Camaro'

2008-07-25 21:48:17

From: SonOfSheep
You should know :D

And the truth is you don't. TerminateScript is for terminating the script early. Say something bad happens in the script like some bug you never fixed. Means that you should TERMINATE the script. My good friend the terminator has a little thing he likes to say:


HAHA, lol nah, dont bother changing it ..

Daniel

2008-09-27 22:17:05

Even though this is an old thread, it is still alive ;)

This will begin in 2 days time. So get ready :p (p.s: To all people that want to participate in it, try not to make the script juse use Writelns etc, or with a begin and an end. so people just need to compile it and it'll give em' an answer ;)).

Hopefully this'll go good :p

sirlaughsalot

2008-09-27 22:28:59

[QUOTE=Dan's The Man;472031]Even though this is an old thread, it is still alive ;)

This will begin in 2 days time. So get ready :p (p.s: To all people that want to participate in it, try not to make the script juse use Writelns etc, or with a [b]begin[/b] and an [b]end.[/b] so people just need to compile it and it'll give em' an answer ;)).

Hopefully this'll go good :p

Sounds like fun :D i have some ideas ^_^

Daniel

2008-09-28 20:15:37

From: sirlaughsalot
Sounds like fun :D i have some ideas ^_^

Lol, k. 1 more day :p

Raskolnikov

2008-09-30 14:14:49

W00t ness I guess it started :D

Cut em2 it

Daniel

2008-09-30 22:05:35

From: Cut em2 it
W00t ness I guess it started :D

Cut em2 it

program New;

var
Started: Boolean;

begin
Inc(Dec(Dec(Inc(Inc(Dec(Dec(Dec(IncEx(Started, 5)))))))))); //Not sure you can do this :p
case(Started) of
True: Readln('Enter yes if you wish to continue'#39);
False: Status('False Alert');
end;
end.