Well, a few changes:
## For URLs you may want to use:
visit_url("URL");
## For the adventuring for an item portions, it may be easier to do the "conditions"
if (item_amount($item[XXX]) == 0){
cli_execute("conditions clear");
add_item_condition(1, $item[XXX]);
adventure(my_adventures()...