SRL Archive - SRL Archives

Function| ColorEffectAdd;


Baked0420

2009-05-10 11:08:58

I had an idea for Text.Scar, or wherever it would be put, but to be able to edit your text with random colors, or effects, or both. I made a little function where you can set it to True or False to randomly pick a color or effect or both. Here's the function:


Function ColorEffectAdd(Color, Effect:Boolean):String;
var
S1,S2,S3:String;
begin
if(Color)then
begin
case Random(5) of
0: S1:= 'red:';
1: S1:= 'green:';
2: S1:= 'cyan:';
3: S1:= 'purple:';
4: S1:= 'white:';
end;
end;
if(Effect)then
begin
case Random(5) of
0: S2:= 'scroll:';
1: S2:= 'shake:';
2: S2:= 'slide:';
3: S2:= 'wave:';
4: S2:= 'wave2:';
end;
end;
if(Color) and (Effect)then
begin
S3:= S1+S2;
{$IFDEF DEBUG}writeln('Choose S3:' + S3);{$ENDIF}
Result:= S3;
end;
if(Color) and (not(Effect))then
begin
{$IFDEF DEBUG}writeln('Choose S1:' + S1);{$ENDIF}
Result:= S1;
end;
If(not(Color)) and (Effect)then
begin
{$IFDEF DEBUG}writeln('Choose S2:' + S2);{$ENDIF}
Result:= S2;
end;
end;


I also attatched a little script to test it. Think this should be added to help add antiban to people who want to use it in TypeSends in RS or is it not worth it?

Floor66

2009-05-10 11:14:02

Looks kwl. Might need some shortening here and there maybe. GJ!

Baked0420

2009-05-10 11:15:32

yea, I did it real fast though just to add randomness to repeated TypeSends at the grand exchange. I might find a way to shorten it though, if I do I'll edit first post. But does it look like something you'd ever use?

Floor66

2009-05-10 11:16:22

In an autotalker yes defiantly.

Frt

2009-05-10 11:20:58

No need for those if's since you're only setting the variables if the booleans are true.

Function ColorEffectAdd(Color, Effect:Boolean):String;
var
S1, S2: String;
begin
if(Color)then
begin
case Random(5) of
0: S1:= 'red:';
1: S1:= 'green:';
2: S1:= 'cyan:';
3: S1:= 'purple:';
4: S1:= 'white:';
end;
end;
if(Effect)then
begin
case Random(5) of
0: S2:= 'scroll:';
1: S2:= 'shake:';
2: S2:= 'slide:';
3: S2:= 'wave:';
4: S2:= 'wave2:';
end;
end;
Result := S1 + S2;
end;

Baked0420

2009-05-10 11:21:51

ok so it was a decent function for something I thought of real quick. I want to also add ColorEffectAddEx; or something, where it won't randomly choose between all colors and effects. It would only do the colors and/or the effects you choose by what you enter into the array, so it can only do one color and/or effect or randomly choose between the few you want. I just don't feel like making it just this second, but I could easily.

EDIT: I thought bout that, but didn't feel like testing it also to make sure it'd work just as well, and I also did it this way for a neater debug of each. But I did think about that at one point, but thanks for suggestion Frt. Seeing it wrote out now it looks like it would work, wasn't sure why I thought it might not.

Naum

2009-05-10 11:45:06

shorten by changing it to an array:

Function ColorEffectAdd(Color, Effect:Boolean):String;
var
S1, S2: TStringArray;
S1x, S2x : String;
I : Integer;
begin
S1 := ['red:', 'green:', 'cyan:', 'purple:', 'white:'];
S2 := ['scroll:', 'shake:', 'slide:', 'wave:', 'wave2:'];
if(Color)then
begin
I := Random(5);
S1x := S1[I];
End;
if(Effect)then
begin
I := Random(5);
S2x := S2[I];
end;
Result := S1x + S2x;
end;

Good function, would be good for anti-ban :)

Baked0420

2009-05-10 11:48:10

I was thinking bout using arrays, was gonna do it later, but thanks Nauman :)

Sir R. M8gic1an

2009-05-10 12:40:46


{*******************************************************************************
function RandChatFx(Effect: Byte): string;
By: EvilChicken!
Description: Returns a RS chat effect based on 'Effect'.
0 reteurns completely random effect(s), 1 returns a colorful chat effect,
2 returns a text moving effect, 3 returns both types of effects.
Use example: TypeSend(RandChatEffect(0) + 'I love pie!');
*******************************************************************************}

- Found in Text.scar.

~RM

NiCbaZ

2009-05-10 14:21:48

[PHP]function ColorEffectAdd(Color, Effect:Boolean):String;
var
S1 : TStringArray;

begin
S1 := ['red:', 'green:', 'cyan:', 'purple:', 'white:','scroll:', 'shake:', 'slide:', 'wave:', 'wave2:'];
if Color then
Result := S1[0+random(4);
if Effect then
Result:= Result + S1[5+random(5)];
end;[/PHP]

Sir R. M8gic1an

2009-05-10 17:02:52

From: NiCbaZ
[PHP]function ColorEffectAdd(Color, Effect:Boolean):String;
var
S1 : TStringArray;

begin
S1 := ['red:', 'green:', 'cyan:', 'purple:', 'white:','scroll:', 'shake:', 'slide:', 'wave:', 'wave2:'];
if Color then
Result := S1[0+random(4);
if Effect then
Result:= Result + S1[5+random(5)];
end;[/PHP]


humm… might change the one in srl for that.

~RM

marpis

2009-05-10 17:10:37

From: NiCbaZ
[PHP]function ColorEffectAdd(Color, Effect:Boolean):String;
var
S1 : TStringArray;

begin
S1 := ['red:', 'green:', 'cyan:', 'purple:', 'white:','scroll:', 'shake:', 'slide:', 'wave:', 'wave2:'];
if Color then
Result := S1[random(5)];
if Effect then
Result:= Result + S1[5+random(5)];
end;[/PHP]


the numbers there are wrong, fixed them
random(5) = 0, 1, 2, 3, 4 = red, green, cyan, purple, white
5+random(5) = 5, 6, 7, 8, 9 = scroll, shake, slide, wave, wave2

Baked0420

2009-05-10 20:36:53

From: Rasta Magician

{*******************************************************************************
function RandChatFx(Effect: Byte): string;
By: EvilChicken!
Description: Returns a RS chat effect based on 'Effect'.
0 reteurns completely random effect(s), 1 returns a colorful chat effect,
2 returns a text moving effect, 3 returns both types of effects.
Use example: TypeSend(RandChatEffect(0) + 'I love pie!');
*******************************************************************************}

- Found in Text.scar.

~RM


Dang, I didn't know this was in already, I tried checking for it before I posted but couldn't find something to add color/effects. Thanks for showing me Rasta.

EDIT: I like how you guys shortened it, NiCbaZ's looks nice. And if you do edit Text.Scar will I get any credits?

EvilChicken!

2009-05-10 20:57:41

Nice job, NiCbaZ! :)
I commited it, this is the version in the repos:

{*******************************************************************************
function ColorEffectAdd(Color, Effect: Boolean): string;
By: NiCbaZ
Description: Returns a RS chat effect based on 'Color' and 'Effect' booleans.
*******************************************************************************}
function ColorEffectAdd(Color, Effect: Boolean): string;
var
Str : TStringArray;

begin
Str := ['flash1:', 'flash2:', 'flash3:', 'glow1:', 'glow2:', 'glow3:', 'red:',
'green:', 'cyan:', 'purple:', 'white:', 'scroll:', 'shake:', 'slide:',
'wave:', 'wave2:'];
if Color then
Result := Str[Random(11)];
if Effect then
Result := Result + Str[11 + Random(5)];
end;

Da 0wner

2009-05-10 22:40:56

To bad Baked did not receive any credit :o.

Floor66

2009-05-10 22:48:37

Baked gave the idea of a whole new function c'mon guys.

Da 0wner

2009-05-10 23:10:26

Orly? Nah he didn't but still. Credit him pl0x.

Baked0420

2009-05-11 00:16:44

wait what didn't I do?

Da 0wner

2009-05-11 00:20:30

your idea was not original.

Baked0420

2009-05-11 01:05:07

but this function was originally mine

Da 0wner

2009-05-11 01:12:10

But Nicbaz's is not the same as yours and he made it from scratch. There was one in SRL already but they replaced it with Nicbaz's because it was shorter but yours was not.

Baked0420

2009-05-11 01:14:03

eh whatever doesn't really matter to me

ZephyrsFury

2009-05-11 14:29:57

Crediting is done at the developer's discretion.

Thanks Baked for your time in helping develop SRL, thanks NicBaz for the new function and thanks EvilChicken! for commiting. :)

ZephyrsFury

2009-05-12 12:04:19

Sorry thanks NicBaz, shuttleu was in the other thread ;).