Code style changes and typo fixes.

This commit is contained in:
luk3yx 2019-09-19 18:48:39 +12:00
parent a5314b5005
commit d5224e7124
4 changed files with 127 additions and 112 deletions

View File

@ -39,6 +39,9 @@ The following lurkcoin-specific functions and variables exist:
parameters, `success` and `msg`.
- `lurkcoin.server_name`: The account name used to log into lurkcoin.
*Callbacks may or may not be pcall()ed, this is liable to change and you should
not rely on errors bringing down the server or just being logged.*
### Bank API
This mod creates a "universal"™ bank API.

View File

@ -170,8 +170,9 @@ if minetest.get_modpath('currency') then
if not lurkcoin.bank.add(pname, m, 'Deposit') then
player:get_inventory():add_item('main', stack)
end
core.log('action', 'Player ' .. pname .. ' deposts ' ..
stack:to_string() .. ' into an ATM.')
core.log('action', 'Player ' .. pname .. ' deposits ' ..
tostring(m) .. 'Mg (' .. stack:to_string() ..
') into a lurkcoin ATM.')
end
end
inv:set_list(listname, {})
@ -239,9 +240,14 @@ function lurkcoin.show_atm(name, page, params)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == 'lurkcoin:atm' then
if formname ~= 'lurkcoin:atm' then return end
local name = player:get_player_name()
-- These probably don't need to be deleted.
fields._err = nil
fields._exchange_rate = nil
if withdrawls then
if fields.deposit then
return lurkcoin.show_atm(name, 'deposit')
@ -284,6 +290,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
'ERROR: You do not have enough inventory space!')
end
minetest.log('action', 'Player ' .. name .. ' withdraws ' ..
tostring(amount) .. 'Mg (' .. stack:to_string() ..
') from a lurkcoin ATM.')
lurkcoin.bank.subtract(name, amount)
inv:add_item('main', stack)
@ -357,7 +366,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.quit then
open_atms[name] = nil
end
end
end)
minetest.register_on_leaveplayer(function(player)

View File

@ -29,9 +29,12 @@ if not http then
'Please add lurkcoin to secure.http_mods in minetest.conf.')
end
-- Download functions
-- This user agent is not strictly required, however I might do something
-- with the lurkcoin mod version later.
lurkcoin.user_agent = 'Minetest ' .. minetest.get_version().string ..
' (with lurkcoin mod v' .. tostring(lurkcoin.version) .. ')'
-- Download functions
local function get(url, data, callback)
if not data then
data = {}

View File

@ -31,11 +31,12 @@ if not minetest.get_modpath('cloaking') or not cloaking.hide_player then
table.insert(minetest.registered_on_chat_messages, 1, function(name, msg)
if msg:find('[\r\n]') then
minetest.chat_send_player(name,
'Error sending message: https://xkcd.com/327')
'New lines are not permitted in chat messages')
return true
end
end)
-- Also tweak minetest.log because of paranoia.
local log = minetest.log
function minetest.log(level, text)
level = level:gsub('[\r\n]', ' ')