SRL Archive - Help and Support

Little question here...


'Toxin

2012-05-28 15:16:12

So, I'm working on somewhat of a fail-safe here regarding angles, and I've stumped into somewhat of a dead end. Basically, I want to be able to track the positioning of the compass angle, and if it is a certain angle, then move left or right 5 degrees.

Here's what I've come up with so far…


if Length(tpa) < 40 then
begin
WriteLn('Failed to track ob');
deg := rs_GetCompassAngleDegrees;
writeln('degrees below:');
writeln(deg);
if (deg < 5) then
begin
newDegrees := deg + 5;
//SetAngle(newDegrees);
end else
begin
newDegrees := deg - 5;
//SetAngle(newDegrees);
end;

The issue is, SetAngle accepts Integers, and the 'newDegrees' is of type Extended. Is there a way I can take the newDegrees variable and convert/round it such that it is an integer? The value of newDegree is usually something like 5.1923478593489, so if I am able to convert that into an Integer, I'd be able to do what I am trying to do. Any ideas?

Runaway

2012-05-28 15:23:57

- Floor() to round down
- Ceil() to round up
- Round() to round up if the decimal is above .5; down if not

putonajonny

2012-05-28 15:50:12

What he said, but just so you know compass angle getting isn't that accurate (not to 5 degrees)

'Toxin

2012-05-28 16:12:16

Hmmm alright thanks guys, I'll look into it.

From: putonajonny
What he said, but just so you know compass angle getting isn't that accurate (not to 5 degrees)


I know, but it really doesn't have to be, I just wanted to have it move and search again once the compass has been moved. I am running into an exception causing my script to crash due to that I believe so I wanted to just have it move the compass every so often.

putonajonny

2012-05-28 16:18:47

[QUOTE='Toxin;1033120]Hmmm alright thanks guys, I'll look into it.



I know, but it really doesn't have to be, I just wanted to have it move and search again once the compass has been moved. I am running into an exception causing my script to crash due to that I believe so I wanted to just have it move the compass every so often.


Just had a look at the code: (line 125 in mapwalk.simba)
if (__MakeCompass_MinCheck(StartAngle, DirectionDeg) <= 8.0) then

Using MakeCompass if it is within 8 degrees it doesn't bother moving

'Toxin

2012-05-28 16:24:33

From: putonajonny
Just had a look at the code: (line 125 in mapwalk.simba)
if (__MakeCompass_MinCheck(StartAngle, DirectionDeg) <= 8.0) then

Using MakeCompass if it is within 8 degrees it doesn't bother moving


So, basically it if is being told to shift left or right <8 degrees it won't move at all?

From: Runaway
- Floor() to round down
- Ceil() to round up
- Round() to round up if the decimal is above .5; down if not


Just tried to use these, it does work with the datatype used, however it still remains as an Extended. Is there a way to convert an Extended to Integer, some type of a cast where after it has been rounded, to convert it so that MakeCompass can be utilized?

Runaway

2012-05-28 16:29:58

[QUOTE='Toxin;1033134]Just tried to use these, it does work with the datatype used, however it still remains as an Extended. Is there a way to convert an Extended to Integer, some type of a cast where after it has been rounded, to convert it so that MakeCompass can be utilized?[/QUOTE]

[simba]
if Length(tpa) < 40 then
begin
WriteLn('Failed to track ob');
deg := rs_GetCompassAngleDegrees;
writeln('degrees below:');
writeln(deg);
if (deg < 5) then
begin
newDegrees := Round(deg + 5);
//SetAngle(newDegrees);
end else
begin
newDegrees := Round(deg - 5);
//SetAngle(newDegrees);
end;



var
d: Integer;

if Length(tpa) < 40 then
begin
WriteLn('Failed to track ob');
deg := rs_GetCompassAngleDegrees;
writeln('degrees below:');
writeln(deg);
if (deg < 5) then
begin
newDegrees := deg + 5;
d := Round(newDegrees);
//SetAngle(d);
end else
begin
newDegrees := deg - 5;
d := Round(newDegrees);
//SetAngle(d);
end;

'Toxin

2012-05-28 16:38:58

Wow, thanks Runaway. Clearly I'm tired. I should've seen this much earlier. Thanks a bunch. Rep+ for you guys :)

Runaway

2012-05-28 16:40:49

[QUOTE='Toxin;1033152]Wow, thanks Runaway. Clearly I'm tired. I should've seen this much earlier. Thanks a bunch. Rep+ for you guys :)

No problem, happens to the best of us :p

putonajonny

2012-05-28 17:00:25

[QUOTE='Toxin;1033134]So, basically it if is being told to shift left or right <8 degrees it won't move at all? exactly :)

Sir Ducksworthy

2012-05-28 22:39:24

Yeh I've noticed how the compass angle detection isn't very accurate I'm going to be working on a new function soon, I will firstly make an accurate measuring system and then I will be measuring how many degrees/radians the compass changes in seperate portions of 100ms-1500ms of Key Holding and Also how much it changes when Moving the Mouse and holding in the scroll button then making it have an offset that will be corrected afterwards for Humanization.
Also it's really slow trying to use the Left or Right key only to change the compass angle.
Jagex has changed Click North so that the it won't really correct the mini map to a perfect north anymore aswell.

Jakkle

2012-06-05 15:57:08

@leetsxc
What about accounting for the (every so often) movement of the compass while not doing anything ?