PDA

View Full Version : Anyone interested in creating a MAIL script?



nocturnix
03-15-2023, 03:40 AM
Hold item in your hand. ;mail <postage> target

Any city, picks box, sends.

Bonus for ;mail check function.

Tgo01
03-15-2023, 04:44 AM
I've never gotten around to playing with the in game mail system. Sounded more complicated than it needed to be when they released it. What all is involved? Don't you have to buy stamps and pay more silver based on item weight or something?

nocturnix
03-15-2023, 07:35 AM
I've never gotten around to playing with the in game mail system. Sounded more complicated than it needed to be when they released it. What all is involved? Don't you have to buy stamps and pay more silver based on item weight or something?

Same man. But now I have a use case for my characters. I bought a crucible, so i want to start smelting down stuff i find. I have to mail that stuff to my smelter with as little hassle as possible.

The mail system was surprisingly simple. Scripting it would be a breeze. You could even do it in Wrayth scripting but lich would be nicer.

So you:
1. go to the mail place
2. order a box from the merchant there
3. put your item in the box, close it
4. then mail <priority> <target>

Prices are on the wiki here: https://gswiki.play.net/Mail_system

Once in the mail room you can activate the mail commands as follows

MAIL CHECK - checks your received mail
MAIL COLLECT {stamp #} - collects a parcel mailed to you
MAIL DND {on|off} - toggles do not disturb on or off
MAIL RETRIEVE {stamp #} - retrieves a sent parcel that the recipient has not picked up
MAIL ESTIMATE {item} - estimates the cost of sending the designated item
MAIL REJECT {stamp #} - returns a mail item to its sender
MAIL SEND {name} - send the item in your hands (prioritizing right)
to the designated person's mailbox
MAIL SEND {name} COD {amount} - sends mail, requests payment on delivery
MAIL STATUS - checks the status of your sent mail

Update: i'm not sure why the wiki talks about stamps. I dont believe i did anything at all with stamps. Maybe its a flavor thing? Or maybe the wiki is outdated.

Tgo01
03-15-2023, 01:08 PM
Yeah maybe they got rid of stamps because people complained about the unnecessary hassle.

Slark
03-17-2023, 09:22 AM
The mail clerk will do all the stamp stuff for you. I think it's slightly more expensive, but we're talking a few hundred silvers more expensive - nothing massive. That change came out a few months ago.

Tgo01
03-21-2023, 01:55 AM
Alright, wrote up a simple little script:

Reason you have to specify which room you mail packages from is because the required room in Icemule isn't tagged at all and ;go2 mail brings you to a room you can't mail packages from. So not sure if the other towns aren't tagged properly or not so it's an option there.

Just have the item you want to mail in either hand, be sure you have one hand free, and specify the name of the person you are mailing to when starting the script. Example: ;mail dreaven



order_number = 4 #Order number of the shipping container you want to use.
get_silvers_from_bank_first = true #Enter true to have script get silvers from bank first. Enter nil to have it skip going to bank.
amount_of_silvers_to_get_from_bank = 30000 #Enter amount of silvers script will withdraw from bank. Script always deposits all silvers you have before withdrawing.
room_number_to_mail_packages_from = 30187 #Room number in the town you can mail packages from.
#Mail Speeds:
#standard = 60 minutes
#express = 20 minutes
#first = immediate
mail_speed = "first"

if checkright && checkleft
echo "You need one free hand to run this script. Hold just the one item you want to mail."
elsif checkright.nil? && checkleft.nil?
echo "You must be holding the item you want to mail."
elsif script.vars[1].nil?
echo "You must specify the name of the person you are sending to. For example: ;mail Dreaven"
else
if checkright
item_to_mail = checkright
else
item_to_mail = checkleft
end
if get_silvers_from_bank_first
start_script "go2", ["bank"]
wait_while{ running? "go2" }
fput "depo all"
fput "withdraw #{amount_of_silvers_to_get_from_bank} silvers"
end
start_script "go2", [room_number_to_mail_packages_from]
wait_while{ running? "go2" }
fput "order #{order_number}"
fput "buy"
if checkright != item_to_mail
fput "put my #{item_to_mail} in my #{checkright}"
fput "close my #{checkright}"
else
fput "put my #{item_to_mail} in my #{checkleft}"
fput "close my #{checkleft}"
end
2.times{ fput "mail send #{script.vars[1]} #{mail_speed}" }
end

Alastir
03-21-2023, 11:37 PM
Alright, wrote up a simple little script:

Reason you have to specify which room you mail packages from is because the required room in Icemule isn't tagged at all and ;go2 mail brings you to a room you can't mail packages from. So not sure if the other towns aren't tagged properly or not so it's an option there.

Just have the item you want to mail in either hand, be sure you have one hand free, and specify the name of the person you are mailing to when starting the script. Example: ;mail dreaven



order_number = 4 #Order number of the shipping container you want to use.
get_silvers_from_bank_first = true #Enter true to have script get silvers from bank first. Enter nil to have it skip going to bank.
amount_of_silvers_to_get_from_bank = 30000 #Enter amount of silvers script will withdraw from bank. Script always deposits all silvers you have before withdrawing.
room_number_to_mail_packages_from = 30187 #Room number in the town you can mail packages from.
#Mail Speeds:
#standard = 60 minutes
#express = 20 minutes
#first = immediate
mail_speed = "first"

if checkright && checkleft
echo "You need one free hand to run this script. Hold just the one item you want to mail."
elsif checkright.nil? && checkleft.nil?
echo "You must be holding the item you want to mail."
elsif script.vars[1].nil?
echo "You must specify the name of the person you are sending to. For example: ;mail Dreaven"
else
if checkright
item_to_mail = checkright
else
item_to_mail = checkleft
end
if get_silvers_from_bank_first
start_script "go2", ["bank"]
wait_while{ running? "go2" }
fput "depo all"
fput "withdraw #{amount_of_silvers_to_get_from_bank} silvers"
end
start_script "go2", [room_number_to_mail_packages_from]
wait_while{ running? "go2" }
fput "order #{order_number}"
fput "buy"
if checkright != item_to_mail
fput "put my #{item_to_mail} in my #{checkright}"
fput "close my #{checkright}"
else
fput "put my #{item_to_mail} in my #{checkleft}"
fput "close my #{checkleft}"
end
2.times{ fput "mail send #{script.vars[1]} #{mail_speed}" }
end


I uploaded this as mail.

;repos download mail --game=any

Tgo01
03-23-2023, 04:00 AM
Yay updates!

Script will now state how much silvers you spent every time you send a package:



|-------------------------------------------------|
|Service Cost |
|-------------------------------------------------|
|Box 900 |
|Shipping 5,350 |
|Total 6,250 |
|-------------------------------------------------|


Script can now automatically collect all of your incoming packages via using the check command line variable, for example ;mail check

When started the script will run to the nearest post office, collect each package you have waiting, gather all of the items inside and STOW them all, then throw away the empty package. Script will NOT collect packages that are COD. The script will then note each package you received, who it was from, and what was inside, if a package is COD it will state it did not pick up the package and will say how much the COD of that package is.



-------------------------------------------------
Package number: 123002323
Sender: Vonaq
Contents:
yellow zircon
-------------------------------------------------


-------------------------------------------------
Package number: 123002319
Sender: Vonaq
Contents:
This package is payment upon delivery and was not collected. The COD is 500
-------------------------------------------------


-------------------------------------------------
Package number: 123002324
Sender: Vonaq
Contents:
snowflake zircon
-------------------------------------------------


Script code:



order_number = 4 #Order number of the shipping container you want to use.
get_silvers_from_bank_first = true #Enter true to have script get silvers from bank first. Enter nil to have it skip going to bank.
amount_of_silvers_to_get_from_bank = 30000 #Enter amount of silvers script will withdraw from bank. Script always deposits all silvers you have before withdrawing.
room_number_to_mail_packages_from = 30187 #Room number in the town you can mail packages from.
#Mail Speeds:
#standard = 60 minutes
#express = 20 minutes
#first = immediate
mail_speed = "first"

if script.vars.any?{ |i| i =~ /check/i }
all_mail_received = Hash.new
package_numbers_and_names = Hash.new
fput "stow left" if checkleft
fput "stow right" if checkright
start_script "go2", ["mail"]
wait_while{ running? "go2" }
fput "mail check"
while line = get
if line =~ /I'm sorry, .*, but it doesn't appear that anything has come in for you.|If you'd like to retrieve one of your parcels/
break
elsif line =~ /(\d+)\s*([a-zA-Z]+)\s+/
package_number = $1
sender = $2
package_numbers_and_names.store(package_number, :number_package => package_number, :package_sender => sender)
end
end
if package_numbers_and_names.count == 0
_respond "|-------------------------------------------------|"
_respond "|No mail. |"
_respond "|-------------------------------------------------|"
else
package_numbers_and_names.each{ |key,value|
fput "mail collect #{package_numbers_and_names[key][:number_package]}"
while line = get
if line =~ /They disappear for a little while before returning with .*, which they hand to you./
container = GameObj.right_hand
fput "open ##{container.id}"
fput "look in ##{container.id}"
wait_until { container.contents }
package_all_contents = Array.new
container.contents.each{ |i| package_all_contents.push(i.name) }
all_mail_received.store(package_numbers_and_names[key][:number_package], :number_package => package_numbers_and_names[key][:number_package], :package_sender => package_numbers_and_names[key][:package_sender], :package_contents => package_all_contents)
container.contents.each{ |i|
fput "get ##{i.id}"
fput "stow ##{i.id}"
}
fput "throw #{checkright}"
break
elsif line =~ /has been marked for payment upon delivery at a cost of (.*) silvers? by its sender/
cod_silver = $1
all_mail_received.store(package_numbers_and_names[key][:number_package], :number_package => package_numbers_and_names[key][:number_package], :package_sender => package_numbers_and_names[key][:package_sender], :package_contents => "This package is payment upon delivery and was not collected. The COD is #{cod_silver}.")
break
end
end
}
all_mail_received.each{ |key,value|
_respond
_respond "-------------------------------------------------"
_respond "Package number: #{all_mail_received[key][:number_package]}"
_respond "Sender: #{all_mail_received[key][:package_sender]}"
_respond "Contents:"
if all_mail_received.kind_of?(Array)
all_mail_received[key][:package_contents].each{ |i| _respond i }
else
_respond all_mail_received[key][:package_contents]
end
_respond "-------------------------------------------------"
_respond
}
end
else
if checkright && checkleft
echo "You need one free hand to run this script. Hold just the one item you want to mail."
elsif checkright.nil? && checkleft.nil?
echo "You must be holding the item you want to mail."
elsif script.vars[1].nil?
echo "You must specify the name of the person you are sending to. For example: ;mail Dreaven"
else
if checkright
item_to_mail = checkright
else
item_to_mail = checkleft
end
if get_silvers_from_bank_first
start_script "go2", ["bank"]
wait_while{ running? "go2" }
fput "depo all"
fput "withdraw #{amount_of_silvers_to_get_from_bank} silvers"
end
start_script "go2", [room_number_to_mail_packages_from]
wait_while{ running? "go2" }
fput "order #{order_number}"
while line = get
if line =~ /(\d+|\d+,\d+) silver/ || line =~ /price to (.*)\.\"/
box_cost = $1
elsif line =~ /You may order a QUANTITY of this item/
break
end
end
fput "buy"
if checkright != item_to_mail
fput "put my #{item_to_mail} in my #{checkright}"
fput "close my #{checkright}"
else
fput "put my #{item_to_mail} in my #{checkleft}"
fput "close my #{checkleft}"
end
fput "mail send #{script.vars[1]} #{mail_speed}"
while line = get
if line =~ /cost (.*) silvers? based/
shipping_cost = $1
break
end
end
fput "mail send #{script.vars[1]} #{mail_speed}"
box_text = "|Box #{box_cost}"
(32 - box_cost.length).times{ box_text += " " }
box_text += "|"

shipping_text = "|Shipping #{shipping_cost}"
(32 - shipping_cost.length).times{ shipping_text += " " }
shipping_text += "|"

total_cost = (box_cost.delete(",").to_i + shipping_cost.delete(",").to_i).to_i.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
total_text = "|Total #{total_cost}"
(32 - total_cost.length).times{ total_text += " " }
total_text += "|"
_respond "|-------------------------------------------------|"
_respond "|Service Cost |"
_respond "|-------------------------------------------------|"
_respond box_text
_respond shipping_text
_respond total_text
_respond "|-------------------------------------------------|"
end
end

nocturnix
05-11-2023, 01:57 AM
This sounds great! I will try it out next time I'm in game, been working at an actual office lately so have less time to login but should on weekend or so.

nocturnix
05-13-2023, 03:09 AM
It seems to be using the wrong room number in Teras. Can I specify the mail room number?

I tried:

;mail name RN

But i don't think that works.

FYI teras mail room number is: 30290. ;go mail works there.

Tgo01
05-13-2023, 03:16 AM
I didn't use ;go2 mail in the script because for Icemule at least that brings you to the wrong room.

You have to edit the values of the first 4 variables/lines in the script to make it work properly.

nocturnix
05-13-2023, 04:27 AM
Seems to get stuck here:


Frae exclaims, "Sold for 1,000 silvers!"
Frae takes the 1,000 silvers you offer in payment.
He hands you a large burlap shipping sack and says, "Here's your purchase. Thanks for your patronage."
>
[mail]>put my trident in my sack
>
You put an acid-stained razern trident in your burlap shipping sack.
>
[mail]>close my sack
You close a large burlap shipping sack.
>
[mail]>mail send redforge first
You beckon a doddering dwarven postal clerk over and ask him to send a large burlap shipping sack to Redforge. He says, "Sure, I can send the sack to Redforge. It'll cost 7,350 silvers based on its weight and priority."


If you're certain you'd like to send a large burlap shipping sack to Redforge, enter MAIL SEND REDFORGE again within 30 seconds.
>MAIL SEND REDFORGE
You must specify a mailing speed (standard, express, or first) because the sack does not have a stamp on it.

Tgo01
05-13-2023, 04:40 AM
Darn NPCs saying different things.

Change the following line:

if line =~ /will cost (.*) silvers? based/

To this:

if line =~ /cost (.*) silvers? based/

Gelston
05-15-2023, 08:16 AM
If you don't rename your script to femail you are a sexist.

Tgo01
05-15-2023, 04:02 PM
If you don't rename your script to femail you are a sexist.

:(