Log in

View Full Version : Runecape inventory count???



CRASH_OVERRIDE
11-25-2012, 10:40 AM
Hey i have a really awkward question to ask in regards to scripting with Simba for Runescape.

Basically i am working on a script. It works great. I am working on adding a feature that counts the gems acquired whilst mining.

I have no issues with progress reports. But i am having issues on figuring out a way to actually count what the gem is and how to actually count it?

I guess i would identify it using a DTM. But how do you actually count this and add it to a progress report?

If i add Inc(SapphireMined); to the bottom of my mining ore procedure then its going to say i mined X amount of ore in my proggy and X amount of "Sapphires:" But its going to use the ore count on the sapphire count so it will say "Ore Mined: 28", "Sapphires: 28" and it wont actually count sapphires.

So is their a way you can count gems(search inv) before banking and add them to the progress report that way?

I really am after some ideas examples please.

Cheers.

-CO.

Markus
11-25-2012, 10:42 AM
SapphireMined := SapphireMined + CountInv(....);
Replace .... with appropriate parameters, iirc CountInv accepts bitmaps and dtms.

YoHoJo
11-25-2012, 10:56 AM
^Not exactly right?
It would count way too many because it would be adding all new counts (including already counted ones) to the new count? Get me?

Open up inventory.simba file and you'll zee tons of useful functions in there.

CRASH_OVERRIDE
11-25-2012, 11:08 AM
Hrmm...

Im not sure how to do this then:/

Theirs too many options in include.simba....

I am thinking something along the lines of "ExistsItemDTM" or "InvCount" or "CountItems"?

Flight
11-25-2012, 11:10 AM
Try something like this:


IncEx(SapphireMined, CountItems('dtm', DTM_Sapphire, []));

riwu
11-25-2012, 11:11 AM
I'd use CountItems. Make a DTM of the gems.
Then just call like IncEx(TotalGemMined, CountItems()); before you bank.

YoHoJo
11-25-2012, 11:13 AM
Actually Markus after reading OP I think that will work just fine.
Make a DTM for each gem.
Before banking do what Markus said.
Exists would just result in a true or false you need to use something like CountItem or similar to that.
Look inside inventory.simba for the functions that count and return an integer as the result.

CRASH_OVERRIDE
11-25-2012, 11:17 AM
Riwu, if i did that how would you include that for proggy?

riwu
11-25-2012, 11:24 AM
Declare the variable TotalGemMined globally as integer. Then you can just call it in your proggy like:
writeln('Total Gem mined: ' + ToStr(TotalGemMined));

Note that this only makes sense if you are banking. Otherwise it shouldn't be added by the previous value.

CRASH_OVERRIDE
11-25-2012, 11:53 AM
GR!

Im failing soo bad here.

All it needs to do is count a gem based on its dtm before i bank it. Which one of the above is best to use?

I tried all the above i probably am not doing it right...

IncEx(SapphireMined, CountItems('mggAAAHicY2NgYEgB4iggTgPiXCBOhfKToXQkV C4HKscvlA8kmTDwfwbsgBEHhgAARsQGQw==', DTM_Sapphire, []));

Does CountInv even exist?

Doesnt even work:(

slushpuppy
11-25-2012, 02:11 PM
You can try something like this:


var lastCount, totalSapphires : Integer;

procedure checkSapphire;
var tmp : Integer;
begin
tmp := CountItems(SaphDTM,'dtm',[TOL]);
if (tmp < lastCount) then
begin
totalSapphires := totalSapphires + lastCount;

end;
lastCount := tmp;
end;




this should give you very accurate count at the expense that you will almost certainly be 1 invent count less.

riwu
11-25-2012, 02:17 PM
GR!

Im failing soo bad here.

All it needs to do is count a gem based on its dtm before i bank it. Which one of the above is best to use?

I tried all the above i probably am not doing it right...

IncEx(SapphireMined, CountItems('mggAAAHicY2NgYEgB4iggTgPiXCBOhfKToXQkV C4HKscvlA8kmTDwfwbsgBEHhgAARsQGQw==', DTM_Sapphire, []));

Does CountInv even exist?

Doesnt even work:(
It should be:

DTM_Sapphire:= DTMFromString('mggAAAHicY2NgYEgB4iggTgPiXCBOhfKToX QkVC4HKscvlA8kmTDwfwbsgBEHhgAARsQGQw==');
IncEx(SapphireMined, CountItems('dtm', DTM_Sapphire, []));
FreeDTM(DTM_Sapphire);

Although why would you only want to count sapphire, but not emerald etc?

Flight
11-25-2012, 03:15 PM
I got your PM mate, but I decided just to post my reply here, so here it is.

Oh it's quite simple, you'd be surprised. Let me explain.

[Includes/SRL/SRL/core/inventory.simba]

Go down to the "CountItems" function and you'll get an explanation for it.

function CountItems(ItemType: string; Identifier: Integer; tol: TIntegerArray): Integer;


That means the parameters for this function are:

ItemType ('dtm', 'bitmap', 'color): We'll be using a DTM, so for this parameter simply put 'dtm' (including ' ')
Identifier: The actual DTM/Bitmap/Color code goes here, in your case DTM_Sapphire
Tol: Tolerance (only used for bitmaps and colors, NOT DTMs)


And this function will return the number of that item found within the inventory. Now that you know how to use that function, let's put it to use in the script. Here's what one version might look like:

{$DEFINE SMART8}
{$I SRL/SRL.Simba}

Var
DTM_Sapphire,SapphireCount: Integer;

Procedure LoadVariables;
begin
DTM_Sapphire := DTMFromString('Put your sapphire dtm string here');
//No need to set "SapphireCount" to 0 here, it's automatically set to 0 when the script starts
end;

Procedure DoBanking;
var
SapCnt: Integer; //This is reset to 0 every time this procedure is called
begin
WalkToBank;
SapCnt := CountItems('dtm', DTM_Sapphire, []); //"SapCnt" now equals the number of sapphire DTMs found in the inventory
if (SapCnt > 0) then
Writeln('We mined '+ToStr(SapCnt)+' sapphires this load!');

IncEx(SapphireCount, SapCnt); //This inceases "SapphireCount" by whatever SapCnt equals

if (SapphireCount > 0) then
Writeln('We have mined a total of '+ToStr(SapphireCount)+' sapphires!');

OpenBank;
DepositStuff;
CloseBank;
end;



begin
SetupSRL;

LoadVariables; //Make sure to actually load our script variables

DoBanking;
end.

I tired to explain everything out as much as I could. If you still have questions post here and I'll help however I can.

CRASH_OVERRIDE
11-26-2012, 06:09 AM
WOW, Cheers Flight.

See this is where i fail on this... I always think i need to use every option listed in the function example :(

@ Riwu, I am only doing sapphire because i am doing each gem separately. So, naturally when i understand how to do one i just change a few variables and settings her and their and "BINGO".

Cheers guys, Really appreciate the help!.