-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3edb509
commit cb52421
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ globals = { | |
"minetest", | ||
"technic", | ||
"mail", | ||
"beerchat" | ||
"beerchat", | ||
"atm" | ||
} | ||
|
||
read_globals = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
mtui.register_on_command("atm_transfer", function(data) | ||
if not data.amount then | ||
return { success = false, errmsg = "no amount specified" } | ||
end | ||
|
||
if data.amount <= 0 then | ||
return { success = false, errmsg = "invalid amount" } | ||
end | ||
|
||
if not minetest.player_exists(data.source) then | ||
return { success = false, errmsg = "source player does not exist" } | ||
end | ||
|
||
if not minetest.player_exists(data.target) then | ||
return { success = false, errmsg = "target player does not exist" } | ||
end | ||
atm.read_account(data.source) | ||
atm.read_account(data.target) | ||
|
||
if atm.balance[data.source] < data.amount then | ||
return { success = false, errmsg = "insufficient amount" } | ||
end | ||
|
||
atm.balance[data.source] = atm.balance[data.source] - data.amount | ||
atm.balance[data.target] = atm.balance[data.target] + data.amount | ||
|
||
atm.save_account(data.source) | ||
atm.save_account(data.target) | ||
|
||
return { | ||
success = true, | ||
source_balance = atm.balance[data.source], | ||
target_balance = atm.balance[data.target] | ||
} | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ mesecons_switch, | |
mesecons_lightstone, | ||
mesecons_luacontroller, | ||
digilines, | ||
mooncontroller | ||
mooncontroller, | ||
atm | ||
""" |