Bank Withdrawal (script): Difference between revisions

From Elanthipedia
Jump to navigation Jump to search
(Created page with '{{Script |cat=utility |fe=Genie |auth=Isharon }} This script withdraws an exact amount from the bank, using the fewest possible coins. (You must be at a bank te…')
 
No edit summary
Line 61: Line 61:


end:
end:
send wealth</pre>
send wealth
waitforre ^Wealth:$
put #parse SCRIPT DONE
exit</pre>

Revision as of 16:25, 6 December 2014

Bank Withdrawal (script)
Category utility
Front-end Genie
Author Isharon


This script withdraws an exact amount from the bank, using the fewest possible coins. (You must be at a bank teller.)

Syntax

.WD %1

%1 equals the number (in coppers) that you want to withdraw. For example, if you want to withdraw 103,496 Kronars, type .WD 103496. The script will withdraw 10 plats, 3 gold, 4 silver, 9 bronze, and 6 coppers.

Script

evalmath Total %1
var Copper 0
var Bronze 0
var Silver 0
var Gold 0
var Platinum 0

evalmath Platinum floor(%Total / 10000)
evalmath Gold floor((%Total-(%Platinum*10000)) / 1000)
evalmath Silver floor((%Total-(%Platinum*10000)-(%Gold*1000)) / 100)
evalmath Bronze floor((%Total-(%Platinum*10000)-(%Gold*1000)-(%Silver*100)) / 10)
evalmath Copper %Total-(%Platinum*10000)-(%Gold*1000)-(%Silver*100)-(%Bronze*10)

if %Platinum > 0 then gosub withdrawp
if %Gold > 0 then gosub withdrawg
if %Silver > 0 then gosub withdraws
if %Bronze > 0 then gosub withdrawb
if %Copper > 0 then gosub withdrawc
goto end

withdrawp:
send withdraw %Platinum platinum
waitforre ^The clerk counts
return

withdrawg:
send withdraw %Gold gold
waitforre ^The clerk counts
return

withdraws:
send withdraw %Silver silver
waitforre ^The clerk counts
return

withdrawb:
send withdraw %Bronze bronze
waitforre ^The clerk counts
return

withdrawc:
send withdraw %Copper copper
waitforre ^The clerk counts
return

end:
send wealth
waitforre ^Wealth:$
put #parse SCRIPT DONE
exit