diff options
| author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-28 13:48:33 +0100 |
|---|---|---|
| committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-28 13:48:33 +0100 |
| commit | eb6aca8b4a67ef55108231e71ff29a18a29bf5ae (patch) | |
| tree | f891914d25cae2cdaa24392381436a287340651e /builtin/game | |
| parent | 8de51dae97aa2fe6ea02e4cf437bfe2b2a38eb06 (diff) | |
| parent | f1d72d212a0661588be27003069abf4bd8092e55 (diff) | |
| download | dragonfireclient-eb6aca8b4a67ef55108231e71ff29a18a29bf5ae.tar.xz | |
Merged Minetest
Diffstat (limited to 'builtin/game')
| -rw-r--r-- | builtin/game/chat.lua | 22 | ||||
| -rw-r--r-- | builtin/game/falling.lua | 10 | ||||
| -rw-r--r-- | builtin/game/features.lua | 1 | ||||
| -rw-r--r-- | builtin/game/item.lua | 3 | ||||
| -rw-r--r-- | builtin/game/item_entity.lua | 5 | ||||
| -rw-r--r-- | builtin/game/misc.lua | 6 | ||||
| -rw-r--r-- | builtin/game/register.lua | 5 |
7 files changed, 44 insertions, 8 deletions
diff --git a/builtin/game/chat.lua b/builtin/game/chat.lua index aae811794..945707623 100644 --- a/builtin/game/chat.lua +++ b/builtin/game/chat.lua @@ -58,6 +58,11 @@ core.register_on_chat_message(function(name, message) param = param or "" + -- Run core.registered_on_chatcommands callbacks. + if core.run_callbacks(core.registered_on_chatcommands, 5, name, cmd, param) then + return true + end + local cmd_def = core.registered_chatcommands[cmd] if not cmd_def then core.chat_send_player(name, "-!- Invalid command: " .. cmd) @@ -66,8 +71,17 @@ core.register_on_chat_message(function(name, message) local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs) if has_privs then core.set_last_run_mod(cmd_def.mod_origin) - local _, result = cmd_def.func(name, param) - if result then + local success, result = cmd_def.func(name, param) + if success == false and result == nil then + core.chat_send_player(name, "-!- Invalid command usage") + local help_def = core.registered_chatcommands["help"] + if help_def then + local _, helpmsg = help_def.func(name, cmd) + if helpmsg then + core.chat_send_player(name, helpmsg) + end + end + elseif result then core.chat_send_player(name, result) end else @@ -1070,10 +1084,10 @@ core.register_chatcommand("last-login", { local pauth = core.get_auth_handler().get_auth(param) if pauth and pauth.last_login and pauth.last_login ~= -1 then -- Time in UTC, ISO 8601 format - return true, "Last login time was " .. + return true, param.."'s last login time was " .. os.date("!%Y-%m-%dT%H:%M:%SZ", pauth.last_login) end - return false, "Last login time is unknown" + return false, param.."'s last login time is unknown" end, }) diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 714506a5f..8d044beaa 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -52,6 +52,7 @@ core.register_entity(":__builtin:falling_node", { floats = false, set_node = function(self, node, meta) + node.param2 = node.param2 or 0 self.node = node meta = meta or {} if type(meta.to_table) == "function" then @@ -83,6 +84,9 @@ core.register_entity(":__builtin:falling_node", { local textures if def.tiles and def.tiles[1] then local tile = def.tiles[1] + if def.drawtype == "torchlike" and def.paramtype2 ~= "wallmounted" then + tile = def.tiles[2] or def.tiles[1] + end if type(tile) == "table" then tile = tile.name end @@ -143,7 +147,11 @@ core.register_entity(":__builtin:falling_node", { -- Rotate entity if def.drawtype == "torchlike" then - self.object:set_yaw(math.pi*0.25) + if def.paramtype2 == "wallmounted" then + self.object:set_yaw(math.pi*0.25) + else + self.object:set_yaw(-math.pi*0.25) + end elseif (node.param2 ~= 0 and (def.wield_image == "" or def.wield_image == nil)) or def.drawtype == "signlike" diff --git a/builtin/game/features.lua b/builtin/game/features.lua index a15475333..4d3c90ff0 100644 --- a/builtin/game/features.lua +++ b/builtin/game/features.lua @@ -17,6 +17,7 @@ core.features = { area_store_persistent_ids = true, pathfinder_works = true, object_step_has_moveresult = true, + direct_velocity_on_players = true, } function core.has_feature(arg) diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 2c43a8548..768df847b 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -538,8 +538,9 @@ function core.node_dig(pos, node, digger) local diggername = user_name(digger) local log = make_log(diggername) local def = core.registered_nodes[node.name] + -- Copy pos because the callback could modify it if def and (not def.diggable or - (def.can_dig and not def.can_dig(pos, digger))) then + (def.can_dig and not def.can_dig(vector.new(pos), digger))) then log("info", diggername .. " tried to dig " .. node.name .. " which is not diggable " .. core.pos_to_string(pos)) diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index 20dd18044..9b1b23bfd 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -54,8 +54,9 @@ core.register_entity(":__builtin:item", { local max_count = stack:get_stack_max() local count = math.min(stack:get_count(), max_count) local size = 0.2 + 0.1 * (count / max_count) ^ (1 / 3) - local def = core.registered_nodes[itemname] - local glow = def and math.floor(def.light_source / 2 + 0.5) + local def = core.registered_items[itemname] + local glow = def and def.light_source and + math.floor(def.light_source / 2 + 0.5) self.object:set_properties({ is_visible = true, diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 341e613c2..96a0a2dda 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -151,6 +151,12 @@ function core.setting_get_pos(name) end +-- See l_env.cpp for the other functions +function core.get_artificial_light(param1) + return math.floor(param1 / 16) +end + + -- To be overriden by protection mods function core.is_protected(pos, name) diff --git a/builtin/game/register.lua b/builtin/game/register.lua index 1034d4f2b..1f94a9dca 100644 --- a/builtin/game/register.lua +++ b/builtin/game/register.lua @@ -118,6 +118,10 @@ function core.register_item(name, itemdef) end itemdef.name = name + -- default short_description to first line of description + itemdef.short_description = itemdef.short_description or + (itemdef.description or ""):gsub("\n.*","") + -- Apply defaults and add to registered_* table if itemdef.type == "node" then -- Use the nodebox as selection box if it's not set manually @@ -584,6 +588,7 @@ core.unregister_biome = make_wrap_deregistration(core.register_biome, core.clear_registered_biomes, core.registered_biomes) core.registered_on_chat_messages, core.register_on_chat_message = make_registration() +core.registered_on_chatcommands, core.register_on_chatcommand = make_registration() core.registered_globalsteps, core.register_globalstep = make_registration() core.registered_playerevents, core.register_playerevent = make_registration() core.registered_on_mods_loaded, core.register_on_mods_loaded = make_registration() |
