SRL Archive - OSR Help

CoinAmount and CountItems


deathcrow

2013-04-04 14:28:47

I made a script for stealing from a chest and it works so far. I am just working on adding fail-safes.

Sometimes when you "search for traps" on a chest nothing will change in the chat box if it was at the perfect time. The way I have made the script so far it makes it think it successfully looted the chest, which is incorrect.

So I want to make it count how many of a stackable item is in the inventory or/and count how many coins are in the inventory. With this I could make it check to see if there is more of that item/coins than there was before it stole from the chest. If not then it didn't steal and it could try again.


I tried using the builtin function CoinAmount and CountItems but they don't seem to be working properly.

This is the code I have tried:

Procedure CheckInvItem;
Var
ItemsInInv, ItemDTM: Integer;
Begin
ItemDTM := DTMFromString('mWAAAAHicY2FgYHBiYmCwAGJnIPYFYg5GBgYBIP4DlOMD0r3NzQwxoaEMuzZsYFg0bRoDOmBEwyAAALteCME=');
ItemsInInv := CountItems('dtm', ItemDTM, []);
End;

Also, I have tried this:
WriteLn('Coins found: '+toStr(CoinAmount('inventory')));


The first part of the code doesn't get the number of my stackable item in my inventory so I tried doing coins instead (2nd part of code). When it counts the coins it always tells me there are 0 coins in the inventory.


Any ideas?

I appreciate the help! Thank you.

gamer716

2013-04-04 14:59:42

I would look in SRL-OSR/SRL/core/amount.simba
There are two functions that can be useful to you, CoinAmount and GetAmount.

If these don't work, the colors might be broken. You can try to update them or wait for the official SRL release.

deathcrow

2013-04-04 15:16:50

From: gamer716
I would look in SRL-OSR/SRL/core/amount.simba
There are two functions that can be useful to you, CoinAmount and GetAmount.

If these don't work, the colors might be broken. You can try to update them or wait for the official SRL release.


Yes, these don't work properly (at least when I have tried using them). I will see about updating them myself.

I already edited some of the functions in "antirandoms" to make it work better for my script.


EDIT:

I went ahead and edited the CoinAmount and now it works. It doesn't work perfectly however. Sometimes it will only get the first two numbers (out of 3 numbers). But it works correctly most of the time.


The other part of code isn't exactly necessary now. But I would like to see it still work.

I changed it to:

Procedure CheckInvItem;
Var
ItemDTM: Integer;
Begin
ItemDTM := DTMFromString('mWAAAAHicY2FgYHBiYmCwAGJnIPYFYg5GBgYBIP4DlOMD0r3NzQwxoaEMuzZsYFg0bRoDOmBEwyAAALteCME=');
ItemsInInv := CountItemsIn('inv', 'dtm', ItemDTM, []);
writeln('Items found: ' + toStr(ItemsInInv));
End;

It works now but since it is a stackable item it only counts 1 of them, but I will see about changing it to work similar to how the CountCoins works. I may edit the CountCoins a little bit more so that it works correctly more often. (If you have 201 coins it may say that you have 21 coins instead of the correct value.)