Achaean Withdraw Exact Gold from Bank

Share your scripts and packages with other Mudlet users.
Post Reply
Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Achaean Withdraw Exact Gold from Bank

Post by Wennef »

I was trying to make mudlet versions of what I have in zmud. Please check if it can be made better. Thanks!
Attachments
Withdraw Exact Amount.xml
(1.5 KiB) Downloaded 352 times

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Achaean Withdraw Exact Gold from Bank

Post by Vadi »

It's a good attempt and works, but you do not want to be using global variables. here is a reworked version that passes the value directly to the function for use, and localizes the returns result - so 'num' only exists when that trigger runs and is gone after.
Code: [show] | [select all] lua
function round(num)  
	if num >= 100 then
		rounded = math.floor(num + 0.5)
    	return rounded
	elseif num < 100 then
		rounded = math.ceil(num + 0.5)
    	return rounded
	end
end

local num = round(tonumber(matches[2])/0.995)
send("withdraw " .. num)

Wennef
Posts: 43
Joined: Sun Apr 11, 2010 3:48 am

Re: Achaean Withdraw Exact Gold from Bank

Post by Wennef »

Thanks! I'll change it in mine for now!

XD not that I need to change the xml thing since Vadi's reworked is just what it is now.

Post Reply