Hello everybody!
In order to help myself learn some scripting (and hopefully eventually some perl so I can remake these more efficiently once I am done) I am working on writing a pack of macros to share with the community which will be released once i have worked out a few more bugs in the leveling script and finished first Job changes. Right now however I am working on a vending macro that will automatically:
- setup in desired location
- restock on items when you sell out first by checking storage and then if storage
is out of the item it will go to a specified NPC vendor
- return to desired location to set shop back up
- repeat indefinitely
- set up a shop with permanent inventory so as to be able to buy discount leveling
items with other bots being run at the same time while saving much money and
funneling Zeny to the merchant.
The code chunk I am posting up is the inventory check where it is supposed to check storage for the item, if item does not exist in storage it should go to the npc instead.
The issue i am having is even when storage is at '0' it will go there anyways instead of going to the NPC. I believe the cause of this is that if the storage is not actively open it shows a value of -1. I would just use this value, except that it does not actually tell me if the item exists in storage or not, and in order to make use of a storage check it seems I would have to make it open storage, then check contents of storage and if 0 then go to NPC. I would like to avoid having to go to storage first as it wastes a lot of zenny....which as a money making profile would be kind of pointless.
If anyone could give me some advice on how to get the contents of storage without having to be actively at it I would greatly appreciate it as this is the first hurdle I have come across I just have not been able to solve myself via forum searching and web scrubbing.
The following is the chunk of code I am currently having trouble with.
Code: Select all
macro InvCheck {
if (@cartamount (Item Choice) == 0) (goto get) #If Red Potions in Cart is = 0 go to storage script#
if ((@storamount (Item Choice) == 0) && (@cartamount (Item Choice) == 0)) (goto get2) ###If Storage and Cart both = 0 then go to shop script###
call move_to_spot #when all "if" conditions have been completed, goto next macro
:get
pause 2
do closeshop
pause 3
do move payon www xxx
pause 2
do talknpc yyy zzz c r1 n
pause 2
do storage addfromcart Red Potion
pause 1
do storage gettocart @storage (Red Potion) @eval (928 - @cartamount (ItemChoice))
pause 10
call move_to_spot
stop
:get2
pause 2
do closeshop
pause 3
do move uuu vvv
pause 2
talknpc sss ttt b n
pause 2
do buy 1 @eval (500 - @cartamount (Item Choice))
pause 3
do cart add @inventory (Item Choice) @invamount (Item Choice)
pause 10
do cart add Item Choice
pause 2
talknpc sss ttt b n
pause 2
do buy 1 @eval (928 - @cartamount (Item Choice))
pause 3
do cart add @inventory (Red Potion) @invamount (Item Choice)
pause 10
do cart add Item Choice
pause 10
call InvCheck
stop
}
Click on the replace tab and replace the following with values for the proper values.
sss ttt = Merchant NPC coordinates (example: 159 96 for Payon Tool Merchant)
uuu vvv = Location near Merchant NPC (example: 159 93 to get near Payon Tool Merchant)
www xxx = Location near Storage NPC
yyy zzz = Storage NPC
Item Choice = Self Explanatory (example: Red Potion)
The only solution I have come up with so far is to move the storage check into ":get"
and if it =0 while storage open then immediately go to ":get2" like the following.
Code: Select all
:get
pause 2
do closeshop
pause 3
do move payon www xxx
pause 2
do talknpc yyy zzz c r1 n
pause 2
if ((@storamount (Item Choice) == 0) (goto get2)
pause 2
do storage addfromcart Red Potion
pause 1
do storage gettocart @storage (Red Potion) @eval (928 - @cartamount (ItemChoice))
pause 10
call move_to_spot