SRL Archive - SRL Snippets

RandomCompass


Laimonas171

2012-10-28 18:31:49

Though easy function but I found it useful, if you are not sure where your object is exactly, if here is something like that please inform me about that in posts :)


{*
Author: laimonas171, Nebula (Troubleshooted it a bit)

Description: Changes to random compass possition N, W, E, S...

Example: MakeCompassRnd; // Changes to random compass possition

Note: In most cases it should be useful at search object on mainscreen, etc as example:
repeat
MakeCompassRnd;
FindMyObject; // search for any object you want...
until(FindMyObject) // timeMarkUp would be useful as failsafe.
*}
procedure MakeCompassRnd;
begin
MakeCompass(Random(3) * 90);
end;
end;

Nebula

2012-10-28 18:40:46

This can be shortened to the below, moving the compass to a a 90 degree increment between 0 and 3. Resulting in the movement to 0, 90, 180, or 270 degrees.

procedure MakeCompassRnd;
begin
MakeCompass(Random(3) * 90);
end;

Sin

2012-10-28 18:43:19


function MakeCompassRnd:Boolean;
begin
Result := MakeCompass(Random(3) * 90);
end;

you mean.

Laimonas171

2012-10-28 18:43:26

From: Nebula
This can be shortened to the below, moving the compass to a a 90 degree increment between 0 and 3. Resulting in the movement to 0, 90, 180, or 270 degrees.

procedure MakeCompassRnd;
begin
MakeCompass(Random(3) * 90);
end;


Oh, I didn't know I can write it in this way :D still it would be useful at library :) probably with you fix if we can call it like that :)

edit: can I edit first post to that?

Nebula

2012-10-28 18:44:33

From: Shay

function MakeCompassRnd:Boolean;
begin
Result := MakeCompass(Random(3) * 90);
end;

you mean.


No, I meant what I posted. There's no reason to make this a function.


From: Laimonas171

edit: can I edit first post to that?
go for it

Sin

2012-10-28 18:45:18


He wants it to be a function.

Laimonas171

2012-10-28 18:48:06

From: Shay

He wants it to be a function.


I see no big deal : )