SRL Archive - OSR Help

MakeCompass issue


Nebula

2011-12-30 20:00:04

I'm sure this has an easy fix but I cant figure it out. Basically I want my compass to move to between 355 and 5 degrees (North,+- a bit). RandomRange doesn't work because It finds a number between 5 and 355, but since I'm using the compass it should reset to 0 at 360. Does anyone know of a fix to this? Thanks.

MakeCompass(randomrange(355, 5));


Edit:

Could I just make a case statement like:

Case random(2) of

0: MakeCompass(randomrange(0, 5));
1: MakeCompass(randomrange(355, 359));

Tickyy

2011-12-30 20:18:17

From: Nebula
I'm sure this has an easy fix but I cant figure it out. Basically I want my compass to move to between 355 and 5 degrees (North,+- a bit). RandomRange doesn't work because It finds a number between 5 and 355, but since I'm using the compass it should reset to 0 at 360. Does anyone know of a fix to this? Thanks.

MakeCompass(randomrange(355, 5));


Edit:

Could I just make a case statement like:

Case random(2) of

0: MakeCompass(randomrange(0, 5));
1: MakeCompass(randomrange(355, 359));


MakeCompass(randomrange(355, 5));

This would be the random range of 355 and 5, which means all numbers from 355 till to 5, i can be 215, it can be 100… etc etc.

Try this:

MakeCompass(randomrange(-5, 5));

Not sure though if MakeCompass works with negative numbers.

Edit: also have you tried ClickNorth yet?

Nebula

2011-12-30 20:41:21

randomrange(-5, 5) wouldn't work since the compass goes from 0 to 360, not -180 to 180. I used cases and it works fine. I dont wan't to use MakeCompass(n) since that will make it perfectly north, which I think is unhuman if it goes perfectly north every time.

legoace

2011-12-30 20:57:03

Your cases solution is the best, I think.

Although MakeCompass(n) doesn't really make the compass exactly north. I believe actually that if the compass is between 355 and 5, it doesn't do anything at all.

euphemism

2011-12-30 21:00:25


case RBool of

True: MakeCompass(RandomRange(0, 5));

False: MakeCompass(RandomRange(355, 360));
end;

Erm, looks like I have been ninja'd.