Removed 'Account Info' from ATM menu; now balance is displayed on the main menu

This commit is contained in:
Vitalie Ciubotaru 2016-03-05 23:05:00 +09:00
parent 7543b2890c
commit b6ffef924e

44
atm.lua
View File

@ -4,14 +4,16 @@ local exchange = ...
local atm_form = "global_exchange:atm_form" local atm_form = "global_exchange:atm_form"
local main_menu =[[ local function main_menu(p_name)
size[6,2] local balance = exchange:get_balance(p_name)
button[0,0;2,1;cash;Cash In/Out] local formspec = 'size[6,2]' ..
button[2,0;2,1;info;Account Info] 'label[0,0;' .. p_name .. '\'s account]' ..
button[4,0;2,1;wire;Wire Monies] 'label[0,0.5;Balance: ' .. balance .. ']' ..
button[1,1;4,1;transaction_log;Transaction Log] 'button[0,1;2,1;cash;Cash In/Out]' ..
]] 'button[2,1;2,1;wire;Transfer]' ..
'button[4,1;2,1;transaction_log;History]'
return formspec
end
local function back(x,y) local function back(x,y)
return "button[" .. x .. "," .. y .. ";2,1;main;Back]" return "button[" .. x .. "," .. y .. ";2,1;main;Back]"
@ -68,29 +70,11 @@ function bills2balance(stack, p_name)
return bal return bal
end end
local function info_fs(p_name)
local balance = exchange:get_balance(p_name)
local fs
if not balance then
fs = label(0.5,0.5, "You don't have an account.")
else
fs = label(0.5,0.5, "Balance: " .. balance)
end
return "size[4,3]" .. fs .. back(0.5,2)
end
local function wire_fs(p_name) local function wire_fs(p_name)
local balance = exchange:get_balance(p_name) local balance = exchange:get_balance(p_name)
local fs = "size[4,5]" .. back(0,4) local fs = "size[4,5]" .. back(0,4)
if not balance then
return fs .. label(0.5,0.5, "You don't have an account.")
end
-- To prevent duplicates -- To prevent duplicates
return fs .. field(-100, -100, 0,0, "trans_id", "", unique()) .. return fs .. field(-100, -100, 0,0, "trans_id", "", unique()) ..
label(0.5,0.5, "Balance: " .. balance) .. label(0.5,0.5, "Balance: " .. balance) ..
@ -160,7 +144,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
trans_ids[p_name] = this_id trans_ids[p_name] = this_id
if fields.main then if fields.main then
minetest.show_formspec(p_name, atm_form, main_menu) minetest.show_formspec(p_name, atm_form, main_menu(p_name))
end end
if fields.cash then if fields.cash then
@ -192,10 +176,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end end
if fields.info then
minetest.show_formspec(p_name, atm_form, info_fs(p_name))
end
if fields.wire then if fields.wire then
minetest.show_formspec(p_name, atm_form, wire_fs(p_name)) minetest.show_formspec(p_name, atm_form, wire_fs(p_name))
end end
@ -221,7 +201,7 @@ minetest.register_node("global_exchange:atm", {
}, },
groups = {cracky=2}, groups = {cracky=2},
on_rightclick = function(pos, _, clicker) on_rightclick = function(pos, _, clicker)
minetest.show_formspec(clicker:get_player_name(), atm_form, main_menu) minetest.show_formspec(clicker:get_player_name(), atm_form, main_menu(clicker:get_player_name()))
end, end,
}) })