SRL Archive - RS3 Help

Running a script in openGL vs directX


agent007

2014-11-10 13:58:16

My script is meant for SMART, naturally I run it with the openGL set in my graphic settings.

The problem is that the MINI MAP disappears in that mode, forcing me to basically teleport away, exit to lobby, log back in, and then the mini map shows.

If I switch to directX the mini map is there instantly. The problem is that my script will not work, it fails to run to the deposit area or fails to run to the coal area.


Maybe there is a good fix to this that is obvious, but once I get the mini map up in openGL the script runs flawlessly for ever, until the 6 hour mark as when you log back in the mini map is gone.



I hope someone has a good answer for me because it is frustrating, just want this thing to run.



I should add that this is very weird. Yesterday I was able to run this perfectly, someone told me to try directX to solve the mini map issue, and it worked. I was running the script for a solid 2 hours. All of a sudden it gives me the debug info posted below.


– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 78 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 79 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– sps.walkPath(): result = False
We failed to walk to the bank!@!


I have not messed with my script at all. After updating it to have a FORM, it worked for over 7-8 hours straight. Then we took a break, came back today and it will not work with directX.

Anyways, let me know if you guys need any more information, such as a link to the script or w/e. I really think this may just be a simple obvious adjustment somewhere.


Thanks again.

3Garrett3

2014-11-10 14:04:12

From: agent007
My script is meant for SMART, naturally I run it with the openGL set in my graphic settings.

The problem is that the MINI MAP disappears in that mode, forcing me to basically teleport away, exit to lobby, log back in, and then the mini map shows.

If I switch to directX the mini map is there instantly. The problem is that my script will not work, it fails to run to the deposit area or fails to run to the coal area.


Maybe there is a good fix to this that is obvious, but once I get the mini map up in openGL the script runs flawlessly for ever, until the 6 hour mark as when you log back in the mini map is gone.



I hope someone has a good answer for me because it is frustrating, just want this thing to run.



I should add that this is very weird. Yesterday I was able to run this perfectly, someone told me to try directX to solve the mini map issue, and it worked. I was running the script for a solid 2 hours. All of a sudden it gives me the debug info posted below.


– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 78 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 79 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– WARNING: sps.getPlayerPos(): Didn't find enough matches accurately calc your postion
– sps.getPlayerPos(): result = {X = -1, Y = -1}, took 62 ms
– sps.walkPath(): result = False
We failed to walk to the bank!@!


I have not messed with my script at all. After updating it to have a FORM, it worked for over 7-8 hours straight. Then we took a break, came back today and it will not work with directX.

Anyways, let me know if you guys need any more information, such as a link to the script or w/e. I really think this may just be a simple obvious adjustment somewhere.


Thanks again.


The problem with OGL is a Runescape bug, and I think it was me who suggested using DirectX to solve any problems with your map.

IIRC, the colours are *slightly* different in DirectX compared to OGL. I think that black is 0 in one and whatever number (65335 or something?) in the other, which is the only thing that really causes problems. It's possible that since you're in a dungeon, you probably have a lot of black in your map, which is causing SPS to have problems.

I would suggest (first make a backup of your current map) making a brand new map using DirectX mode to get the screenshot rather than OGL. If that doesn't work, you can fiddle with the accuracy settings in SPS. These are set using the SPS.Setup function in which you initiate your map. I don't know them off the top of my head but you can find them in the SPS folder (lib.simba I think) and IIRC it should be near the bottom of the include.

agent007

2014-11-10 14:14:03

From: 3Garrett3
The problem with OGL is a Runescape bug, and I think it was me who suggested using DirectX to solve any problems with your map.

IIRC, the colours are *slightly* different in DirectX compared to OGL. I think that black is 0 in one and whatever number (65335 or something?) in the other, which is the only thing that really causes problems. It's possible that since you're in a dungeon, you probably have a lot of black in your map, which is causing SPS to have problems.

I would suggest (first make a backup of your current map) making a brand new map using DirectX mode to get the screenshot rather than OGL. If that doesn't work, you can fiddle with the accuracy settings in SPS. These are set using the SPS.Setup function in which you initiate your map. I don't know them off the top of my head but you can find them in the SPS folder (lib.simba I think) and IIRC it should be near the bottom of the include.


Thanks!

So when I back up my current PNG file and make this new one using directX should I also reset the pathToWalk coordinates with the SPS path generator?

I ask this because when I get the new image in directX I may not have the positioning exactly centered to match the old one.

3Garrett3

2014-11-10 14:17:51

From: agent007
Thanks!

So when I back up my current PNG file and make this new one using directX should I also reset the pathToWalk coordinates with the SPS path generator?

I ask this because when I get the new image in directX I may not have the positioning exactly centered to match the old one.


Yes it would probably be best to go through the process of making the path again, that should make it most accurate (and you won't have to care about making it identical).

agent007

2014-11-10 14:22:49

From: 3Garrett3
Yes it would probably be best to go through the process of making the path again, that should make it most accurate (and you won't have to care about making it identical).



Nice, I will also probably make sure I redo the colors for finding the objects too.

Thanks very much for the quick reply and feedback on this. I will comeback and let you know how it goes!

3Garrett3

2014-11-10 14:24:14

From: agent007
Nice, I will also probably make sure I redo the colors for finding the objects too.

Thanks very much for the quick reply and feedback on this. I will comeback and let you know how it goes!


Perfect, good luck! I think object finding *should* work between OGL or DirectX, the tolerance required usually covers any shift (in any script I've made), just the map seems like it isn't working too well, so I would focus on that first!

agent007

2014-11-10 14:54:36

From: 3Garrett3
Perfect, good luck! I think object finding *should* work between OGL or DirectX, the tolerance required usually covers any shift (in any script I've made), just the map seems like it isn't working too well, so I would focus on that first!


EDIT: Sorry, just saw your stuff about the SPS settings. I will be checking into those now.

Just updated the map using directX. Now it will click in the area of the mini map BUT it just clicks in the bottom right corner on a black area. Progress from before as it would not attempt to click on the mini and just list that debug I posted previously.

Now it tries to click the map and just shows me it cannot find deposit box. Getting close. I will get back here soon once I check into adjusting the SPS setup like you suggested.
Thanks again by the way.

agent007

2014-11-10 15:26:21

From: 3Garrett3
If that doesn't work, you can fiddle with the accuracy settings in SPS. These are set using the SPS.Setup function in which you initiate your map. I don't know them off the top of my head but you can find them in the SPS folder (lib.simba I think) and IIRC it should be near the bottom of the include.



Well I am in the area you are speaking of and there are two concerns.

One, there isn't really anything there that "I" notice to alter or change to get better accuracy/results.

Two, I want othere people to use the script I have as well. I do not think everyone will feel comfortable with changing that area up.


Is there anything else I can do that you think of?

There is always the option of adding in a procedure that is called when the mini map is not present. This will run the person out to fally bank, exit to lobby, log back in, and then go back down to the dungeon and mine.

Thanks again for helping me out.

3Garrett3

2014-11-10 15:38:27

From: agent007
Well I am in the area you are speaking of and there are two concerns.

One, there isn't really anything there that "I" notice to alter or change to get better accuracy/results.

Two, I want othere people to use the script I have as well. I do not think everyone will feel comfortable with changing that area up.


Is there anything else I can do that you think of?

There is always the option of adding in a procedure that is called when the mini map is not present. This will run the person out to fally bank, exit to lobby, log back in, and then go back down to the dungeon and mine.

Thanks again for helping me out.


Sorry, I think I was being vague.

What I mean is that the SPS.Setup('Map Name') (or however that procedure goes, sorry for not having Simba on this computer) has optional parameters. SPS.Setup('Name', Accuracy, Match, Tolerance) are something along the lines of what you want.

What I meant by "In the SPS file" was to say that I can't remember the order of them or the typical values (those are at the top with the name DEFAULT_ACCURACY or something and so on). You'll have to look in the include to find out the order and typical values for the function, but then you simply change the setup line in your script.

If you can't figure it out, hopefully someone with Simba in front of them can help you out. The best I can do for you is this:


SPS.setup('EVERGREEN_MAP_2', RUNESCAPE_OTHER, 5, 500, 0.5);
SPSAnyAngle := False;

That's the setup from my Evergreen cutter. You can simply try that with your map name instead, see if it works. I think I increased the accuracy, decreased tolerance, and increased match fraction (I think it's in that order too). You should try that, and keep fiddling with the settings until it works. If it doesn't work then I'm afraid I don't know what else would help. Try increasing accuracy and changing match fraction first, I don't know if tolerance will be the problem to start.

agent007

2014-11-10 15:54:46

From: 3Garrett3
Sorry, I think I was being vague.

What I mean is that the SPS.Setup('Map Name') (or however that procedure goes, sorry for not having Simba on this computer) has optional parameters. SPS.Setup('Name', Accuracy, Match, Tolerance) are something along the lines of what you want.

What I meant by "In the SPS file" was to say that I can't remember the order of them or the typical values (those are at the top with the name DEFAULT_ACCURACY or something and so on). You'll have to look in the include to find out the order and typical values for the function, but then you simply change the setup line in your script.

If you can't figure it out, hopefully someone with Simba in front of them can help you out. The best I can do for you is this:


SPS.setup('EVERGREEN_MAP_2', RUNESCAPE_OTHER, 5, 500, 0.5);
SPSAnyAngle := False;

That's the setup from my Evergreen cutter. You can simply try that with your map name instead, see if it works. I think I increased the accuracy, decreased tolerance, and increased match fraction (I think it's in that order too). You should try that, and keep fiddling with the settings until it works. If it doesn't work then I'm afraid I don't know what else would help. Try increasing accuracy and changing match fraction first, I don't know if tolerance will be the problem to start.


So this will clarify my understanding.

My custom script has this line of code:
SPS.setup('fally_dung_001', RUNESCAPE_OTHER);

Now I can see where the SPS file in simba's folders list a set of parameters like so:

function SPS_Setup(surface: integer; areas: TStringArray): boolean; 


So the code inside my custom script, when I call the SPS.setup I can try adding and playing with the other parameters?


I am pretty sure I completely understand now. I had some miss interpretation there. Sorry but thanks again.


EDIT: Sorry, not that the parameters are necessarily set here:
function SPS_Setup(surface: integer; areas: TStringArray): boolean; 

However they are all within that function of the script. I can see where they set those values and process them.


I am horrible at explaining what I understand sometimes, but I am playing around with the values now.


function SPS_Setup(surface: integer; areas: TStringArray): boolean;
var
t: integer;
tmp: TMufasaBitmap;
begin
t := getSystemTime;

setLength(SPS_AreaMaps, 0);
setLength(SPS_Areas, 0);

SPS_MultiMouse := true;
SPS_Accuracy := 4;

if (length(areas) > 0) then
begin
if (surface = RUNESCAPE_SURFACE) then
tmp := SPS_MergeAreas(areas) // combine the SPS areas into 1; makes for a more accurate read
else
if (surface = RUNESCAPE_OTHER) then
if (length(areas) = 1) then
tmp := SPS_GetArea(areas[0], surface)
else begin
writeln('SPS_Setup(): Invalid dungeon areas. You can only select one!');
exit;
end;

SPS_IsSetup := true;
result := true;

{$IFDEF SIMBAMAJOR990}
SPS_BitmapToMap(tmp, SPS_Accuracy, SPS_AreaMaps);
{$ELSE}
SPS_AreaMaps := SPS_BitmapToMap(tmp, SPS_Accuracy);
{$ENDIF}

if (surface = RUNESCAPE_SURFACE) then
SPS_Areas := SPS_SortAreas(areas)
else
if (surface = RUNESCAPE_OTHER) then
SPS_Areas := areas;

tmp.free();

end else
writeln('SPS_Setup(): ERROR: SPS areas are not set!');

t := (getSystemTime - t);

if (SPS_Debug) and (result) then
writeln('[SPS] SPS_Setup() took '+toStr(t)+' ms. Areas: '+toStr(SPS_Areas));
end;

3Garrett3

2014-11-10 16:04:59

From: agent007
So this will clarify my understanding.

My custom script has this line of code:
SPS.setup('fally_dung_001', RUNESCAPE_OTHER);

Now I can see where the SPS file in simba's folders list a set of parameters like so:

function SPS_Setup(surface: integer; areas: TStringArray): boolean; 


So the code inside my custom script, when I call the SPS.setup I can try adding and playing with the other parameters?


I am pretty sure I completely understand now. I had some miss interpretation there. Sorry but thanks again.


There should be in the SPS file another SPS.Setup which says something like TSPSArea.Setup(map, folder : String; Accuracy, Tolerance : Integer; MatchPercent : Extended). Note that I made up the parameter names but there should be that many.

Here's what I suggest: go to the part in your script that you referenced. The:


SPS.Setup('fally_dung_001', RUNESCAPE_OTHER);

And change that to:


SPS.Setup('fally_dung_001', RUNESCAPE_OTHER, 5, 500, 0.5);

Where (IIRC) the 5 is accuracy, the 500 is tolerance, and the 0.5 is match percent (50%).

If you run into problems, increase 5 to 6, decrease 500 to 450, increase 0.5 to 0.6, and see what happens. It should get more accurate (but slightly slower) the more you change those values in the direction I've indicated. Accuracy up, Tolerance down, MatchPercent up. I don't know the caps, but I would keep accuracy lower than 10, tolerance above a couple hundred, and matchpercent below 1 (0.9 is probably all you want to go up to).

Edit: Note that all of these changes I'm suggesting are in your own script (only referencing the include because I can't remember the names for things off the top of my head).

agent007

2014-11-10 16:28:50

From: 3Garrett3
There should be in the SPS file another SPS.Setup which says something like TSPSArea.Setup(map, folder : String; Accuracy, Tolerance : Integer; MatchPercent : Extended). Note that I made up the parameter names but there should be that many.

Here's what I suggest: go to the part in your script that you referenced. The:


SPS.Setup('fally_dung_001', RUNESCAPE_OTHER);

And change that to:


SPS.Setup('fally_dung_001', RUNESCAPE_OTHER, 5, 500, 0.5);

Where (IIRC) the 5 is accuracy, the 500 is tolerance, and the 0.5 is match percent (50%).

If you run into problems, increase 5 to 6, decrease 500 to 450, increase 0.5 to 0.6, and see what happens. It should get more accurate (but slightly slower) the more you change those values in the direction I've indicated. Accuracy up, Tolerance down, MatchPercent up. I don't know the caps, but I would keep accuracy lower than 10, tolerance above a couple hundred, and matchpercent below 1 (0.9 is probably all you want to go up to).


Okay. I tried using the same parameters you had. But it didn't work.

These are currently working, BUT it takes 14-17 seconds to find location.
SPS.setup('fally_dung_001', RUNESCAPE_OTHER, 1, 100, 0.0);
SPSAnyAngle := False;

– sps.getPlayerPos(): result = {X = 111, Y = 190}, took 14688 ms

From: 3Garrett3
Edit: Note that all of these changes I'm suggesting are in your own script (only referencing the include because I can't remember the names for things off the top of my head).


I got that after you had shown me about the SPS.setup in my script.:duh: Forgot all about that call! Thanks for clearing it up for me, I didn't think (at first) that there are extra parameters for the SPS.setup call. Thought I simply just used that to reference the PNG file. LOL

3Garrett3

2014-11-10 16:32:10

From: agent007
Okay. I tried using the same parameters you had. But it didn't work.

These are currently working, BUT it takes 14-17 seconds to find location.
SPS.setup('fally_dung_001', RUNESCAPE_OTHER, 1, 100, 0.0);
SPSAnyAngle := False;

– sps.getPlayerPos(): result = {X = 111, Y = 190}, took 14688 ms



I got that after you had shown me about the SPS.setup in my script.:duh: Forgot all about that call! Thanks for clearing it up for me, I didn't think (at first) that there are extra parameters for the SPS.setup call. Thought I simply just used that to reference the PNG file. LOL


Taking the setup parameters to any of the extremes (~0 or 10 accuracy (I think), Low tolerance, and 0 or 1 matchpercent) will have a significant performance impact on your script. I suggest staying as close to the middle as possible. You want high accuracy, low tolerance, high match percent (I think, but there's no tutorial around to suggest which direction is correct).

You should continue to play around with the settings to see if you can get something to work in the range of what I suggested. I wouldn't go as low as you have on any of the values because (as you found out) it has a big impact on performance.

agent007

2014-11-10 16:36:14

From: 3Garrett3
Taking the setup parameters to any of the extremes (~0 or 10 accuracy (I think), Low tolerance, and 0 or 1 matchpercent) will have a significant performance impact on your script. I suggest staying as close to the middle as possible. You want high accuracy, low tolerance, high match percent (I think, but there's no tutorial around to suggest which direction is correct).

You should continue to play around with the settings to see if you can get something to work in the range of what I suggested. I wouldn't go as low as you have on any of the values because (as you found out) it has a big impact on performance.


:spongebob: Thanks. Great learning experience, it is going to help me out a lot with my future scripts for sure.

I am very close to have this the way I want it.

When I get it satisfactory I will post back and let you know what worked best for me!



EDIT:


Okay so that was quick!

  
SPS.setup('fally_dung_001', RUNESCAPE_OTHER, 5, 300, 0.0);
SPSAnyAngle := False;

This works perfectly. Couldn't ask for a better result really.

This is the longest it has taken to locate the position now!
– sps.getPlayerPos(): result = {X = 190, Y = 225}, took 78 ms

3Garrett3

2014-11-10 16:49:09

From: agent007
:spongebob: Thanks. Great learning experience, it is going to help me out a lot with my future scripts for sure.

I am very close to have this the way I want it.

When I get it satisfactory I will post back and let you know what worked best for me!



EDIT:


Okay so that was quick!

  
SPS.setup('fally_dung_001', RUNESCAPE_OTHER, 5, 300, 0.0);
SPSAnyAngle := False;

This works perfectly. Couldn't ask for a better result really.

This is the longest it has taken to locate the position now!
– sps.getPlayerPos(): result = {X = 190, Y = 225}, took 78 ms


I'm glad that you found something that worked! Feel free to PM me if you need anything else!