Page 1 of 1

Checking gold

Posted: Mon Jan 26, 2015 8:41 am
by Desmond
how to make a function that will test the gold?
for example

Code: Select all

if( 30,000 > inventory:itemTotalCount(Gold) ) then

Re: Checking gold

Posted: Mon Jan 26, 2015 9:49 am
by BlubBlab
if( 30000 > getCurrency("gold") )then

Re: Checking gold

Posted: Mon Jan 26, 2015 10:54 am
by Desmond
it does not work correctly even if there is more gold still works

Re: Checking gold

Posted: Mon Jan 26, 2015 11:21 am
by BlubBlab
than you mean:

Code: Select all

if( 30000 <= getCurrency("gold") )then

Re: Checking gold

Posted: Mon Jan 26, 2015 11:45 am
by Desmond
BlubBlab wrote:than you mean:

Code: Select all

if( 30000 <= getCurrency("gold") )then
when the gold in a backpack "30000" then the bot has to go to sleep, but even if more gold still goes to sleep, I even put the ==

Code: Select all

      if( 90000 > getCurrency("gold") )then
	        player:sleep()
		end

Re: Checking gold

Posted: Mon Jan 26, 2015 12:10 pm
by BlubBlab
Than is what I wrote correct:
If I write it down like you speak it will look like this:

Code: Select all

	
Code:
if(  getCurrency("gold") >=  30000 )then
     player:sleep()
end
which has logical the same meaning which I wrote above.

Re: Checking gold

Posted: Mon Jan 26, 2015 1:48 pm
by rock5
I hate to bring this up but I don't see a "gold" option in getCurrency. Desmond, when you tried it, didn't you get the "Invalid currency type." message?

I think you can get the gold using this

Code: Select all

inventory:update()
if (inventory.Money >= 30000) then

Re: Checking gold

Posted: Mon Jan 26, 2015 2:14 pm
by Desmond
well, the very same I have more gold and he still goes to sleep. Should if gold less than "30000" to go to sleep

Re: Checking gold

Posted: Mon Jan 26, 2015 9:15 pm
by rock5
If you have more than 30000 and are using your money and you want to go to sleep when you have less than or equal to 30000 because 30000 is no longer enough, then you use

Code: Select all

if inventory.Money <= 30000 then
or

Code: Select all

if 30000 >= inventory.Money then
They are the same thing.

If you have less than 30000 and you are making money and you want it to go to sleep when it reaches 30000 because it is enough money then you use

Code: Select all

if inventory.Money >= 30000 then
or

Code: Select all

if 30000 <= inventory.Money then
If you think you have it correct and it's still not working then there is probably something else wrong with your file that is not letting this line work.

Re: Checking gold

Posted: Tue Jan 27, 2015 8:31 am
by ZZZZZ
Throw in a RoMScript('GetPlayerMoney("copper"); to check if the inventory.Money function is possibly not working correctly?

Re: Checking gold

Posted: Tue Jan 27, 2015 9:22 am
by rock5
No reason to suspect it doesn't work and it's easy enough to test.

Code: Select all

Command> inventory:update() print(inventory.Money)
122681508
Yep, that's right.

Re: Checking gold

Posted: Tue Jan 27, 2015 12:57 pm
by Desmond

Code: Select all

if 30000 >= inventory.Money then
works thanks "Rock5"
I often cut off Internet whether it is possible to check that when the Internet broke character and then thrown to login to enter?

Re: Checking gold

Posted: Tue Jan 27, 2015 10:55 pm
by rock5
Desmond wrote:I often cut off Internet whether it is possible to check that when the Internet broke character and then thrown to login to enter?
If you are disconnected from the Internet then you can't log back in. You would have to wait for the Internet to be connected again before trying to log back in. I don't think that's possible with what is available at the moment.