diff --git a/game_api.txt b/game_api.txt index 774bd1d1..a32f8d5c 100644 --- a/game_api.txt +++ b/game_api.txt @@ -4,18 +4,21 @@ GitHub Repo: https://github.com/minetest/minetest_game Introduction ------------ + The Minetest Game subgame offers multiple new possibilities in addition to the Minetest engine's built-in API, allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes. For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt Please note: - [XYZ] refers to a section the Minetest API - [#ABC] refers to a section in this document - ^ Explanation for line above + + * [XYZ] refers to a section the Minetest API + * [#ABC] refers to a section in this document Bucket API ---------- + The bucket API allows registering new types of buckets for non-default liquids. + bucket.register_liquid( "default:lava_source", -- name of the source node "default:lava_flowing", -- name of the flowing node @@ -27,215 +30,250 @@ The bucket API allows registering new types of buckets for non-default liquids. Beds API -------- + beds.register_bed( - "beds:bed", -- Bed name - def: See [#Bed definition] -- Bed definition + "beds:bed", -- Bed name + def -- See [#Bed definition] ) - beds.read_spawns() -- returns a table containing players respawn positions - beds.kick_players() -- forces all players to leave bed - beds.skip_night() -- sets world time to morning and saves respawn position of all players currently sleeping + * `beds.read_spawns() ` Returns a table containing players respawn positions + * `beds.kick_players()` Forces all players to leave bed + * `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping + +###Bed definition -#Bed definition ---------------- -{ - description = "Simple Bed", - inventory_image = "beds_bed.png", - wield_image = "beds_bed.png", - tiles = { - bottom = {[Tile definition], - ^ the tiles of the bottom part of the bed - }, - top = {[Tile definition], - ^ the tiles of the bottom part of the bed - } - }, - nodebox = { - bottom = regular nodebox, see [Node boxes], -- bottm part of bed - top = regular nodebox, see [Node boxes], -- top part of bed - }, - selectionbox = regular nodebox, see [Node boxes], -- for both nodeboxes - recipe = { -- Craft recipe - {"group:wool", "group:wool", "group:wool"}, - {"group:wood", "group:wood", "group:wood"} + { + description = "Simple Bed", + inventory_image = "beds_bed.png", + wield_image = "beds_bed.png", + tiles = { + bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed. + top = {Tile definition} -- the tiles of the bottom part of the bed. + }, + nodebox = { + bottom = 'regular nodebox', -- bottom part of bed (see [Node boxes]) + top = 'regular nodebox', -- top part of bed (see [Node boxes]) + }, + selectionbox = 'regular nodebox', -- for both nodeboxes (see [Node boxes]) + recipe = { -- Craft recipe + {"group:wool", "group:wool", "group:wool"}, + {"group:wood", "group:wood", "group:wood"} + } } -} Doors API --------- + The doors mod allows modders to register custom doors and trapdoors. -doors.register_door(name, def) -^ name: "Door name" -^ def: See [#Door definition] - -> Registers new door +`doors.register_door(name, def)` -doors.register_trapdoor(name, def) -^ name: "Trapdoor name" -^ def: See [#Trapdoor definition] - -> Registers new trapdoor + * Registers new door + * `name` Name for door + * `def` See [#Door definition] + +`doors.register_trapdoor(name, def)` + + * Registers new trapdoor + * `name` Name for trapdoor + * `def` See [#Trapdoor definition] + +`doors.get(pos)` + + * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}` + * Returns an ObjecRef to a door, or nil if the position does not contain a door + + ###Methods + + :open(player) -- Open the door object, returns if door was opened + :close(player) -- Close the door object, returns if door was closed + :toggle(player) -- Toggle the door state, returns if state was toggled + :state() -- returns the door state, true = open, false = closed + + the "player" parameter can be omitted in all methods. If passed then + the usual permission checks will be performed to make sure the player + has the permissions needed to open this door. If omitted then no + permission checks are performed. + +###Door definition -#Door definition ----------------- -{ description = "Door description", inventory_image = "mod_door_inv.png", - groups = {group = 1}, - tiles_bottom: [Tile definition], - ^ the tiles of the bottom part of the door {front, side} - tiles_top: [Tile definition], - ^ the tiles of the bottom part of the door {front, side} - node_box_bottom = regular nodebox, see [Node boxes], OPTIONAL, - node_box_top = regular nodebox, see [Node boxes], OPTIONAL, - selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL, - selection_box_top = regular nodebox, see [Node boxes], OPTIONAL, - sound_open_door = sound play for open door, OPTIONAL, - sound_close_door = sound play for close door, OPTIONAL, - only_placer_can_open = true/false, - ^ If true, only placer can open the door (locked for others) -} + groups = {choppy = 2}, + tiles = {"mod_door.png"}, -- UV map. + recipe = craftrecipe, + sounds = default.node_sound_wood_defaults(), -- optional + sound_open = sound play for open door, -- optional + sound_close = sound play for close door, -- optional + protected = false, -- If true, only placer can open the door (locked for others) -#Trapdoor definition ----------------- -{ - tile_front = "doors_trapdoor.png", - ^ the texture for the front and back of the trapdoor - tile_side: "doors_trapdoor_side.png", - ^ the tiles of the four side parts of the trapdoor - sound_open = sound to play when opening the trapdoor, OPTIONAL, - sound_close = sound to play when closing the trapdoor, OPTIONAL, - -> You can add any other node definition properties for minetest.register_node, - such as wield_image, inventory_image, sounds, groups, description, ... - Only node_box, selection_box, tiles, drop, drawtype, paramtype, paramtype2, on_rightclick - will be overwritten by the trapdoor registration function -} +###Trapdoor definition + + description = "Trapdoor description", + inventory_image = "mod_trapdoor_inv.png", + groups = {choppy = 2}, + tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor + tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor + sounds = default.node_sound_wood_defaults(), -- optional + sound_open = sound play for open door, -- optional + sound_close = sound play for close door, -- optional + protected = false, -- If true, only placer can open the door (locked for others) Fence API --------- Allows creation of new fences with "fencelike" drawtype. -default.register_fence(name, item definition) - ^ Registers a new fence. Custom fields texture and material are required, as - ^ are name and description. The rest is optional. You can pass most normal - ^ nodedef fields here except drawtype. The fence group will always be added - ^ for this node. +`default.register_fence(name, item definition)` + + Registers a new fence. Custom fields texture and material are required, as + are name and description. The rest is optional. You can pass most normal + nodedef fields here except drawtype. The fence group will always be added + for this node. + +###fence definition -#fence definition name = "default:fence_wood", description = "Wooden Fence", texture = "default_wood.png", material = "default:wood", - groups = {choppy=2, oddly_breakable_by_hand = 2, flammable = 2}, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, sounds = default.node_sound_wood_defaults(), +#Walls API +--------- +The walls API allows easy addition of stone auto-connecting wall nodes. + +walls.register(name, desc, texture, mat, sounds) +^ name = "walls:stone_wall". Node name. +^ desc = "A Stone wall" +^ texture = "default_stone.png" +^ mat = "default:stone". Used to auto-generate crafting recipe. +^ sounds = sounds: see [#Default sounds] + Farming API ----------- + The farming API allows you to easily register plants and hoes. -farming.register_hoe(name, hoe definition) - -> Register a new hoe, see [#hoe definition] +`farming.register_hoe(name, hoe definition)` + * Register a new hoe, see [#hoe definition] -farming.register_plant(name, Plant definition) - -> Register a new growing plant, see [#Plant definition] +`farming.register_plant(name, Plant definition)` + * Register a new growing plant, see [#Plant definition] -#Hoe Definition ---------------- -{ - description = "", -- Description for tooltip - inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image - max_uses = 30, -- Uses until destroyed - material = "", -- Material for recipes - recipe = { -- Craft recipe, if material isn't used - {"air", "air", "air"}, - {"", "group:stick"}, - {"", "group:stick"}, +###Hoe Definition + + + { + description = "", -- Description for tooltip + inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image + max_uses = 30, -- Uses until destroyed + material = "", -- Material for recipes + recipe = { -- Craft recipe, if material isn't used + {"air", "air", "air"}, + {"", "group:stick"}, + {"", "group:stick"}, + } } -} -#Plant definition ------------------ -{ - description = "", -- Description of seed item - inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image - steps = 8, -- How many steps the plant has to grow, until it can be harvested - ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber) - minlight = 13, -- Minimum light to grow - maxlight = default.LIGHT_MAX -- Maximum light to grow -} +###Plant definition + + { + description = "", -- Description of seed item + inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image + steps = 8, -- How many steps the plant has to grow, until it can be harvested + -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber) + minlight = 13, -- Minimum light to grow + maxlight = default.LIGHT_MAX -- Maximum light to grow + } + +Fire API +-------- + +`on_burn(pos)` + + * Called when fire attempts to remove a burning node. + * `pos` Position of the burning node. Screwdriver API --------------- + The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it. -To use it, add the on_screwdriver function to the node definition. -on_rotate(pos, node, user, mode, new_param2) -^ pos: position of the node that the screwdriver is being used on -^ node: that node -^ user: the player who used the screwdriver -^ mode: screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS -^ new_param2: the new value of param2 that would have been set if on_rotate wasn't there -^ return value: false to disallow rotation, nil to keep default behaviour, true to allow +To use it, add the `on_screwdriver` function to the node definition. + +`on_rotate(pos, node, user, mode, new_param2)` + + * `pos` Position of the node that the screwdriver is being used on + * `node` that node + * `user` The player who used the screwdriver + * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS + * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there + * return value: false to disallow rotation, nil to keep default behaviour, true to allow it but to indicate that changed have already been made (so the screwdriver will wear out) -^ use on_rotate = screwdriver.disallow to always disallow rotation -^ use on_rotate = screwdriver.rotate_simple to allow only face rotation + * use `on_rotate = screwdriver.disallow` to always disallow rotation + * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation Stairs API ---------- + The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those delivered with Minetest Game, to keep them compatible with other mods. -stairs.register_stair(subname, recipeitem, groups, images, description, sounds) - -> Registers a stair. - -> subname: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" - -> recipeitem: Item used in the craft recipe, e.g. "default:cobble" - -> groups: see [Known damage and digging time defining groups] - -> images: see [Tile definition] - -> description: used for the description field in the stair's definition - -> sounds: see [#Default sounds] +`stairs.register_stair(subname, recipeitem, groups, images, description, sounds)` -stairs.register_slab(subname, recipeitem, groups, images, description, sounds) - -> Registers a slabs - -> subname: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" - -> recipeitem: Item used in the craft recipe, e.g. "default:cobble" - -> groups: see [Known damage and digging time defining groups] - -> images: see [Tile definition] - -> description: used for the description field in the stair's definition - -> sounds: see [#Default sounds] + * Registers a stair. + * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" + * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble" + * `groups`: see [Known damage and digging time defining groups] + * `images`: see [Tile definition] + * `description`: used for the description field in the stair's definition + * `sounds`: see [#Default sounds] -stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds) - -> A wrapper for stairs.register_stair and stairs.register_slab - -> Uses almost the same arguments as stairs.register_stair - -> desc_stair: Description for stair node - -> desc_slab: Description for slab node +`stairs.register_slab(subname, recipeitem, groups, images, description, sounds)` + + * Registers a slabs + * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" + * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble" + * `groups`: see [Known damage and digging time defining groups] + * `images`: see [Tile definition] + * `description`: used for the description field in the stair's definition + * `sounds`: see [#Default sounds] + +`stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)` + + * A wrapper for stairs.register_stair and stairs.register_slab + * Uses almost the same arguments as stairs.register_stair + * `desc_stair`: Description for stair node + * `desc_slab`: Description for slab node Xpanes API ---------- + Creates panes that automatically connect to each other -xpanes.register_pane(subname, def) - -> subname: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}" - -> def: See [#Pane definition] +`xpanes.register_pane(subname, def)` -#Pane definition ----------------- -{ - textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"}, - ^ More tiles aren't supported - groups = {group = rating}, - ^ Uses the known node groups, see [Known damage and digging time defining groups] - sounds = SoundSpec, - ^ See [#Default sounds] - recipe = {{"","","","","","","","",""}}, - ^ Recipe field only -} + * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}" + * `def`: See [#Pane definition] + +###Pane definition + + { + textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"}, -- More tiles aren't supported + groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups] + sounds = SoundSpec, -- See [#Default sounds] + recipe = {{"","","","","","","","",""}}, -- Recipe field only + } Raillike definitions -------------------- + The following nodes use the group `connect_to_raillike` and will only connect to raillike nodes within this group and the same group value. Use `minetest.raillike_group()` to get the group value. | Node type | Raillike group name -+-----------------------+-------------------- +|-----------------------|--------------------- | default:rail | "rail" | tnt:gunpowder | "gunpowder" | tnt:gunpowder_burning | "gunpowder" @@ -248,168 +286,188 @@ of your node. Default sounds -------------- + Sounds inside the default table can be used within the sounds field of node definitions. -default.node_sound_defaults() -default.node_sound_stone_defaults() -default.node_sound_dirt_defaults() -default.node_sound_sand_defaults() -default.node_sound_wood_defaults() -default.node_sound_leaves_defaults() -default.node_sound_glass_defaults() + * `default.node_sound_defaults()` + * `default.node_sound_stone_defaults()` + * `default.node_sound_dirt_defaults()` + * `default.node_sound_sand_defaults()` + * `default.node_sound_wood_defaults()` + * `default.node_sound_leaves_defaults()` + * `default.node_sound_glass_defaults()` Default constants ----------------- -default.LIGHT_MAX -^ The maximum light level (see [Node definition] light_source) + +`default.LIGHT_MAX` The maximum light level (see [Node definition] light_source) Player API ---------- + The player API can register player models and update the player's appearence -default.player_register_model(name, def) -^ Register a new model to be used by players. - -> name: model filename such as "character.x", "foo.b3d", etc. - -> def: See [#Model definition] +`default.player_register_model(name, def)` -default.registered_player_models[name] -^ Get a model's definition - -> see [#Model definition] + * Register a new model to be used by players. + * name: model filename such as "character.x", "foo.b3d", etc. + * def: See [#Model definition] -default.player_set_model(player, model_name) -^ Change a player's model - -> player: PlayerRef - -> model_name: model registered with player_register_model() +`default.registered_player_models[name]` -default.player_set_animation(player, anim_name [, speed]) -^ Applies an animation to a player - -> anim_name: name of the animation. - -> speed: frames per second. If nil, default from the model is used + * Get a model's definition + * see [#Model definition] -default.player_set_textures(player, textures) -^ Sets player textures - -> player: PlayerRef - -> textures: array of textures - ^ If is nil, the default textures from the model def are used +`default.player_set_model(player, model_name)` + + * Change a player's model + * `player`: PlayerRef + * `model_name`: model registered with player_register_model() + +`default.player_set_animation(player, anim_name [, speed])` + + * Applies an animation to a player + * anim_name: name of the animation. + * speed: frames per second. If nil, default from the model is used + +`default.player_set_textures(player, textures)` + + * Sets player textures + * `player`: PlayerRef + * `textures`: array of textures, If `textures` is nil, the default textures from the model def are used default.player_get_animation(player) -^ Returns a table containing fields "model", "textures" and "animation". -^ Any of the fields of the returned table may be nil. - -> player: PlayerRef -Model Definition ----------------- -{ - animation_speed = 30, -- Default animation speed, in FPS. - textures = {"character.png", }, -- Default array of textures. - visual_size = {x = 1, y = 1}, -- Used to scale the model. - animations = { - -- = {x = , y = }, - foo = {x = 0, y = 19}, - bar = {x = 20, y = 39}, + * Returns a table containing fields `model`, `textures` and `animation`. + * Any of the fields of the returned table may be nil. + * player: PlayerRef + +###Model Definition + + { + animation_speed = 30, -- Default animation speed, in FPS. + textures = {"character.png", }, -- Default array of textures. + visual_size = {x = 1, y = 1}, -- Used to scale the model. + animations = { + -- = {x = , y = }, + foo = {x = 0, y = 19}, + bar = {x = 20, y = 39}, -- ... - }, -} + }, + } Leafdecay --------- -To enable leaf decay for a node, add it to the "leafdecay" group. -The rating of the group determines how far from a node in the group "tree" +To enable leaf decay for a node, add it to the `leafdecay` group. + +The rating of the group determines how far from a node in the group `tree` the node can be without decaying. -If param2 of the node is ~= 0, the node will always be preserved. Thus, if -the player places a node of that kind, you will want to set param2=1 or so. +If `param2` of the node is ~= 0, the node will always be preserved. Thus, if +the player places a node of that kind, you will want to set `param2 = 1` or so. -The function default.after_place_leaves can be set as after_place_node of a node +The function `default.after_place_leaves` can be set as `after_place_node of a node` to set param2 to 1 if the player places the node (should not be used for nodes that use param2 otherwise (e.g. facedir)). -If the node is in the leafdecay_drop group then it will always be dropped as an +If the node is in the `leafdecay_drop` group then it will always be dropped as an item. Dyes ---- + To make recipes that will work with any dye ever made by anybody, define them based on groups. You can select any group of groups, based on your need for amount of colors. -#Color groups -------------- -Base color groups: -- basecolor_white -- basecolor_grey -- basecolor_black -- basecolor_red -- basecolor_yellow -- basecolor_green -- basecolor_cyan -- basecolor_blue -- basecolor_magenta +###Color groups -Extended color groups (* = equal to a base color): -* excolor_white -- excolor_lightgrey -* excolor_grey -- excolor_darkgrey -* excolor_black -* excolor_red -- excolor_orange -* excolor_yellow -- excolor_lime -* excolor_green -- excolor_aqua -* excolor_cyan -- excolor_sky_blue -* excolor_blue -- excolor_violet -* excolor_magenta -- excolor_red_violet +Base color groups: + + * `basecolor_white` + * `basecolor_grey` + * `basecolor_black` + * `basecolor_red` + * `basecolor_yellow` + * `basecolor_green` + * `basecolor_cyan` + * `basecolor_blue` + * `basecolor_magenta` + +Extended color groups ( * means also base color ) + + * `excolor_white` * + * `excolor_lightgrey` + * `excolor_grey` * + * `excolor_darkgrey` + * `excolor_black` * + * `excolor_red` * + * `excolor_orange` + * `excolor_yellow` * + * `excolor_lime` + * `excolor_green` * + * `excolor_aqua` + * `excolor_cyan` * + * `excolor_sky_blue` + * `excolor_blue` * + * `excolor_violet` + * `excolor_magenta` * + * `excolor_red_violet` The whole unifieddyes palette as groups: -- unicolor_ + + * `unicolor_` + For the following, no white/grey/black is allowed: -- unicolor_medium_ -- unicolor_dark_ -- unicolor_light_ -- unicolor__s50 -- unicolor_medium__s50 -- unicolor_dark__s50 + + * `unicolor_medium_` + * `unicolor_dark_` + * `unicolor_light_` + * `unicolor__s50` + * `unicolor_medium__s50` + * `unicolor_dark__s50` Example of one shapeless recipe using a color group: -minetest.register_craft({ - type = "shapeless", - output = ':item_yellow', - recipe = {':item_no_color', 'group:basecolor_yellow'}, -}) -#Color lists ------------- -dye.basecolors -^ Array containing the names of available base colors + minetest.register_craft({ + type = "shapeless", + output = ':item_yellow', + recipe = {':item_no_color', 'group:basecolor_yellow'}, + }) -dye.excolors -^ Array containing the names of the available extended colors +###Color lists + + * `dye.basecolors` are an array containing the names of available base colors + + * `dye.excolors` are an array containing the names of the available extended colors Trees ----- -default.grow_tree(pos, is_apple_tree) -^ Grows a mgv6 tree or apple tree at pos -default.grow_jungle_tree(pos) -^ Grows a mgv6 jungletree at pos + * `default.grow_tree(pos, is_apple_tree)` + * Grows a mgv6 tree or apple tree at pos -default.grow_pine_tree(pos) -^ Grows a mgv6 pinetree at pos + * `default.grow_jungle_tree(pos)` + * Grows a mgv6 jungletree at pos -default.grow_new_apple_tree(pos) -^ Grows a new design apple tree at pos + * `default.grow_pine_tree(pos)` + * Grows a mgv6 pinetree at pos -default.grow_new_jungle_tree(pos) -^ Grows a new design jungle tree at pos + * `default.grow_new_apple_tree(pos)` + * Grows a new design apple tree at pos -default.grow_new_pine_tree(pos) -^ Grows a new design pine tree at pos + * `default.grow_new_jungle_tree(pos)` + * Grows a new design jungle tree at pos -default.grow_new_acacia_tree(pos) -^ Grows a new design acacia tree at pos + * `default.grow_new_pine_tree(pos)` + * Grows a new design pine tree at pos + + * `default.grow_new_acacia_tree(pos)` + * Grows a new design acacia tree at pos + + * `default.grow_new_aspen_tree(pos)` + * Grows a new design aspen tree at pos + + * `default.grow_new_snowy_pine_tree(pos)` + * Grows a new design snowy pine tree at pos diff --git a/minetest.conf.example b/minetest.conf.example index 11b4835f..ac5b8f68 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -9,6 +9,11 @@ # 0 to disable #share_bones_time = 1200 +# How much earlier the bones of a dead player can be looted by +# everyone if the player dies in a protected area they don't own. +# 0 to disable. By default it is "share_bones_time" divide by four. +#share_bones_time_early = 300 + # Whether standard fire should be disabled ('basic flame' nodes will disappear) # 'permanent flame' nodes will remain with either setting #disable_fire = false diff --git a/mods/beds/api.lua b/mods/beds/api.lua index 6b72814d..0c27c4e3 100644 --- a/mods/beds/api.lua +++ b/mods/beds/api.lua @@ -19,6 +19,7 @@ function beds.register_bed(name, def) type = "fixed", fixed = def.selectionbox, }, + after_place_node = function(pos, placer, itemstack) local n = minetest.get_node_or_nil(pos) if not n or not n.param2 then @@ -36,6 +37,7 @@ function beds.register_bed(name, def) minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2}) return false end, + on_destruct = function(pos) local n = minetest.get_node_or_nil(pos) if not n then return end @@ -46,9 +48,11 @@ function beds.register_bed(name, def) minetest.remove_node(p) end end, + on_rightclick = function(pos, node, clicker) beds.on_rightclick(pos, clicker) end, + on_rotate = function(pos, node, user, mode, new_param2) local dir = minetest.facedir_to_dir(node.param2) local p = vector.add(pos, dir) @@ -99,7 +103,6 @@ function beds.register_bed(name, def) minetest.register_alias(name, name .. "_bottom") - -- register recipe minetest.register_craft({ output = name, recipe = def.recipe diff --git a/mods/beds/beds.lua b/mods/beds/beds.lua index 43bf98ed..5f31f136 100644 --- a/mods/beds/beds.lua +++ b/mods/beds/beds.lua @@ -1,44 +1,45 @@ --- fancy shaped bed +-- Fancy shaped bed + beds.register_bed("beds:fancy_bed", { description = "Fancy Bed", inventory_image = "beds_bed_fancy.png", wield_image = "beds_bed_fancy.png", tiles = { - bottom = { - "beds_bed_top1.png", - "default_wood.png", - "beds_bed_side1.png", - "beds_bed_side1.png^[transformFX", - "default_wood.png", - "beds_bed_foot.png", - }, - top = { - "beds_bed_top2.png", - "default_wood.png", - "beds_bed_side2.png", - "beds_bed_side2.png^[transformFX", - "beds_bed_head.png", - "default_wood.png", - } + bottom = { + "beds_bed_top1.png", + "default_wood.png", + "beds_bed_side1.png", + "beds_bed_side1.png^[transformFX", + "default_wood.png", + "beds_bed_foot.png", + }, + top = { + "beds_bed_top2.png", + "default_wood.png", + "beds_bed_side2.png", + "beds_bed_side2.png^[transformFX", + "beds_bed_head.png", + "default_wood.png", + } }, nodebox = { - bottom = { - {-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375}, - {0.375, -0.5, -0.5, 0.5, -0.065, -0.4375}, - {-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375}, - {-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5}, - {0.4375, -0.375, -0.5, 0.5, -0.125, 0.5}, - {-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5}, - }, - top = { - {-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5}, - {0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5}, - {-0.5, 0, 0.4375, 0.5, 0.125, 0.5}, - {-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5}, - {-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5}, - {0.4375, -0.375, -0.5, 0.5, -0.125, 0.5}, - {-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375}, - } + bottom = { + {-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375}, + {0.375, -0.5, -0.5, 0.5, -0.065, -0.4375}, + {-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375}, + {-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5}, + {0.4375, -0.375, -0.5, 0.5, -0.125, 0.5}, + {-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5}, + }, + top = { + {-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5}, + {0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5}, + {-0.5, 0, 0.4375, 0.5, 0.125, 0.5}, + {-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5}, + {-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5}, + {0.4375, -0.375, -0.5, 0.5, -0.125, 0.5}, + {-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375}, + } }, selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5}, recipe = { @@ -48,41 +49,42 @@ beds.register_bed("beds:fancy_bed", { }, }) --- simple shaped bed +-- Simple shaped bed + beds.register_bed("beds:bed", { description = "Simple Bed", inventory_image = "beds_bed.png", wield_image = "beds_bed.png", tiles = { - bottom = { - "beds_bed_top_bottom.png^[transformR90", - "default_wood.png", - "beds_bed_side_bottom_r.png", - "beds_bed_side_bottom_r.png^[transformfx", - "beds_transparent.png", - "beds_bed_side_bottom.png" - }, - top = { - "beds_bed_top_top.png^[transformR90", - "default_wood.png", - "beds_bed_side_top_r.png", - "beds_bed_side_top_r.png^[transformfx", - "beds_bed_side_top.png", - "beds_transparent.png", - } + bottom = { + "beds_bed_top_bottom.png^[transformR90", + "default_wood.png", + "beds_bed_side_bottom_r.png", + "beds_bed_side_bottom_r.png^[transformfx", + "beds_transparent.png", + "beds_bed_side_bottom.png" + }, + top = { + "beds_bed_top_top.png^[transformR90", + "default_wood.png", + "beds_bed_side_top_r.png", + "beds_bed_side_top_r.png^[transformfx", + "beds_bed_side_top.png", + "beds_transparent.png", + } }, nodebox = { - bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, - top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, + bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, + top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, }, selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5}, recipe = { {"wool:red", "wool:red", "wool:white"}, {"group:wood", "group:wood", "group:wood"} }, - }) --- aliases for PA's beds mod +-- Aliases for PilzAdam's beds mod + minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom") minetest.register_alias("beds:bed_top_red", "beds:bed_top") diff --git a/mods/beds/functions.lua b/mods/beds/functions.lua index 5b2f5406..afc8e15a 100644 --- a/mods/beds/functions.lua +++ b/mods/beds/functions.lua @@ -6,15 +6,14 @@ if enable_respawn == nil then enable_respawn = true end - --- helper functions +-- Helper functions local function get_look_yaw(pos) local n = minetest.get_node(pos) if n.param2 == 1 then - return pi/2, n.param2 + return pi / 2, n.param2 elseif n.param2 == 3 then - return -pi/2, n.param2 + return -pi / 2, n.param2 elseif n.param2 == 0 then return pi, n.param2 else @@ -70,8 +69,8 @@ local function lay_down(player, pos, bed_pos, state, skip) end -- physics, eye_offset, etc - player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) - player:set_look_yaw(math.random(1, 180)/100) + player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) + player:set_look_yaw(math.random(1, 180) / 100) default.player_attached[name] = false player:set_physics_override(1, 1, 1) hud_flags.wielditem = true @@ -84,11 +83,11 @@ local function lay_down(player, pos, bed_pos, state, skip) player_in_bed = player_in_bed + 1 -- physics, eye_offset, etc - player:set_eye_offset({x=0,y=-13,z=0}, {x=0,y=0,z=0}) + player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0}) local yaw, param2 = get_look_yaw(bed_pos) player:set_look_yaw(yaw) local dir = minetest.facedir_to_dir(param2) - local p = {x=bed_pos.x+dir.x/2,y=bed_pos.y,z=bed_pos.z+dir.z/2} + local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2} player:set_physics_override(0, 0, 0) player:setpos(p) default.player_attached[name] = true @@ -102,17 +101,15 @@ end local function update_formspecs(finished) local ges = #minetest.get_connected_players() local form_n = "" - local is_majority = (ges/2) < player_in_bed + local is_majority = (ges / 2) < player_in_bed if finished then - form_n = beds.formspec .. - "label[2.7,11; Good morning.]" + form_n = beds.formspec .. "label[2.7,11; Good morning.]" else - form_n = beds.formspec .. - "label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]" + form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. + " of " .. tostring(ges) .. " players are in bed]" if is_majority and is_night_skip_enabled() then - form_n = form_n .. - "button_exit[2,8;4,0.75;force;Force night skip]" + form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]" end end @@ -122,10 +119,10 @@ local function update_formspecs(finished) end --- public functions +-- Public functions function beds.kick_players() - for name,_ in pairs(beds.player) do + for name, _ in pairs(beds.player) do local player = minetest.get_player_by_name(name) lay_down(player, nil, nil, false) end @@ -175,7 +172,7 @@ function beds.on_rightclick(pos, player) end --- callbacks +-- Callbacks minetest.register_on_joinplayer(function(player) beds.read_spawns() diff --git a/mods/beds/init.lua b/mods/beds/init.lua index 09982c24..8b258901 100644 --- a/mods/beds/init.lua +++ b/mods/beds/init.lua @@ -3,14 +3,15 @@ beds.player = {} beds.pos = {} beds.spawn = {} -beds.formspec = "size[8,15;true]".. - "bgcolor[#080808BB; true]".. - "button_exit[2,12;4,0.75;leave;Leave Bed]" +beds.formspec = "size[8,15;true]" .. + "bgcolor[#080808BB; true]" .. + "button_exit[2,12;4,0.75;leave;Leave Bed]" local modpath = minetest.get_modpath("beds") --- load files -dofile(modpath.."/functions.lua") -dofile(modpath.."/api.lua") -dofile(modpath.."/beds.lua") -dofile(modpath.."/spawns.lua") +-- Load files + +dofile(modpath .. "/functions.lua") +dofile(modpath .. "/api.lua") +dofile(modpath .. "/beds.lua") +dofile(modpath .. "/spawns.lua") diff --git a/mods/beds/spawns.lua b/mods/beds/spawns.lua index 6e087f82..14ec75bf 100644 --- a/mods/beds/spawns.lua +++ b/mods/beds/spawns.lua @@ -43,7 +43,7 @@ function beds.save_spawns() end local output = io.open(org_file, "w") for i, v in pairs(beds.spawn) do - output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n") + output:write(v.x .. " " .. v.y .. " " .. v.z .. " " .. i .. "\n") end io.close(output) end diff --git a/mods/bones/init.lua b/mods/bones/init.lua index f8e6c677..808233b6 100644 --- a/mods/bones/init.lua +++ b/mods/bones/init.lua @@ -5,7 +5,7 @@ bones = {} local function is_owner(pos, name) local owner = minetest.get_meta(pos):get_string("owner") - if owner == "" or owner == name then + if owner == "" or owner == name or minetest.check_player_privs(placer, "protection_bypass") then return true end return false @@ -43,7 +43,11 @@ minetest.register_node("bones:bones", { can_dig = function(pos, player) local inv = minetest.get_meta(pos):get_inventory() - return is_owner(pos, player:get_player_name()) and inv:is_empty("main") + local name = "" + if player then + name = player:get_player_name() + end + return is_owner(pos, name) and inv:is_empty("main") end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) diff --git a/mods/creative/init.lua b/mods/creative/init.lua index bac75e01..01163707 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -113,15 +113,15 @@ creative.set_creative_formspec = function(player, start_i, pagenum, tab_id) tableoptions[background=#00000000;highlight=#00000000;border=false] button[5.4,3.2;0.8,0.9;creative_prev;<] button[7.25,3.2;0.8,0.9;creative_next;>] - button[2.1,3.4;0.8,0.5;search;?] - button[2.75,3.4;0.8,0.5;clear;X] - tooltip[search;Search] - tooltip[clear;Reset] + button[2.1,3.4;0.8,0.5;creative_search;?] + button[2.75,3.4;0.8,0.5;creative_clear;X] + tooltip[creative_search;Search] + tooltip[creative_clear;Reset] listring[current_player;main] ]] .. - "field[0.3,3.5;2.2,1;filter;;".. filter .."]".. + "field[0.3,3.5;2.2,1;creative_filter;;".. filter .."]".. "listring[detached:creative_".. player_name ..";main]".. - "tabheader[0,0;tabs;Crafting,All,Nodes,Tools,Items;".. tostring(tab_id) ..";true;false]".. + "tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;".. tostring(tab_id) ..";true;false]".. "list[detached:creative_".. player_name ..";main;0,0;8,3;".. tostring(start_i) .."]".. "table[6.05,3.35;1.15,0.5;pagenum;#FFFF00,".. tostring(pagenum) ..",#FFFFFF,/ ".. tostring(pagemax) .."]".. default.get_hotbar_bg(0,4.7).. @@ -139,7 +139,7 @@ creative.set_crafting_formspec = function(player) list[detached:creative_trash;main;0,2.75;1,1;] image[0.06,2.85;0.8,0.8;creative_trash_icon.png] image[5,1.75;1,1;gui_furnace_arrow_bg.png^[transformR270] - tabheader[0,0;tabs;Crafting,All,Nodes,Tools,Items;1;true;false] + tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;1;true;false] listring[current_player;main] listring[current_player;craft] ]] .. @@ -158,15 +158,15 @@ minetest.register_on_joinplayer(function(player) end) minetest.register_on_player_receive_fields(function(player, formname, fields) - if not minetest.setting_getbool("creative_mode") then + if formname ~= "" or not minetest.setting_getbool("creative_mode") then return end - -- Figure out current page from formspec + local player_name = player:get_player_name() local formspec = player:get_inventory_formspec() - local filter = formspec:match("filter;;([%w_:]+)") or "" - local start_i = formspec:match("list%[detached:creative_".. player_name ..";.*;(%d+)%]") - local tab_id = tonumber(formspec:match("tabheader%[.*;(%d+)%;.*%]")) + local filter = formspec:match("creative_filter;;([%w_:]+)") or "" + local start_i = formspec:match("list%[.-".. player_name ..";.-;(%d+)%]") + local tab_id = tonumber(formspec:match("tabheader%[.-;(%d+)%;")) local inv_size = player_inventory[player_name].size start_i = tonumber(start_i) or 0 @@ -174,20 +174,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if tab_id == 1 then creative.set_crafting_formspec(player) end - elseif fields.tabs then - if tonumber(fields.tabs) == 1 then + elseif fields.creative_tabs then + local tab = tonumber(fields.creative_tabs) + if tab == 1 then creative.set_crafting_formspec(player) else - creative.update_creative_inventory(player_name, filter, tonumber(fields.tabs)) - creative.set_creative_formspec(player, 0, 1, tonumber(fields.tabs)) + creative.update_creative_inventory(player_name, filter, tab) + creative.set_creative_formspec(player, 0, 1, tab) end - elseif fields.clear then + elseif fields.creative_clear then player_inventory[player_name].filter = "" creative.update_creative_inventory(player_name, nil, tab_id) creative.set_creative_formspec(player, 0, 1, tab_id) - elseif fields.search then - player_inventory[player_name].filter = fields.filter:lower() - creative.update_creative_inventory(player_name, fields.filter:lower(), tab_id) + elseif fields.creative_search then + local lowstr = fields.creative_filter:lower() + player_inventory[player_name].filter = lowstr + creative.update_creative_inventory(player_name, lowstr, tab_id) creative.set_creative_formspec(player, 0, 1, tab_id) else if fields.creative_prev then diff --git a/mods/default/README.txt b/mods/default/README.txt index c190cee0..048b4c0a 100644 --- a/mods/default/README.txt +++ b/mods/default/README.txt @@ -27,7 +27,6 @@ Cisoun's WTFPL texture pack: default_lava.png default_leaves.png default_sapling.png - default_sign_wall.png default_stone.png default_tree.png default_tree_top.png @@ -59,7 +58,6 @@ VanessaE (WTFPL): default_desert_sand.png default_desert_stone.png default_sand.png - default_jungletree_top.png Calinou (CC BY-SA): default_brick.png @@ -100,28 +98,29 @@ Zeg9 (CC BY-SA 3.0): default_gold_block.png paramat (CC BY-SA 3.0): - wieldhand.png, derived from character.png by Jordach (CC BY-SA 3.0) + wieldhand.png copied from character.png by Jordach (CC BY-SA 3.0) default_pinetree.png default_pinetree_top.png default_pinewood.png - default_sandstone_brick.png - default_obsidian_brick.png - default_river_water.png - default_river_water_source_animated.png - default_river_water_flowing_animated.png default_acacia_leaves.png default_acacia_sapling.png default_acacia_tree.png default_acacia_tree_top.png default_acacia_wood.png + default_junglewood.png + default_jungletree_top.png + default_sandstone_brick.png + default_obsidian_brick.png + default_stone_brick.png + default_desert_stone_brick.png + default_river_water.png + default_river_water_source_animated.png + default_river_water_flowing_animated.png default_dry_grass.png default_dry_grass_side.png default_dry_grass_*.png - default_junglewood.png, derived from a texture by BlockMen (CC BY-SA 3.0) - default_grass.png, derived from a texture by Philipbenr (CC BY-SA 3.0) - default_grass_side.png, derived from a texture by Philipbenr (CC BY-SA 3.0) - default_stone_brick.png, derived from a texture by Cisoun (WTFPL) - default_desert_stone_brick.png, derived from a texture by VanessaE (WTFPL) + default_grass.png + default_grass_side.png brunob.santos (CC BY-SA 4.0): default_desert_cobble.png @@ -156,6 +155,9 @@ sofar (CC BY-SA 3.0): default_aspen_tree_top, derived from default_pine_tree_top (by paramat) default_aspen_wood, derived from default_pine_wood (by paramat) +sofar (WTFPL): + default_gravel.png -- Derived from Gambit's PixelBOX texture pack light gravel + Neuromancer (CC BY-SA 2.0): default_cobble.png, based on texture by Brane praefect default_mossycobble.png, based on texture by Brane praefect @@ -174,6 +176,8 @@ Gambit (WTFPL): default_grass_*.png default_paper.png default_diamond_block.png + default_ladder_steel.png + default_sign_wall_wood.png asl97 (WTFPL): default_ice.png diff --git a/mods/default/aliases.lua b/mods/default/aliases.lua index 64e6ebba..63fe59b2 100644 --- a/mods/default/aliases.lua +++ b/mods/default/aliases.lua @@ -23,7 +23,7 @@ minetest.register_alias("bookshelf", "default:bookshelf") minetest.register_alias("glass", "default:glass") minetest.register_alias("wooden_fence", "default:fence_wood") minetest.register_alias("rail", "default:rail") -minetest.register_alias("ladder", "default:ladder") +minetest.register_alias("ladder", "default:ladder_wood") minetest.register_alias("wood", "default:wood") minetest.register_alias("mese", "default:mese") minetest.register_alias("cloud", "default:cloud") @@ -32,7 +32,7 @@ minetest.register_alias("water_source", "default:water_source") minetest.register_alias("lava_flowing", "default:lava_flowing") minetest.register_alias("lava_source", "default:lava_source") minetest.register_alias("torch", "default:torch") -minetest.register_alias("sign_wall", "default:sign_wall") +minetest.register_alias("sign_wall", "default:sign_wall_wood") minetest.register_alias("furnace", "default:furnace") minetest.register_alias("chest", "default:chest") minetest.register_alias("locked_chest", "default:chest_locked") @@ -74,3 +74,7 @@ minetest.register_alias("default:mese_block", "default:mese") -- Aliases for corrected pine node names minetest.register_alias("default:pinetree", "default:pine_tree") minetest.register_alias("default:pinewood", "default:pine_wood") + +minetest.register_alias("default:ladder", "default:ladder_wood") +minetest.register_alias("default:sign_wall", "default:sign_wall_wood") + diff --git a/mods/default/crafting.lua b/mods/default/crafting.lua index 27f69035..34292a41 100644 --- a/mods/default/crafting.lua +++ b/mods/default/crafting.lua @@ -43,7 +43,16 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'default:sign_wall', + output = 'default:sign_wall_steel 3', + recipe = { + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'', 'group:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'default:sign_wall_wood 3', recipe = { {'group:wood', 'group:wood', 'group:wood'}, {'group:wood', 'group:wood', 'group:wood'}, @@ -539,7 +548,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'default:ladder', + output = 'default:ladder_wood 3', recipe = { {'group:stick', '', 'group:stick'}, {'group:stick', 'group:stick', 'group:stick'}, @@ -547,6 +556,15 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = 'default:ladder_steel 15', + recipe = { + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, + {'default:steel_ingot', '', 'default:steel_ingot'}, + } +}) + minetest.register_craft({ output = 'default:mese', recipe = { @@ -748,7 +766,31 @@ minetest.register_craft({ minetest.register_craft({ type = "fuel", - recipe = "default:ladder", + recipe = "default:fence_acacia_wood", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:fence_junglewood", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:fence_pine_wood", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:fence_aspen_wood", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:ladder_wood", burntime = 5, }) @@ -772,7 +814,7 @@ minetest.register_craft({ minetest.register_craft({ type = "fuel", - recipe = "default:sign_wall", + recipe = "default:sign_wall_wood", burntime = 10, }) diff --git a/mods/default/craftitems.lua b/mods/default/craftitems.lua index 406943e2..09ebeccf 100644 --- a/mods/default/craftitems.lua +++ b/mods/default/craftitems.lua @@ -3,7 +3,7 @@ minetest.register_craftitem("default:stick", { description = "Stick", inventory_image = "default_stick.png", - groups = {stick=1}, + groups = {stick = 1}, }) minetest.register_craftitem("default:paper", { @@ -20,18 +20,20 @@ local function book_on_use(itemstack, user, pointed_thing) end local formspec if owner == player_name then - formspec = "size[8,8]"..default.gui_bg.. - "field[0.5,1;7.5,0;title;Title:;".. - minetest.formspec_escape(title).."]".. - "textarea[0.5,1.5;7.5,7;text;Contents:;".. - minetest.formspec_escape(text).."]".. + formspec = "size[8,8]" .. default.gui_bg .. + default.gui_bg_img .. + "field[0.5,1;7.5,0;title;Title:;" .. + minetest.formspec_escape(title) .. "]" .. + "textarea[0.5,1.5;7.5,7;text;Contents:;" .. + minetest.formspec_escape(text) .. "]" .. "button_exit[2.5,7.5;3,1;save;Save]" else - formspec = "size[8,8]"..default.gui_bg.. - "label[0.5,0.5;by "..owner.."]".. - "label[0.5,0;"..minetest.formspec_escape(title).."]".. - "tableoptions[background=#00000000;highlight=#00000000;border=false]".. - "table[0.5,1.5;7.5,7;;"..minetest.formspec_escape(text):gsub("\n", ",")..";1]" + formspec = "size[8,8]" .. default.gui_bg .. + default.gui_bg_img .. + "label[0.5,0.5;by " .. owner .. "]" .. + "label[0.5,0;" .. minetest.formspec_escape(title) .. "]" .. + "textarea[0.5,1.5;7.5,7;text;;" .. + minetest.formspec_escape(text) .. "]" end minetest.show_formspec(user:get_player_name(), "default:book", formspec) end @@ -76,14 +78,14 @@ end) minetest.register_craftitem("default:book", { description = "Book", inventory_image = "default_book.png", - groups = {book=1}, + groups = {book = 1}, on_use = book_on_use, }) minetest.register_craftitem("default:book_written", { description = "Book With Text", inventory_image = "default_book_written.png", - groups = {book=1, not_in_creative_inventory=1}, + groups = {book = 1, not_in_creative_inventory = 1}, stack_max = 1, on_use = book_on_use, }) @@ -91,7 +93,7 @@ minetest.register_craftitem("default:book_written", { minetest.register_craft({ type = "shapeless", output = "default:book_written", - recipe = { "default:book", "default:book_written" } + recipe = {"default:book", "default:book_written"} }) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 0137d912..a85009bf 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -88,37 +88,24 @@ end -- Lavacooling -- -default.cool_lava_source = function(pos) - minetest.set_node(pos, {name = "default:obsidian"}) - minetest.sound_play("default_cool_lava", - {pos = pos, max_hear_distance = 16, gain = 0.25}) -end - -default.cool_lava_flowing = function(pos) - minetest.set_node(pos, {name = "default:stone"}) +default.cool_lava = function(pos, node) + if node.name == "default:lava_source" then + minetest.set_node(pos, {name = "default:obsidian"}) + else -- Lava flowing + minetest.set_node(pos, {name = "default:stone"}) + end minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}) end minetest.register_abm({ - nodenames = {"default:lava_flowing"}, + nodenames = {"default:lava_source", "default:lava_flowing"}, neighbors = {"group:water"}, interval = 1, - chance = 2, + chance = 1, catch_up = false, action = function(...) - default.cool_lava_flowing(...) - end, -}) - -minetest.register_abm({ - nodenames = {"default:lava_source"}, - neighbors = {"group:water"}, - interval = 1, - chance = 2, - catch_up = false, - action = function(...) - default.cool_lava_source(...) + default.cool_lava(...) end, }) @@ -177,8 +164,8 @@ end minetest.register_abm({ nodenames = {"default:cactus"}, neighbors = {"group:sand"}, - interval = 50, - chance = 20, + interval = 12, + chance = 83, action = function(...) default.grow_cactus(...) end @@ -186,9 +173,9 @@ minetest.register_abm({ minetest.register_abm({ nodenames = {"default:papyrus"}, - neighbors = {"default:dirt", "default:dirt_with_grass", "default:sand"}, - interval = 50, - chance = 20, + neighbors = {"default:dirt", "default:dirt_with_grass"}, + interval = 14, + chance = 71, action = function(...) default.grow_papyrus(...) end @@ -226,16 +213,27 @@ function default.register_fence(name, def) -- Allow almost everything to be overridden local default_fields = { paramtype = "light", - drawtype = "fencelike", + drawtype = "nodebox", + node_box = { + type = "connected", + fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}}, + -- connect_top = + -- connect_bottom = + connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8}, + {-1/16,-5/16,-1/2,1/16,-3/16,-1/8}}, + connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16}, + {-1/2,-5/16,-1/16,-1/8,-3/16,1/16}}, + connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2}, + {-1/16,-5/16,1/8,1/16,-3/16,1/2}}, + connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16}, + {1/8,-5/16,-1/16,1/2,-3/16,1/16}}, + }, + connects_to = {"group:fence", "group:wood", "group:tree"}, inventory_image = fence_texture, wield_image = fence_texture, - tiles = { def.texture }, + tiles = {def.texture}, sunlight_propagates = true, is_ground_content = false, - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, groups = {}, } for k, v in pairs(default_fields) do @@ -270,9 +268,11 @@ minetest.register_globalstep(function(dtime) end) default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) - local node = minetest.get_node(pos) - node.param2 = 1 - minetest.set_node(pos, node) + if placer and not placer:get_player_control().sneak then + local node = minetest.get_node(pos) + node.param2 = 1 + minetest.set_node(pos, node) + end end minetest.register_abm({ @@ -358,8 +358,9 @@ minetest.register_abm({ minetest.register_abm({ nodenames = {"default:dirt"}, - interval = 2, - chance = 200, + neighbors = {"air"}, + interval = 6, + chance = 67, catch_up = false, action = function(pos, node) local above = {x = pos.x, y = pos.y + 1, z = pos.z} @@ -384,8 +385,8 @@ minetest.register_abm({ minetest.register_abm({ nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass"}, - interval = 2, - chance = 20, + interval = 8, + chance = 50, catch_up = false, action = function(pos, node) local above = {x = pos.x, y = pos.y + 1, z = pos.z} @@ -407,7 +408,7 @@ minetest.register_abm({ minetest.register_abm({ nodenames = {"default:cobble"}, neighbors = {"group:water"}, - interval = 17, + interval = 16, chance = 200, catch_up = false, action = function(pos, node) diff --git a/mods/default/furnace.lua b/mods/default/furnace.lua index 6d89aae1..aa2be212 100644 --- a/mods/default/furnace.lua +++ b/mods/default/furnace.lua @@ -90,6 +90,137 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player return stack:get_count() end +local function swap_node(pos, name) + local node = minetest.get_node(pos) + if node.name == name then + return + end + node.name = name + minetest.swap_node(pos, node) +end + +local function furnace_node_timer(pos, elapsed) + -- + -- Inizialize metadata + -- + local meta = minetest.get_meta(pos) + local fuel_time = meta:get_float("fuel_time") or 0 + local src_time = meta:get_float("src_time") or 0 + local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 + + local inv = meta:get_inventory() + local srclist = inv:get_list("src") + local fuellist = inv:get_list("fuel") + local dstlist = inv:get_list("dst") + + -- + -- Cooking + -- + + -- Check if we have cookable content + local cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + local cookable = true + + if cooked.time == 0 then + cookable = false + end + + -- Check if we have enough fuel to burn + if fuel_time < fuel_totaltime then + -- The furnace is currently active and has enough fuel + fuel_time = fuel_time + 1 + + -- If there is a cookable item then check if it is ready yet + if cookable then + src_time = src_time + 1 + if src_time >= cooked.time then + -- Place result in dst list if possible + if inv:room_for_item("dst", cooked.item) then + inv:add_item("dst", cooked.item) + inv:set_stack("src", 1, aftercooked.items[1]) + src_time = 0 + end + end + end + else + -- Furnace ran out of fuel + if cookable then + -- We need to get new fuel + local fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) + + if fuel.time == 0 then + -- No valid fuel in fuel list + fuel_totaltime = 0 + fuel_time = 0 + src_time = 0 + else + -- Take fuel from fuel list + inv:set_stack("fuel", 1, afterfuel.items[1]) + + fuel_totaltime = fuel.time + fuel_time = 0 + end + else + -- We don't need to get new fuel since there is no cookable item + fuel_totaltime = 0 + fuel_time = 0 + src_time = 0 + end + end + + -- + -- Update formspec, infotext and node + -- + local formspec = inactive_formspec + local item_state = "" + local item_percent = 0 + if cookable then + item_percent = math.floor(src_time / cooked.time * 100) + item_state = item_percent .. "%" + else + if srclist[1]:is_empty() then + item_state = "Empty" + else + item_state = "Not cookable" + end + end + + local fuel_state = "Empty" + local active = "inactive " + local result = false + + if fuel_time <= fuel_totaltime and fuel_totaltime ~= 0 then + active = "active " + local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) + fuel_state = fuel_percent .. "%" + formspec = active_formspec(fuel_percent, item_percent) + swap_node(pos, "default:furnace_active") + -- make sure timer restarts automatically + result = true + else + if not fuellist[1]:is_empty() then + fuel_state = "0%" + end + swap_node(pos, "default:furnace") + -- stop timer on the inactive furnace + local timer = minetest.get_node_timer(pos) + timer:stop() + end + + local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")" + + -- + -- Set meta values + -- + meta:set_float("fuel_totaltime", fuel_totaltime) + meta:set_float("fuel_time", fuel_time) + meta:set_float("src_time", src_time) + meta:set_string("formspec", formspec) + meta:set_string("infotext", infotext) + + return result +end + -- -- Node definitions -- @@ -106,9 +237,26 @@ minetest.register_node("default:furnace", { legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_stone_defaults(), - + can_dig = can_dig, - + + on_timer = furnace_node_timer, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", inactive_formspec) + local inv = meta:get_inventory() + inv:set_size('src', 1) + inv:set_size('fuel', 1) + inv:set_size('dst', 4) + end, + + on_metadata_inventory_put = function(pos) + -- start timer function, it will sort out whether furnace can burn or not. + local timer = minetest.get_node_timer(pos) + timer:start(1.0) + end, + allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_take = allow_metadata_inventory_take, @@ -138,154 +286,12 @@ minetest.register_node("default:furnace_active", { legacy_facedir_simple = true, is_ground_content = false, sounds = default.node_sound_stone_defaults(), - + on_timer = furnace_node_timer, + can_dig = can_dig, - + allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_take = allow_metadata_inventory_take, }) --- --- ABM --- - -local function swap_node(pos, name) - local node = minetest.get_node(pos) - if node.name == name then - return - end - node.name = name - minetest.swap_node(pos, node) -end - -minetest.register_abm({ - nodenames = {"default:furnace", "default:furnace_active"}, - interval = 1.0, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - -- - -- Inizialize metadata - -- - local meta = minetest.get_meta(pos) - local fuel_time = meta:get_float("fuel_time") or 0 - local src_time = meta:get_float("src_time") or 0 - local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 - - -- - -- Inizialize inventory - -- - local inv = meta:get_inventory() - for listname, size in pairs({ - src = 1, - fuel = 1, - dst = 4, - }) do - if inv:get_size(listname) ~= size then - inv:set_size(listname, size) - end - end - local srclist = inv:get_list("src") - local fuellist = inv:get_list("fuel") - local dstlist = inv:get_list("dst") - - -- - -- Cooking - -- - - -- Check if we have cookable content - local cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) - local cookable = true - - if cooked.time == 0 then - cookable = false - end - - -- Check if we have enough fuel to burn - if fuel_time < fuel_totaltime then - -- The furnace is currently active and has enough fuel - fuel_time = fuel_time + 1 - - -- If there is a cookable item then check if it is ready yet - if cookable then - src_time = src_time + 1 - if src_time >= cooked.time then - -- Place result in dst list if possible - if inv:room_for_item("dst", cooked.item) then - inv:add_item("dst", cooked.item) - inv:set_stack("src", 1, aftercooked.items[1]) - src_time = 0 - end - end - end - else - -- Furnace ran out of fuel - if cookable then - -- We need to get new fuel - local fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) - - if fuel.time == 0 then - -- No valid fuel in fuel list - fuel_totaltime = 0 - fuel_time = 0 - src_time = 0 - else - -- Take fuel from fuel list - inv:set_stack("fuel", 1, afterfuel.items[1]) - - fuel_totaltime = fuel.time - fuel_time = 0 - - end - else - -- We don't need to get new fuel since there is no cookable item - fuel_totaltime = 0 - fuel_time = 0 - src_time = 0 - end - end - - -- - -- Update formspec, infotext and node - -- - local formspec = inactive_formspec - local item_state = "" - local item_percent = 0 - if cookable then - item_percent = math.floor(src_time / cooked.time * 100) - item_state = item_percent .. "%" - else - if srclist[1]:is_empty() then - item_state = "Empty" - else - item_state = "Not cookable" - end - end - - local fuel_state = "Empty" - local active = "inactive " - if fuel_time <= fuel_totaltime and fuel_totaltime ~= 0 then - active = "active " - local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) - fuel_state = fuel_percent .. "%" - formspec = active_formspec(fuel_percent, item_percent) - swap_node(pos, "default:furnace_active") - else - if not fuellist[1]:is_empty() then - fuel_state = "0%" - end - swap_node(pos, "default:furnace") - end - - local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")" - - -- - -- Set meta values - -- - meta:set_float("fuel_totaltime", fuel_totaltime) - meta:set_float("fuel_time", fuel_time) - meta:set_float("src_time", src_time) - meta:set_string("formspec", formspec) - meta:set_string("infotext", infotext) - end, -}) diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua index 05d7b2b9..3424a557 100644 --- a/mods/default/mapgen.lua +++ b/mods/default/mapgen.lua @@ -991,8 +991,8 @@ function default.register_decorations() place_on = {"default:dirt_with_grass"}, sidelen = 16, noise_params = { - offset = 0.04, - scale = 0.02, + offset = 0.036, + scale = 0.022, spread = {x = 250, y = 250, z = 250}, seed = 2, octaves = 3, @@ -1010,8 +1010,8 @@ function default.register_decorations() place_on = {"default:dirt_with_grass"}, sidelen = 16, noise_params = { - offset = 0.002, - scale = 0.001, + offset = 0.0018, + scale = 0.0011, spread = {x = 250, y = 250, z = 250}, seed = 2, octaves = 3, @@ -1021,17 +1021,17 @@ function default.register_decorations() y_min = 1, y_max = 31000, schematic = { - size = { x = 3, y = 3, z = 1}, + size = {x = 3, y = 3, z = 1}, data = { - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "default:tree", param2 = 12, prob = 191 }, - { name = "default:tree", param2 = 12 }, - { name = "default:tree", param2 = 12, prob = 127 }, - { name = "air", prob = 0 }, - { name = "flowers:mushroom_brown", prob = 63 }, - { name = "air", prob = 0 }, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "default:tree", param2 = 12, prob = 191}, + {name = "default:tree", param2 = 12}, + {name = "default:tree", param2 = 12, prob = 127}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_brown", prob = 63}, + {name = "air", prob = 0}, }, }, flags = "place_center_x", @@ -1062,17 +1062,17 @@ function default.register_decorations() y_min = 1, y_max = 31000, schematic = { - size = { x = 3, y = 3, z = 1}, + size = {x = 3, y = 3, z = 1}, data = { - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "default:jungletree", param2 = 12, prob = 191 }, - { name = "default:jungletree", param2 = 12 }, - { name = "default:jungletree", param2 = 12, prob = 127 }, - { name = "air", prob = 0 }, - { name = "flowers:mushroom_brown", prob = 127 }, - { name = "air", prob = 0 }, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "default:jungletree", param2 = 12, prob = 191}, + {name = "default:jungletree", param2 = 12}, + {name = "default:jungletree", param2 = 12, prob = 127}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_brown", prob = 127}, + {name = "air", prob = 0}, }, }, flags = "place_center_x", @@ -1086,8 +1086,8 @@ function default.register_decorations() place_on = {"default:dirt_with_snow", "default:dirt_with_grass"}, sidelen = 16, noise_params = { - offset = 0.04, - scale = 0.02, + offset = 0.036, + scale = 0.022, spread = {x = 250, y = 250, z = 250}, seed = 2, octaves = 3, @@ -1104,22 +1104,29 @@ function default.register_decorations() deco_type = "schematic", place_on = {"default:dirt_with_snow", "default:dirt_with_grass"}, sidelen = 80, - fill_ratio = 0.003, + noise_params = { + offset = 0.0018, + scale = 0.0011, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.66 + }, biomes = {"taiga", "coniferous_forest"}, y_min = 1, y_max = 31000, schematic = { - size = { x = 3, y = 3, z = 1}, + size = {x = 3, y = 3, z = 1}, data = { - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "default:pine_tree", param2 = 12, prob = 191 }, - { name = "default:pine_tree", param2 = 12 }, - { name = "default:pine_tree", param2 = 12, prob = 127 }, - { name = "air", prob = 0 }, - { name = "flowers:mushroom_red", prob = 63 }, - { name = "air", prob = 0 }, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "default:pine_tree", param2 = 12, prob = 191}, + {name = "default:pine_tree", param2 = 12}, + {name = "default:pine_tree", param2 = 12, prob = 127}, + {name = "air", prob = 0}, + {name = "flowers:mushroom_red", prob = 63}, + {name = "air", prob = 0}, }, }, flags = "place_center_x", @@ -1164,14 +1171,14 @@ function default.register_decorations() y_min = 1, y_max = 31000, schematic = { - size = { x = 3, y = 2, z = 1}, + size = {x = 3, y = 2, z = 1}, data = { - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "default:acacia_tree", param2 = 12, prob = 191 }, - { name = "default:acacia_tree", param2 = 12 }, - { name = "default:acacia_tree", param2 = 12, prob = 127 }, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "default:acacia_tree", param2 = 12, prob = 191}, + {name = "default:acacia_tree", param2 = 12}, + {name = "default:acacia_tree", param2 = 12, prob = 127}, }, }, flags = "place_center_x", @@ -1186,7 +1193,7 @@ function default.register_decorations() sidelen = 16, noise_params = { offset = 0.0, - scale = -0.03, + scale = -0.015, spread = {x = 250, y = 250, z = 250}, seed = 2, octaves = 3, @@ -1206,7 +1213,7 @@ function default.register_decorations() sidelen = 16, noise_params = { offset = 0.0, - scale = -0.0015, + scale = -0.0008, spread = {x = 250, y = 250, z = 250}, seed = 2, octaves = 3, @@ -1216,17 +1223,17 @@ function default.register_decorations() y_min = 1, y_max = 31000, schematic = { - size = { x = 3, y = 3, z = 1}, + size = {x = 3, y = 3, z = 1}, data = { - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "air", prob = 0 }, - { name = "default:aspen_tree", param2 = 12 }, - { name = "default:aspen_tree", param2 = 12 }, - { name = "default:aspen_tree", param2 = 12, prob = 127 }, - { name = "flowers:mushroom_red", prob = 63 }, - { name = "flowers:mushroom_brown", prob = 63 }, - { name = "air", prob = 0 }, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "air", prob = 0}, + {name = "default:aspen_tree", param2 = 12}, + {name = "default:aspen_tree", param2 = 12}, + {name = "default:aspen_tree", param2 = 12, prob = 127}, + {name = "flowers:mushroom_red", prob = 63}, + {name = "flowers:mushroom_brown", prob = 63}, + {name = "air", prob = 0}, }, }, flags = "place_center_x", diff --git a/mods/default/models/character.b3d b/mods/default/models/character.b3d index bc9d9273..f411f471 100644 Binary files a/mods/default/models/character.b3d and b/mods/default/models/character.b3d differ diff --git a/mods/default/models/character.blend b/mods/default/models/character.blend index 34c56240..6493f813 100644 Binary files a/mods/default/models/character.blend and b/mods/default/models/character.blend differ diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index c79d74df..a7fd43fa 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -146,9 +146,11 @@ default:chest_locked default:bookshelf -default:sign_wall +default:sign_wall_wood +default:sign_wall_steel -default:ladder +default:ladder_wood +default:ladder_steel default:fence_wood default:fence_acacia_wood @@ -324,11 +326,10 @@ minetest.register_node("default:dirt_with_snow", { groups = {crumbly = 3, soil = 1}, drop = 'default:dirt', sounds = default.node_sound_dirt_defaults({ - footstep = {name = "default_snow_footstep", gain = 0.25}, + footstep = {name = "default_snow_footstep", gain = 0.15}, }), }) - minetest.register_node("default:sand", { description = "Sand", tiles = {"default_sand.png"}, @@ -380,8 +381,9 @@ minetest.register_node("default:snow", { }, groups = {crumbly = 3, falling_node = 1, puts_out_fire = 1}, sounds = default.node_sound_dirt_defaults({ - footstep = {name = "default_snow_footstep", gain = 0.25}, - dug = {name = "default_snow_footstep", gain = 0.75}, + footstep = {name = "default_snow_footstep", gain = 0.15}, + dug = {name = "default_snow_footstep", gain = 0.2}, + dig = {name = "default_snow_footstep", gain = 0.2} }), on_construct = function(pos) @@ -397,12 +399,12 @@ minetest.register_node("default:snowblock", { tiles = {"default_snow.png"}, groups = {crumbly = 3, puts_out_fire = 1}, sounds = default.node_sound_dirt_defaults({ - footstep = {name = "default_snow_footstep", gain = 0.25}, - dug = {name = "default_snow_footstep", gain = 0.75}, + footstep = {name = "default_snow_footstep", gain = 0.15}, + dug = {name = "default_snow_footstep", gain = 0.2}, + dig = {name = "default_snow_footstep", gain = 0.2} }), }) - minetest.register_node("default:ice", { description = "Ice", tiles = {"default_ice.png"}, @@ -879,10 +881,6 @@ minetest.register_node("default:cactus", { groups = {snappy = 1, choppy = 3, flammable = 2}, sounds = default.node_sound_wood_defaults(), on_place = minetest.rotate_node, - - after_dig_node = function(pos, node, metadata, digger) - default.dig_up(pos, node, digger) - end, }) minetest.register_node("default:papyrus", { @@ -1055,7 +1053,6 @@ end minetest.register_node("default:water_source", { description = "Water Source", - inventory_image = minetest.inventorycube("default_water.png"), drawtype = "liquid", tiles = { { @@ -1100,7 +1097,6 @@ minetest.register_node("default:water_source", { minetest.register_node("default:water_flowing", { description = "Flowing Water", - inventory_image = minetest.inventorycube("default_water.png"), drawtype = "flowingliquid", tiles = {"default_water.png"}, special_tiles = { @@ -1147,7 +1143,6 @@ minetest.register_node("default:water_flowing", { minetest.register_node("default:river_water_source", { description = "River Water Source", - inventory_image = minetest.inventorycube("default_river_water.png"), drawtype = "liquid", tiles = { { @@ -1193,7 +1188,6 @@ minetest.register_node("default:river_water_source", { minetest.register_node("default:river_water_flowing", { description = "Flowing River Water", - inventory_image = minetest.inventorycube("default_river_water.png"), drawtype = "flowingliquid", tiles = {"default_river_water.png"}, special_tiles = { @@ -1242,7 +1236,6 @@ minetest.register_node("default:river_water_flowing", { minetest.register_node("default:lava_source", { description = "Lava Source", - inventory_image = minetest.inventorycube("default_lava.png"), drawtype = "liquid", tiles = { { @@ -1289,7 +1282,6 @@ minetest.register_node("default:lava_source", { minetest.register_node("default:lava_flowing", { description = "Flowing Lava", - inventory_image = minetest.inventorycube("default_lava.png"), drawtype = "flowingliquid", tiles = {"default_lava.png"}, special_tiles = { @@ -1420,7 +1412,14 @@ local function get_locked_chest_formspec(pos) end local function has_locked_chest_privilege(meta, player) - if player:get_player_name() ~= meta:get_string("owner") then + local name = "" + if player then + if minetest.check_player_privs(player, "protection_bypass") then + return true + end + name = player:get_player_name() + end + if name ~= meta:get_string("owner") then return false end return true @@ -1455,11 +1454,13 @@ minetest.register_node("default:chest", { end, on_metadata_inventory_put = function(pos, listname, index, stack, player) minetest.log("action", player:get_player_name() .. - " moves stuff to chest at " .. minetest.pos_to_string(pos)) + " moves " .. stack:get_name() .. + " to chest at " .. minetest.pos_to_string(pos)) end, on_metadata_inventory_take = function(pos, listname, index, stack, player) minetest.log("action", player:get_player_name() .. - " takes stuff from chest at " .. minetest.pos_to_string(pos)) + " takes " .. stack:get_name() .. + " from chest at " .. minetest.pos_to_string(pos)) end, }) @@ -1515,11 +1516,13 @@ minetest.register_node("default:chest_locked", { end, on_metadata_inventory_put = function(pos, listname, index, stack, player) minetest.log("action", player:get_player_name() .. - " moves stuff to locked chest at " .. minetest.pos_to_string(pos)) + " moves " .. stack:get_name() .. + " to locked chest at " .. minetest.pos_to_string(pos)) end, on_metadata_inventory_take = function(pos, listname, index, stack, player) minetest.log("action", player:get_player_name() .. - " takes stuff from locked chest at " .. minetest.pos_to_string(pos)) + " takes " .. stack:get_name() .. + " from locked chest at " .. minetest.pos_to_string(pos)) end, on_rightclick = function(pos, node, clicker) local meta = minetest.get_meta(pos) @@ -1611,56 +1614,67 @@ minetest.register_node("default:bookshelf", { end, }) +local function register_sign(material, desc, def) + minetest.register_node("default:sign_wall_" .. material, { + description = desc .. " Sign", + drawtype = "nodebox", + tiles = {"default_sign_wall_" .. material .. ".png"}, + inventory_image = "default_sign_" .. material .. ".png", + wield_image = "default_sign_" .. material .. ".png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + node_box = { + type = "wallmounted", + wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, + wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, + wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}, + }, + groups = def.groups, + legacy_wallmounted = true, + sounds = def.sounds, -minetest.register_node("default:sign_wall", { - description = "Sign", - drawtype = "nodebox", - tiles = {"default_sign.png"}, - inventory_image = "default_sign_wall.png", - wield_image = "default_sign_wall.png", - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - node_box = { - type = "wallmounted", - wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, - wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, - wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}, - }, - groups = {choppy = 2, dig_immediate = 2, attached_node = 1}, - legacy_wallmounted = true, - sounds = default.node_sound_defaults(), + on_construct = function(pos) + --local n = minetest.get_node(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "field[text;;${text}]") + meta:set_string("infotext", "\"\"") + end, + on_receive_fields = function(pos, formname, fields, sender) + --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) + local player_name = sender:get_player_name() + if minetest.is_protected(pos, player_name) then + minetest.record_protection_violation(pos, player_name) + return + end + local meta = minetest.get_meta(pos) + if not fields.text then return end + minetest.log("action", (player_name or "") .. " wrote \"" .. + fields.text .. "\" to sign at " .. minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"' .. fields.text .. '"') + end, + }) +end - on_construct = function(pos) - --local n = minetest.get_node(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", "field[text;;${text}]") - meta:set_string("infotext", "\"\"") - end, - on_receive_fields = function(pos, formname, fields, sender) - --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) - if minetest.is_protected(pos, sender:get_player_name()) then - minetest.record_protection_violation(pos, sender:get_player_name()) - return - end - local meta = minetest.get_meta(pos) - if not fields.text then return end - minetest.log("action", (sender:get_player_name() or "") .. " wrote \"" .. - fields.text .. "\" to sign at " .. minetest.pos_to_string(pos)) - meta:set_string("text", fields.text) - meta:set_string("infotext", '"' .. fields.text .. '"') - end, +register_sign("wood", "Wooden", { + sounds = default.node_sound_wood_defaults(), + groups = {choppy = 2, attached_node = 1, flammable = 2} }) +register_sign("steel", "Steel", { + sounds = default.node_sound_defaults(), + groups = {cracky = 2, attached_node = 1} +}) -minetest.register_node("default:ladder", { - description = "Ladder", +minetest.register_node("default:ladder_wood", { + description = "Wooden Ladder", drawtype = "signlike", - tiles = {"default_ladder.png"}, - inventory_image = "default_ladder.png", - wield_image = "default_ladder.png", + tiles = {"default_ladder_wood.png"}, + inventory_image = "default_ladder_wood.png", + wield_image = "default_ladder_wood.png", paramtype = "light", paramtype2 = "wallmounted", sunlight_propagates = true, @@ -1678,9 +1692,31 @@ minetest.register_node("default:ladder", { sounds = default.node_sound_wood_defaults(), }) +minetest.register_node("default:ladder_steel", { + description = "Steel Ladder", + drawtype = "signlike", + tiles = {"default_ladder_steel.png"}, + inventory_image = "default_ladder_steel.png", + wield_image = "default_ladder_steel.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + climbable = true, + is_ground_content = false, + selection_box = { + type = "wallmounted", + --wall_top = = + --wall_bottom = = + --wall_side = = + }, + groups = {cracky = 2}, + sounds = default.node_sound_stone_defaults(), +}) + default.register_fence("default:fence_wood", { description = "Wooden Fence", - texture = "default_wood.png", + texture = "default_fence_wood.png", material = "default:wood", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, sounds = default.node_sound_wood_defaults() @@ -1688,7 +1724,7 @@ default.register_fence("default:fence_wood", { default.register_fence("default:fence_acacia_wood", { description = "Acacia Fence", - texture = "default_acacia_wood.png", + texture = "default_fence_acacia_wood.png", material = "default:acacia_wood", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, sounds = default.node_sound_wood_defaults() @@ -1696,7 +1732,7 @@ default.register_fence("default:fence_acacia_wood", { default.register_fence("default:fence_junglewood", { description = "Junglewood Fence", - texture = "default_junglewood.png", + texture = "default_fence_junglewood.png", material = "default:junglewood", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, sounds = default.node_sound_wood_defaults() @@ -1704,7 +1740,7 @@ default.register_fence("default:fence_junglewood", { default.register_fence("default:fence_pine_wood", { description = "Pine Fence", - texture = "default_pine_wood.png", + texture = "default_fence_pine_wood.png", material = "default:pine_wood", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, sounds = default.node_sound_wood_defaults() @@ -1712,7 +1748,7 @@ default.register_fence("default:fence_pine_wood", { default.register_fence("default:fence_aspen_wood", { description = "Aspen Fence", - texture = "default_aspen_wood.png", + texture = "default_fence_aspen_wood.png", material = "default:aspen_wood", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, sounds = default.node_sound_wood_defaults() @@ -1722,7 +1758,6 @@ minetest.register_node("default:glass", { description = "Glass", drawtype = "glasslike_framed_optional", tiles = {"default_glass.png", "default_glass_detail.png"}, - inventory_image = minetest.inventorycube("default_glass.png"), paramtype = "light", sunlight_propagates = true, is_ground_content = false, @@ -1734,7 +1769,6 @@ minetest.register_node("default:obsidian_glass", { description = "Obsidian Glass", drawtype = "glasslike_framed_optional", tiles = {"default_obsidian_glass.png", "default_obsidian_glass_detail.png"}, - inventory_image = minetest.inventorycube("default_obsidian_glass.png"), paramtype = "light", is_ground_content = false, sunlight_propagates = true, diff --git a/mods/default/schematics/snowy_pine_tree_from_sapling.mts b/mods/default/schematics/snowy_pine_tree_from_sapling.mts new file mode 100644 index 00000000..0692049a Binary files /dev/null and b/mods/default/schematics/snowy_pine_tree_from_sapling.mts differ diff --git a/mods/default/models/character.png b/mods/default/textures/character.png similarity index 100% rename from mods/default/models/character.png rename to mods/default/textures/character.png diff --git a/mods/default/textures/default_fence_acacia_wood.png b/mods/default/textures/default_fence_acacia_wood.png new file mode 100644 index 00000000..3b973f34 Binary files /dev/null and b/mods/default/textures/default_fence_acacia_wood.png differ diff --git a/mods/default/textures/default_fence_aspen_wood.png b/mods/default/textures/default_fence_aspen_wood.png new file mode 100644 index 00000000..7fb624dc Binary files /dev/null and b/mods/default/textures/default_fence_aspen_wood.png differ diff --git a/mods/default/textures/default_fence_junglewood.png b/mods/default/textures/default_fence_junglewood.png new file mode 100644 index 00000000..c390941c Binary files /dev/null and b/mods/default/textures/default_fence_junglewood.png differ diff --git a/mods/default/textures/default_fence_pine_wood.png b/mods/default/textures/default_fence_pine_wood.png new file mode 100644 index 00000000..74609d99 Binary files /dev/null and b/mods/default/textures/default_fence_pine_wood.png differ diff --git a/mods/default/textures/default_fence_wood.png b/mods/default/textures/default_fence_wood.png new file mode 100644 index 00000000..1e76430d Binary files /dev/null and b/mods/default/textures/default_fence_wood.png differ diff --git a/mods/default/textures/default_gravel.png b/mods/default/textures/default_gravel.png index ad48fa46..25a78b64 100644 Binary files a/mods/default/textures/default_gravel.png and b/mods/default/textures/default_gravel.png differ diff --git a/mods/default/textures/default_jungletree_top.png b/mods/default/textures/default_jungletree_top.png index 62cd7814..4844682b 100644 Binary files a/mods/default/textures/default_jungletree_top.png and b/mods/default/textures/default_jungletree_top.png differ diff --git a/mods/default/textures/default_ladder_steel.png b/mods/default/textures/default_ladder_steel.png new file mode 100644 index 00000000..1cc6dfde Binary files /dev/null and b/mods/default/textures/default_ladder_steel.png differ diff --git a/mods/default/textures/default_ladder.png b/mods/default/textures/default_ladder_wood.png similarity index 100% rename from mods/default/textures/default_ladder.png rename to mods/default/textures/default_ladder_wood.png diff --git a/mods/default/textures/default_sign.png b/mods/default/textures/default_sign.png deleted file mode 100644 index 912a3723..00000000 Binary files a/mods/default/textures/default_sign.png and /dev/null differ diff --git a/mods/default/textures/default_sign_steel.png b/mods/default/textures/default_sign_steel.png new file mode 100644 index 00000000..5705c787 Binary files /dev/null and b/mods/default/textures/default_sign_steel.png differ diff --git a/mods/default/textures/default_sign_wall.png b/mods/default/textures/default_sign_wall.png deleted file mode 100644 index 56a7d2e3..00000000 Binary files a/mods/default/textures/default_sign_wall.png and /dev/null differ diff --git a/mods/default/textures/default_sign_wall_steel.png b/mods/default/textures/default_sign_wall_steel.png new file mode 100644 index 00000000..d8d4a5b0 Binary files /dev/null and b/mods/default/textures/default_sign_wall_steel.png differ diff --git a/mods/default/textures/default_sign_wall_wood.png b/mods/default/textures/default_sign_wall_wood.png new file mode 100644 index 00000000..f25a67a8 Binary files /dev/null and b/mods/default/textures/default_sign_wall_wood.png differ diff --git a/mods/default/textures/default_sign_wood.png b/mods/default/textures/default_sign_wood.png new file mode 100644 index 00000000..a25a4c34 Binary files /dev/null and b/mods/default/textures/default_sign_wood.png differ diff --git a/mods/default/trees.lua b/mods/default/trees.lua index 48718e5d..c93fdabc 100644 --- a/mods/default/trees.lua +++ b/mods/default/trees.lua @@ -1,10 +1,10 @@ +local random = math.random + -- -- Grow trees from saplings -- --- 'Can grow' function - -local random = math.random +-- 'can grow' function function default.can_grow(pos) local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z}) @@ -24,6 +24,39 @@ function default.can_grow(pos) end +-- 'is snow nearby' function + +local function is_snow_nearby(pos) + local x, y, z = pos.x, pos.y, pos.z + local c_snow = minetest.get_content_id("default:snow") + local c_snowblock = minetest.get_content_id("default:snowblock") + local c_dirtsnow = minetest.get_content_id("default:dirt_with_snow") + + local vm = minetest.get_voxel_manip() + local minp, maxp = vm:read_from_map( + {x = x - 1, y = y - 1, z = z - 1}, + {x = x + 1, y = y + 1, z = z + 1} + ) + local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) + local data = vm:get_data() + + for yy = y - 1, y + 1 do + for zz = z - 1, z + 1 do + local vi = a:index(x - 1, yy, zz) + for xx = x - 1, x + 1 do + local nodid = data[vi] + if nodid == c_snow or nodid == c_snowblock or nodid == c_dirtsnow then + return true + end + vi = vi + 1 + end + end + end + + return false +end + + -- Sapling ABM minetest.register_abm({ @@ -57,8 +90,11 @@ minetest.register_abm({ elseif node.name == "default:pine_sapling" then minetest.log("action", "A pine sapling grows into a tree at ".. minetest.pos_to_string(pos)) + local snow = is_snow_nearby(pos) if mapgen == "v6" then - default.grow_pine_tree(pos) + default.grow_pine_tree(pos, snow) + elseif snow then + default.grow_new_snowy_pine_tree(pos) else default.grow_new_pine_tree(pos) end @@ -199,7 +235,8 @@ function default.grow_jungle_tree(pos, bad) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local data = vm:get_data() - add_trunk_and_leaves(data, a, pos, c_jungletree, c_jungleleaves, height, 3, 30, false) + add_trunk_and_leaves(data, a, pos, c_jungletree, c_jungleleaves, + height, 3, 30, false) -- Roots for z_dist = -1, 1 do @@ -240,7 +277,7 @@ local function add_snow(data, vi, c_air, c_ignore, c_snow) end end -function default.grow_pine_tree(pos) +function default.grow_pine_tree(pos, snow) local x, y, z = pos.x, pos.y, pos.z local maxy = y + random(9, 13) -- Trunk top @@ -249,32 +286,15 @@ function default.grow_pine_tree(pos) local c_pine_tree = minetest.get_content_id("default:pine_tree") local c_pine_needles = minetest.get_content_id("default:pine_needles") local c_snow = minetest.get_content_id("default:snow") - local c_snowblock = minetest.get_content_id("default:snowblock") - local c_dirtsnow = minetest.get_content_id("default:dirt_with_snow") local vm = minetest.get_voxel_manip() local minp, maxp = vm:read_from_map( - {x = x - 3, y = y - 1, z = z - 3}, + {x = x - 3, y = y, z = z - 3}, {x = x + 3, y = maxy + 3, z = z + 3} ) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local data = vm:get_data() - -- Scan for snow nodes near sapling to enable snow on branches - local snow = false - for yy = y - 1, y + 1 do - for zz = z - 1, z + 1 do - local vi = a:index(x - 1, yy, zz) - for xx = x - 1, x + 1 do - local nodid = data[vi] - if nodid == c_snow or nodid == c_snowblock or nodid == c_dirtsnow then - snow = true - end - vi = vi + 1 - end - end - end - -- Upper branches layer local dev = 3 for yy = maxy - 1, maxy + 1 do @@ -350,7 +370,8 @@ function default.grow_pine_tree(pos) end -- Trunk - data[a:index(x, y, z)] = c_pine_tree -- Force-place lowest trunk node to replace sapling + -- Force-place lowest trunk node to replace sapling + data[a:index(x, y, z)] = c_pine_tree for yy = y + 1, maxy do local vi = a:index(x, yy, z) local node_id = data[vi] @@ -369,42 +390,57 @@ end -- New apple tree function default.grow_new_apple_tree(pos) - local path = minetest.get_modpath("default") .. "/schematics/apple_tree_from_sapling.mts" + local path = minetest.get_modpath("default") .. + "/schematics/apple_tree_from_sapling.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, - path, 0, nil, false) + path, "0", nil, false) end -- New jungle tree function default.grow_new_jungle_tree(pos) - local path = minetest.get_modpath("default") .. "/schematics/jungle_tree_from_sapling.mts" + local path = minetest.get_modpath("default") .. + "/schematics/jungle_tree_from_sapling.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, - path, 0, nil, false) + path, "0", nil, false) end -- New pine tree function default.grow_new_pine_tree(pos) - local path = minetest.get_modpath("default") .. "/schematics/pine_tree_from_sapling.mts" + local path = minetest.get_modpath("default") .. + "/schematics/pine_tree_from_sapling.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, - path, 0, nil, false) + path, "0", nil, false) +end + + +-- New snowy pine tree + +function default.grow_new_snowy_pine_tree(pos) + local path = minetest.get_modpath("default") .. + "/schematics/snowy_pine_tree_from_sapling.mts" + minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, + path, "random", nil, false) end -- New acacia tree function default.grow_new_acacia_tree(pos) - local path = minetest.get_modpath("default") .. "/schematics/acacia_tree_from_sapling.mts" + local path = minetest.get_modpath("default") .. + "/schematics/acacia_tree_from_sapling.mts" minetest.place_schematic({x = pos.x - 4, y = pos.y - 1, z = pos.z - 4}, - path, random, nil, false) + path, "random", nil, false) end -- New aspen tree function default.grow_new_aspen_tree(pos) - local path = minetest.get_modpath("default") .. "/schematics/aspen_tree_from_sapling.mts" + local path = minetest.get_modpath("default") .. + "/schematics/aspen_tree_from_sapling.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, - path, 0, nil, false) + path, "0", nil, false) end diff --git a/mods/doors/README.txt b/mods/doors/README.txt index 27f0507a..deff667c 100644 --- a/mods/doors/README.txt +++ b/mods/doors/README.txt @@ -1,12 +1,16 @@ Minetest Game mod: doors ======================== -version: 1.3 +version: 2.0 License of source code: ----------------------- Copyright (C) 2012 PilzAdam modified by BlockMen (added sounds, glassdoors[glass, obsidian glass], trapdoor) Steel trapdoor added by sofar. +Copyright (C) 2016 sofar@foo-projects.org +Re-implemented most of the door algorithms, added meshes, UV wrapped texture +Added doors API to facilitate coding mods accessing and operating doors. +Added Fence Gate model, code, and sounds This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it @@ -40,8 +44,25 @@ following textures created by sofar (CC-BY-SA-3.0) doors_trapdoor_steel_side.png door_trapdoor_side.png + +Obsidian door textures by red-001 based on textures by Pilzadam and BlockMen: WTFPL + door_obsidian_glass.png + +Glass door textures by red-001 based on textures by celeron55: CC BY-SA 3.0 + door_glass.png All other textures (created by PilzAdam): WTFPL +Door textures were converted to the new texture map by sofar, paramat and +red-001, under the same license as the originals. + +Models: +-------------------------------------- +Door 3d models by sofar (CC-BY-SA-3.0) + - door_a.obj + - door_b.obj +Fence gate models by sofar (CC-BY-SA-3.0) + - fencegate_open.obj + - fencegate_closed.obj License of sounds -------------------------------------- @@ -49,3 +70,9 @@ Opening-Sound created by CGEffex (CC BY 3.0), modified by BlockMen door_open.ogg Closing-Sound created by bennstir (CC BY 3.0) door_close.ogg +fencegate_open.ogg: + http://www.freesound.org/people/mhtaylor67/sounds/126041/ - CC0 +fencegate_close.ogg: + http://www.freesound.org/people/BarkersPinhead/sounds/274807/ - CC-BY-3.0 + http://www.freesound.org/people/rivernile7/sounds/249573/ - CC-BY-3.0 + diff --git a/mods/doors/init.lua b/mods/doors/init.lua index e942d466..9300e6ff 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -1,435 +1,531 @@ + +--[[ + +Copyright (C) 2012 PilzAdam + modified by BlockMen (added sounds, glassdoors[glass, obsidian glass], trapdoor) +Copyright (C) 2015 - Auke Kok + +--]] + +-- our API object doors = {} --- Registers a door -function doors.register_door(name, def) - def.groups.not_in_creative_inventory = 1 +-- private data +local _doors = {} +_doors.registered_doors = {} +_doors.registered_trapdoors = {} - local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}} +-- returns an object to a door object or nil +function doors.get(pos) + if _doors.registered_doors[minetest.get_node(pos).name] then + -- A normal upright door + return { + pos = pos, + open = function(self, player) + if self:state() then + return false + end + return _doors.door_toggle(self.pos, player) + end, + close = function(self, player) + if not self:state() then + return false + end + return _doors.door_toggle(self.pos, player) + end, + toggle = function(self, player) + return _doors.door_toggle(self.pos, player) + end, + state = function(self) + local state = minetest.get_meta(self.pos):get_int("state") + return state %2 == 1 + end + } + elseif _doors.registered_trapdoors[minetest.get_node(pos).name] then + -- A trapdoor + return { + pos = pos, + open = function(self, player) + if self:state() then + return false + end + return _doors.trapdoor_toggle(self.pos, player) + end, + close = function(self, player) + if not self:state() then + return false + end + return _doors.trapdoor_toggle(self.pos, player) + end, + toggle = function(self, player) + return _doors.trapdoor_toggle(self.pos, player) + end, + state = function(self) + local name = minetest.get_node(pos).name + return name:sub(-5) == "_open" + end + } + else + return nil + end +end - if not def.node_box_bottom then - def.node_box_bottom = box - end - if not def.node_box_top then - def.node_box_top = box - end - if not def.selection_box_bottom then - def.selection_box_bottom= box - end - if not def.selection_box_top then - def.selection_box_top = box +-- this hidden node is placed on top of the bottom, and prevents +-- nodes from being placed in the top half of the door. +minetest.register_node("doors:hidden", { + description = "Hidden Door Segment", + drawtype = "airlike", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + pointable = false, + diggable = false, + buildable_to = false, + floodable = false, + drop = "", + groups = { not_in_creative_inventory = 1 }, + on_blast = function() end +}) + +-- table used to aid door opening/closing +local transform = { + { + { v = "_a", param2 = 3 }, + { v = "_a", param2 = 0 }, + { v = "_a", param2 = 1 }, + { v = "_a", param2 = 2 }, + }, + { + { v = "_b", param2 = 1 }, + { v = "_b", param2 = 2 }, + { v = "_b", param2 = 3 }, + { v = "_b", param2 = 0 }, + }, + { + { v = "_b", param2 = 1 }, + { v = "_b", param2 = 2 }, + { v = "_b", param2 = 3 }, + { v = "_b", param2 = 0 }, + }, + { + { v = "_a", param2 = 3 }, + { v = "_a", param2 = 0 }, + { v = "_a", param2 = 1 }, + { v = "_a", param2 = 2 }, + }, +} + +function _doors.door_toggle(pos, clicker) + local meta = minetest.get_meta(pos) + local state = meta:get_int("state") + local def = minetest.registered_nodes[minetest.get_node(pos).name] + local name = def.door.name + + if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then + local owner = meta:get_string("doors_owner") + if owner ~= "" then + if clicker:get_player_name() ~= owner then + return false + end + end end - if not def.sound_close_door then - def.sound_close_door = "doors_door_close" + local old = state + -- until Lua-5.2 we have no bitwise operators :( + if state % 2 == 1 then + state = state - 1 + else + state = state + 1 end - if not def.sound_open_door then - def.sound_open_door = "doors_door_open" + + local dir = minetest.get_node(pos).param2 + if state % 2 == 0 then + minetest.sound_play(def.door.sounds[1], {pos = pos, gain = 0.3, max_hear_distance = 10}) + else + minetest.sound_play(def.door.sounds[2], {pos = pos, gain = 0.3, max_hear_distance = 10}) end - - - minetest.register_craftitem(name, { + + minetest.swap_node(pos, { + name = name .. transform[state + 1][dir+1].v, + param2 = transform[state + 1][dir+1].param2 + }) + meta:set_int("state", state) + + return true +end + + +local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing) + -- Run script hook + local _, callback + for _, callback in ipairs(core.registered_on_placenodes) do + -- Deepcopy pos, node and pointed_thing because callback can modify them + local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z} + local newnode_copy = {name = newnode.name, param1 = newnode.param1, param2 = newnode.param2} + local oldnode_copy = {name = oldnode.name, param1 = oldnode.param1, param2 = oldnode.param2} + local pointed_thing_copy = { + type = pointed_thing.type, + above = vector.new(pointed_thing.above), + under = vector.new(pointed_thing.under), + ref = pointed_thing.ref, + } + callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) + end +end + +function doors.register(name, def) + if not name:find(":") then + name = "doors:" .. name + end + + -- replace old doors of this type automatically + minetest.register_abm({ + nodenames = {name.."_b_1", name.."_b_2"}, + interval = 7.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local l = tonumber(node.name:sub(-1)) + local meta = minetest.get_meta(pos) + local h = meta:get_int("right") + 1 + local p2 = node.param2 + local replace = { + { { type = "a", state = 0 }, { type = "a", state = 3 } }, + { { type = "b", state = 1 }, { type = "b", state = 2 } } + } + local new = replace[l][h] + -- retain infotext and doors_owner fields + minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2}) + meta:set_int("state", new.state) + -- wipe meta on top node as it's unused + minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, { name = "doors:hidden" }) + end + }) + + minetest.register_craftitem(":" .. name, { description = def.description, inventory_image = def.inventory_image, on_place = function(itemstack, placer, pointed_thing) + local pos = nil + if not pointed_thing.type == "node" then return itemstack end - local ptu = pointed_thing.under - local nu = minetest.get_node(ptu) - if minetest.registered_nodes[nu.name].on_rightclick then - return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack) + local node = minetest.get_node(pointed_thing.under) + local pdef = minetest.registered_nodes[node.name] + if pdef and pdef.on_rightclick then + return pdef.on_rightclick(pointed_thing.under, + node, placer, itemstack) end - local pt = pointed_thing.above - local pt2 = {x=pt.x, y=pt.y, z=pt.z} - pt2.y = pt2.y+1 - if - not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or - not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or - not placer or - not placer:is_player() - then - return itemstack - end - - if minetest.is_protected(pt, placer:get_player_name()) or - minetest.is_protected(pt2, placer:get_player_name()) then - minetest.record_protection_violation(pt, placer:get_player_name()) - return itemstack - end - - local p2 = minetest.dir_to_facedir(placer:get_look_dir()) - local pt3 = {x=pt.x, y=pt.y, z=pt.z} - if p2 == 0 then - pt3.x = pt3.x-1 - elseif p2 == 1 then - pt3.z = pt3.z+1 - elseif p2 == 2 then - pt3.x = pt3.x+1 - elseif p2 == 3 then - pt3.z = pt3.z-1 - end - if minetest.get_item_group(minetest.get_node(pt3).name, "door") == 0 then - minetest.set_node(pt, {name=name.."_b_1", param2=p2}) - minetest.set_node(pt2, {name=name.."_t_1", param2=p2}) + if pdef and pdef.buildable_to then + pos = pointed_thing.under else - minetest.set_node(pt, {name=name.."_b_2", param2=p2}) - minetest.set_node(pt2, {name=name.."_t_2", param2=p2}) - minetest.get_meta(pt):set_int("right", 1) - minetest.get_meta(pt2):set_int("right", 1) + pos = pointed_thing.above + node = minetest.get_node(pos) + pdef = minetest.registered_nodes[node.name] + if not pdef or not pdef.buildable_to then + return itemstack + end end - if def.only_placer_can_open then + local above = { x = pos.x, y = pos.y + 1, z = pos.z } + if not minetest.registered_nodes[minetest.get_node(above).name].buildable_to then + return itemstack + end + + local pn = placer:get_player_name() + if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) then + return itemstack + end + + local dir = minetest.dir_to_facedir(placer:get_look_dir()) + + local ref = { + { x = -1, y = 0, z = 0 }, + { x = 0, y = 0, z = 1 }, + { x = 1, y = 0, z = 0 }, + { x = 0, y = 0, z = -1 }, + } + + local aside = { + x = pos.x + ref[dir + 1].x, + y = pos.y + ref[dir + 1].y, + z = pos.z + ref[dir + 1].z, + } + + local state = 0 + if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then + state = state + 2 + minetest.set_node(pos, {name = name .. "_b", param2 = dir}) + else + minetest.set_node(pos, {name = name .. "_a", param2 = dir}) + end + minetest.set_node(above, { name = "doors:hidden" }) + + local meta = minetest.get_meta(pos) + meta:set_int("state", state) + + if def.protected then local pn = placer:get_player_name() - local meta = minetest.get_meta(pt) meta:set_string("doors_owner", pn) - meta:set_string("infotext", "Owned by "..pn) - meta = minetest.get_meta(pt2) - meta:set_string("doors_owner", pn) - meta:set_string("infotext", "Owned by "..pn) + meta:set_string("infotext", "Owned by " .. pn) end if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end + + on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing) + return itemstack - end, + end }) - local tt = def.tiles_top - local tb = def.tiles_bottom - - local function after_dig_node(pos, name, digger) - local node = minetest.get_node(pos) - if node.name == name then - minetest.node_dig(pos, node, digger) - end - end - - local function check_and_blast(pos, name) - local node = minetest.get_node(pos) - if node.name == name then - minetest.remove_node(pos) - end - end - - local function make_on_blast(base_name, dir, door_type, other_door_type) - if def.only_placer_can_open then - return function() end - else - return function(pos, intensity) - check_and_blast(pos, base_name .. door_type) - pos.y = pos.y + dir - check_and_blast(pos, base_name .. other_door_type) - end - end - end - - local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) - pos.y = pos.y+dir - if minetest.get_node(pos).name ~= check_name then - return - end - local p2 = minetest.get_node(pos).param2 - p2 = params[p2+1] - - minetest.swap_node(pos, {name=replace_dir, param2=p2}) - - pos.y = pos.y-dir - minetest.swap_node(pos, {name=replace, param2=p2}) - - local snd_1 = def.sound_close_door - local snd_2 = def.sound_open_door - if params[1] == 3 then - snd_1 = def.sound_open_door - snd_2 = def.sound_close_door - end - - if minetest.get_meta(pos):get_int("right") ~= 0 then - minetest.sound_play(snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10}) - else - minetest.sound_play(snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10}) - end - end - - local function check_player_priv(pos, player) - if not def.only_placer_can_open then + local can_dig = function(pos, digger) + if not def.protected then return true end local meta = minetest.get_meta(pos) - local pn = player:get_player_name() - return meta:get_string("doors_owner") == pn + local name = "" + if digger then + name = digger:get_player_name() + end + return meta:get_string("doors_owner") == name end - local function on_rotate(pos, node, dir, user, check_name, mode, new_param2) - if not check_player_priv(pos, user) then - return false - end - if mode ~= screwdriver.ROTATE_FACE then - return false - end - - pos.y = pos.y + dir - if not minetest.get_node(pos).name == check_name then - return false - end - if minetest.is_protected(pos, user:get_player_name()) then - minetest.record_protection_violation(pos, user:get_player_name()) - return false - end - - local node2 = minetest.get_node(pos) - node2.param2 = (node2.param2 + 1) % 4 - minetest.swap_node(pos, node2) - - pos.y = pos.y - dir - node.param2 = (node.param2 + 1) % 4 - minetest.swap_node(pos, node) - return true + if not def.sounds then + def.sounds = default.node_sound_wood_defaults() end - minetest.register_node(name.."_b_1", { - tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"}, + if not def.sound_open then + def.sound_open = "doors_door_open" + end + + if not def.sound_close then + def.sound_close = "doors_door_close" + end + + def.groups.not_in_creative_inventory = 1 + def.groups.door = 1 + def.drop = name + def.door = { + name = name, + sounds = { def.sound_close, def.sound_open }, + } + + def.on_rightclick = function(pos, node, clicker) + _doors.door_toggle(pos, clicker) + end + def.after_dig_node = function(pos, node, meta, digger) + minetest.remove_node({ x = pos.x, y = pos.y + 1, z = pos.z}) + end + def.can_dig = function(pos, player) + return can_dig(pos, player) + end + def.on_rotate = function(pos, node, user, mode, new_param2) + return false + end + + if def.protected then + def.on_blast = function() end + else + def.on_blast = function(pos, intensity) + minetest.remove_node(pos) + -- hidden node doesn't get blasted away. + minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + return {name} + end + end + + def.on_destruct = function(pos) + minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + end + + minetest.register_node(":" .. name .. "_a", { + description = def.description, + visual = "mesh", + mesh = "door_a.obj", + tiles = def.tiles, + drawtype = "mesh", paramtype = "light", paramtype2 = "facedir", + sunlight_propagates = true, + use_texture_alpha = true, + walkable = true, is_ground_content = false, - drop = name, - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = def.node_box_bottom - }, + buildable_to = false, + drop = def.drop, + groups = def.groups, + sounds = def.sounds, + door = def.door, + on_rightclick = def.on_rightclick, + after_dig_node = def.after_dig_node, + can_dig = def.can_dig, + on_rotate = def.on_rotate, + on_blast = def.on_blast, + on_destruct = def.on_destruct, selection_box = { type = "fixed", - fixed = def.selection_box_bottom + fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16} + }, + collision_box = { + type = "fixed", + fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16} }, - groups = def.groups, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - pos.y = pos.y+1 - after_dig_node(pos, name.."_t_1", digger) - end, - - on_rightclick = function(pos, node, clicker) - if check_player_priv(pos, clicker) then - on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0}) - end - end, - - on_rotate = function(pos, node, user, mode, new_param2) - return on_rotate(pos, node, 1, user, name.."_t_1", mode) - end, - - can_dig = check_player_priv, - sounds = def.sounds, - sunlight_propagates = def.sunlight, - on_blast = make_on_blast(name, 1, "_b_1", "_t_1") }) - minetest.register_node(name.."_t_1", { - tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1].."^[transformfx"}, + minetest.register_node(":" .. name .. "_b", { + description = def.description, + visual = "mesh", + mesh = "door_b.obj", + tiles = def.tiles, + drawtype = "mesh", paramtype = "light", paramtype2 = "facedir", + sunlight_propagates = true, + use_texture_alpha = true, + walkable = true, is_ground_content = false, - drop = "", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = def.node_box_top - }, + buildable_to = false, + drop = def.drop, + groups = def.groups, + sounds = def.sounds, + door = def.door, + on_rightclick = def.on_rightclick, + after_dig_node = def.after_dig_node, + can_dig = def.can_dig, + on_rotate = def.on_rotate, + on_blast = def.on_blast, + on_destruct = def.on_destruct, selection_box = { type = "fixed", - fixed = def.selection_box_top + fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16} + }, + collision_box = { + type = "fixed", + fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16} }, - groups = def.groups, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - pos.y = pos.y-1 - after_dig_node(pos, name.."_b_1", digger) - end, - - on_rightclick = function(pos, node, clicker) - if check_player_priv(pos, clicker) then - on_rightclick(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0}) - end - end, - - on_rotate = function(pos, node, user, mode, new_param2) - return on_rotate(pos, node, -1, user, name.."_b_1", mode) - end, - - can_dig = check_player_priv, - sounds = def.sounds, - sunlight_propagates = def.sunlight, - on_blast = make_on_blast(name, -1, "_t_1", "_b_1") }) - minetest.register_node(name.."_b_2", { - tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]}, - paramtype = "light", - paramtype2 = "facedir", - is_ground_content = false, - drop = name, - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = def.node_box_bottom - }, - selection_box = { - type = "fixed", - fixed = def.selection_box_bottom - }, - groups = def.groups, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - pos.y = pos.y+1 - after_dig_node(pos, name.."_t_2", digger) - end, - - on_rightclick = function(pos, node, clicker) - if check_player_priv(pos, clicker) then - on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2}) - end - end, - - on_rotate = function(pos, node, user, mode, new_param2) - return on_rotate(pos, node, 1, user, name.."_t_2", mode) - end, - - can_dig = check_player_priv, - sounds = def.sounds, - sunlight_propagates = def.sunlight, - on_blast = make_on_blast(name, 1, "_b_2", "_t_2") - }) - - minetest.register_node(name.."_t_2", { - tiles = {tt[2], tt[2], tt[2], tt[2], tt[1].."^[transformfx", tt[1]}, - paramtype = "light", - paramtype2 = "facedir", - is_ground_content = false, - drop = "", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = def.node_box_top - }, - selection_box = { - type = "fixed", - fixed = def.selection_box_top - }, - groups = def.groups, - - after_dig_node = function(pos, oldnode, oldmetadata, digger) - pos.y = pos.y-1 - after_dig_node(pos, name.."_b_2", digger) - end, - - on_rightclick = function(pos, node, clicker) - if check_player_priv(pos, clicker) then - on_rightclick(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2}) - end - end, - - on_rotate = function(pos, node, user, mode, new_param2) - return on_rotate(pos, node, -1, user, name.."_b_2", mode) - end, - - can_dig = check_player_priv, - sounds = def.sounds, - sunlight_propagates = def.sunlight, - on_blast = make_on_blast(name, -1, "_t_2", "_b_2") - }) + if def.recipe then + minetest.register_craft({ + output = name, + recipe = def.recipe, + }) + end + _doors.registered_doors[name .. "_a"] = true + _doors.registered_doors[name .. "_b"] = true end -doors.register_door("doors:door_wood", { - description = "Wooden Door", - inventory_image = "doors_wood.png", - groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1}, - tiles_bottom = {"doors_wood_b.png", "doors_brown.png"}, - tiles_top = {"doors_wood_a.png", "doors_brown.png"}, - sounds = default.node_sound_wood_defaults(), - sunlight = false, +doors.register("door_wood", { + tiles = {{ name = "doors_door_wood.png", backface_culling = true }}, + description = "Wooden Door", + inventory_image = "doors_item_wood.png", + groups = { snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 }, + recipe = { + {"group:wood", "group:wood"}, + {"group:wood", "group:wood"}, + {"group:wood", "group:wood"}, + } }) -minetest.register_craft({ - output = "doors:door_wood", - recipe = { - {"group:wood", "group:wood"}, - {"group:wood", "group:wood"}, - {"group:wood", "group:wood"} - } +doors.register("door_steel", { + tiles = {{ name = "doors_door_steel.png", backface_culling = true }}, + description = "Steel Door", + inventory_image = "doors_item_steel.png", + protected = true, + groups = { snappy = 1, bendy = 2, cracky = 1, melty = 2, level = 2 }, + recipe = { + {"default:steel_ingot", "default:steel_ingot"}, + {"default:steel_ingot", "default:steel_ingot"}, + {"default:steel_ingot", "default:steel_ingot"}, + } }) -doors.register_door("doors:door_steel", { - description = "Steel Door", - inventory_image = "doors_steel.png", - groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, - tiles_bottom = {"doors_steel_b.png", "doors_grey.png"}, - tiles_top = {"doors_steel_a.png", "doors_grey.png"}, - only_placer_can_open = true, - sounds = default.node_sound_wood_defaults(), - sunlight = false, +doors.register("door_glass", { + tiles = { "doors_door_glass.png"}, + description = "Glass Door", + inventory_image = "doors_item_glass.png", + groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 }, + sounds = default.node_sound_glass_defaults(), + recipe = { + {"default:glass", "default:glass"}, + {"default:glass", "default:glass"}, + {"default:glass", "default:glass"}, + } }) -minetest.register_craft({ - output = "doors:door_steel", - recipe = { - {"default:steel_ingot", "default:steel_ingot"}, - {"default:steel_ingot", "default:steel_ingot"}, - {"default:steel_ingot", "default:steel_ingot"} - } +doors.register("door_obsidian_glass", { + tiles = { "doors_door_obsidian_glass.png" }, + description = "Glass Door", + inventory_image = "doors_item_obsidian_glass.png", + groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 }, + sounds = default.node_sound_glass_defaults(), + recipe = { + {"default:obsidian_glass", "default:obsidian_glass"}, + {"default:obsidian_glass", "default:obsidian_glass"}, + {"default:obsidian_glass", "default:obsidian_glass"}, + }, }) -doors.register_door("doors:door_glass", { - description = "Glass Door", - inventory_image = "doors_glass.png", - groups = {snappy=1,cracky=1,oddly_breakable_by_hand=3,door=1}, - tiles_bottom = {"doors_glass_b.png", "doors_glass_side.png"}, - tiles_top = {"doors_glass_a.png", "doors_glass_side.png"}, - sounds = default.node_sound_glass_defaults(), - sunlight = true, -}) +-- Capture mods using the old API as best as possible. +function doors.register_door(name, def) + if def.only_placer_can_open then + def.protected = true + end + def.only_placer_can_open = nil -minetest.register_craft({ - output = "doors:door_glass", - recipe = { - {"default:glass", "default:glass"}, - {"default:glass", "default:glass"}, - {"default:glass", "default:glass"} - } -}) - -doors.register_door("doors:door_obsidian_glass", { - description = "Obsidian Glass Door", - inventory_image = "doors_obsidian_glass.png", - groups = {snappy=1,cracky=1,oddly_breakable_by_hand=3,door=1}, - tiles_bottom = {"doors_obsidian_glass_b.png", "doors_obsidian_glass_side.png"}, - tiles_top = {"doors_obsidian_glass_a.png", "doors_obsidian_glass_side.png"}, - sounds = default.node_sound_glass_defaults(), - sunlight = true, -}) - -minetest.register_craft({ - output = "doors:door_obsidian_glass", - recipe = { - {"default:obsidian_glass", "default:obsidian_glass"}, - {"default:obsidian_glass", "default:obsidian_glass"}, - {"default:obsidian_glass", "default:obsidian_glass"} - } -}) + local i = name:find(":") + local modname = name:sub(1, i - 1) + if not def.tiles then + if def.protected then + def.tiles = {{name = "doors_door_steel.png", backface_culling = true}} + else + def.tiles = {{name = "doors_door_wood.png", backface_culling = true}} + end + minetest.log("warning", modname .. " registered door \"" .. name .. "\" " .. + "using deprecated API method \"doors.register_door()\" but " .. + "did not provide the \"tiles\" parameter. A fallback tiledef " .. + "will be used instead.") + end + doors.register(name, def) +end ----trapdoor---- +function _doors.trapdoor_toggle(pos, clicker) + if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then + local meta = minetest.get_meta(pos) + local owner = meta:get_string("doors_owner") + if owner ~= "" then + if clicker:get_player_name() ~= owner then + return false + end + end + end + + local node = minetest.get_node(pos) + local def = minetest.registered_nodes[node.name] + + if string.sub(node.name, -5) == "_open" then + minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 10}) + minetest.swap_node(pos, {name = string.sub(node.name, 1, string.len(node.name) - 5), param1 = node.param1, param2 = node.param2}) + else + minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 10}) + minetest.swap_node(pos, {name = node.name .. "_open", param1 = node.param1, param2 = node.param2}) + end +end + function doors.register_trapdoor(name, def) local name_closed = name local name_opened = name.."_open" local function check_player_priv(pos, player) - if not def.only_placer_can_open then + if not def.protected or minetest.check_player_privs(player, "protection_bypass") then return true end local meta = minetest.get_meta(pos) @@ -437,18 +533,8 @@ function doors.register_trapdoor(name, def) return meta:get_string("doors_owner") == pn end - def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing) - if not check_player_priv(pos, clicker) then - return - end - local newname = node.name == name_closed and name_opened or name_closed - local sound = false - if node.name == name_closed then sound = def.sound_open end - if node.name == name_opened then sound = def.sound_close end - if sound then - minetest.sound_play(sound, {pos = pos, gain = 0.3, max_hear_distance = 10}) - end - minetest.swap_node(pos, {name = newname, param1 = node.param1, param2 = node.param2}) + def.on_rightclick = function(pos, node, clicker) + _doors.trapdoor_toggle(pos, clicker) end -- Common trapdoor configuration @@ -458,7 +544,7 @@ function doors.register_trapdoor(name, def) def.is_ground_content = false def.can_dig = check_player_priv - if def.only_placer_can_open then + if def.protected then def.after_place_node = function(pos, placer, itemstack, pointed_thing) local pn = placer:get_player_name() local meta = minetest.get_meta(pos) @@ -467,6 +553,26 @@ function doors.register_trapdoor(name, def) return minetest.setting_getbool("creative_mode") end + + def.on_blast = function() end + else + def.on_blast = function(pos, intensity) + minetest.remove_node(pos) + minetest.remove_node({ x = pos.x, y = pos.y + 1, z = pos.z}) + return { name } + end + end + + if not def.sounds then + def.sounds = default.node_sound_wood_defaults() + end + + if not def.sound_open then + def.sound_open = "doors_door_open" + end + + if not def.sound_close then + def.sound_close = "doors_door_close" end local def_opened = table.copy(def) @@ -501,10 +607,11 @@ function doors.register_trapdoor(name, def) minetest.register_node(name_opened, def_opened) minetest.register_node(name_closed, def_closed) + + _doors.registered_trapdoors[name_opened] = true + _doors.registered_trapdoors[name_closed] = true end - - doors.register_trapdoor("doors:trapdoor", { description = "Trapdoor", inventory_image = "doors_trapdoor.png", @@ -512,9 +619,6 @@ doors.register_trapdoor("doors:trapdoor", { tile_front = "doors_trapdoor.png", tile_side = "doors_trapdoor_side.png", groups = {snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=2, door=1}, - sounds = default.node_sound_wood_defaults(), - sound_open = "doors_door_open", - sound_close = "doors_door_close" }) doors.register_trapdoor("doors:trapdoor_steel", { @@ -523,11 +627,8 @@ doors.register_trapdoor("doors:trapdoor_steel", { wield_image = "doors_trapdoor_steel.png", tile_front = "doors_trapdoor_steel.png", tile_side = "doors_trapdoor_steel_side.png", - only_placer_can_open = true, + protected = true, groups = {snappy=1, bendy=2, cracky=1, melty=2, level=2, door=1}, - sounds = default.node_sound_wood_defaults(), - sound_open = "doors_door_open", - sound_close = "doors_door_close" }) minetest.register_craft({ @@ -547,3 +648,62 @@ minetest.register_craft({ } }) + +----fence gate---- + +local fence = { + description = "Fence Gate", + drawtype = "mesh", + tiles = {"default_wood.png"}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + is_ground_content = false, + drop = "doors:gate_closed", + connect_sides = { "left", "right" }, + groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, + flammable = 2, fence = 1}, + on_rightclick = function(pos, clicker) + local node = minetest.get_node(pos) + local def = minetest.registered_nodes[node.name] + minetest.swap_node(pos, {name = def.gate, param2 = node.param2}) + minetest.sound_play(def.sound, {pos = pos, gain = 0.3, + max_hear_distance = 8}) + end, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}, + }, +} + +local fence_closed = table.copy(fence) +fence_closed.mesh = "doors_fencegate_closed.obj" +fence_closed.gate = "doors:gate_open" +fence_closed.sound = "doors_fencegate_open" +fence_closed.collision_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}, +} + +local fence_open = table.copy(fence) +fence_open.mesh = "doors_fencegate_open.obj" +fence_open.gate = "doors:gate_closed" +fence_open.sound = "doors_fencegate_close" +fence_open.groups.not_in_creative_inventory = 1 +fence_open.collision_box = { + type = "fixed", + fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4}, + {-5/8, -3/8, -14/16, -3/8, 3/8, 0}}, +} + +minetest.register_node("doors:gate_closed", fence_closed) +minetest.register_node("doors:gate_open", fence_open) + +minetest.register_craft({ + output = "doors:gate_closed", + recipe = { + {"default:stick", "group:wood", "default:stick"}, + {"default:stick", "group:wood", "default:stick"}, + }, +}) + diff --git a/mods/doors/models/door_a.obj b/mods/doors/models/door_a.obj new file mode 100644 index 00000000..bd5127b5 --- /dev/null +++ b/mods/doors/models/door_a.obj @@ -0,0 +1,40 @@ +# Blender v2.76 (sub 0) OBJ File: 'door_a.blend' +# www.blender.org +mtllib door_a.mtl +o Cube_Cube.001 +v 0.499000 -0.499000 -0.499000 +v 0.499000 1.499000 -0.499000 +v 0.499000 -0.499000 -0.375000 +v 0.499000 1.499000 -0.375000 +v -0.499000 -0.499000 -0.499000 +v -0.499000 1.499000 -0.499000 +v -0.499000 -0.499000 -0.375000 +v -0.499000 1.499000 -0.375000 +vt 0.842105 1.000000 +vt 0.894737 1.000000 +vt 0.894737 0.000000 +vt 0.842105 0.000000 +vt 0.421053 1.000000 +vt 0.421053 0.000000 +vt 0.947368 1.000000 +vt 0.947368 0.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.500000 +vt 0.947368 0.500000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +usemtl None +s off +f 2/1/1 4/2/1 3/3/1 1/4/1 +f 4/5/2 8/1/2 7/4/2 3/6/2 +f 8/2/3 6/7/3 5/8/3 7/3/3 +f 6/9/4 2/5/4 1/6/4 5/10/4 +f 1/11/5 3/12/5 7/7/5 5/13/5 +f 6/14/6 8/8/6 4/12/6 2/11/6 diff --git a/mods/doors/models/door_b.obj b/mods/doors/models/door_b.obj new file mode 100644 index 00000000..c5607b87 --- /dev/null +++ b/mods/doors/models/door_b.obj @@ -0,0 +1,40 @@ +# Blender v2.76 (sub 0) OBJ File: 'door_b.blend' +# www.blender.org +mtllib door_b.mtl +o Cube_Cube.001 +v -0.499000 -0.499000 -0.499000 +v -0.499000 1.499000 -0.499000 +v -0.499000 -0.499000 -0.375000 +v -0.499000 1.499000 -0.375000 +v 0.499000 -0.499000 -0.499000 +v 0.499000 1.499000 -0.499000 +v 0.499000 -0.499000 -0.375000 +v 0.499000 1.499000 -0.375000 +vt 0.842105 1.000000 +vt 0.842105 0.000000 +vt 0.894737 0.000000 +vt 0.894737 1.000000 +vt 0.421053 1.000000 +vt 0.421053 0.000000 +vt 0.947368 0.000000 +vt 0.947368 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 0.500000 +vt 0.947368 0.500000 +vt 1.000000 1.000000 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +usemtl None +s off +f 2/1/1 1/2/1 3/3/1 4/4/1 +f 4/5/2 3/6/2 7/2/2 8/1/2 +f 8/4/3 7/3/3 5/7/3 6/8/3 +f 6/9/4 5/10/4 1/6/4 2/5/4 +f 1/11/5 5/12/5 7/13/5 3/7/5 +f 6/8/6 2/13/6 4/12/6 8/14/6 diff --git a/mods/doors/models/doors_fencegate_closed.obj b/mods/doors/models/doors_fencegate_closed.obj new file mode 100644 index 00000000..60eb4d74 --- /dev/null +++ b/mods/doors/models/doors_fencegate_closed.obj @@ -0,0 +1,106 @@ +# Blender v2.76 (sub 0) OBJ File: 'gate_closed.blend' +# www.blender.org +mtllib gate_closed.mtl +o Cube_Cube.001 +v -0.625000 -0.500000 0.125000 +v -0.625000 0.500000 0.125000 +v -0.625000 -0.500000 -0.125000 +v -0.625000 0.500000 -0.125000 +v -0.375000 -0.500000 0.125000 +v -0.375000 0.500000 0.125000 +v -0.375000 -0.500000 -0.125000 +v -0.375000 0.500000 -0.125000 +v 0.375000 -0.500000 0.125000 +v 0.375000 0.500000 0.125000 +v 0.375000 -0.500000 -0.125000 +v 0.375000 0.500000 -0.125000 +v 0.625000 -0.500000 0.125000 +v 0.625000 0.500000 0.125000 +v 0.625000 -0.500000 -0.125000 +v 0.625000 0.500000 -0.125000 +v -0.375000 0.187500 0.062500 +v -0.375000 0.312500 0.062500 +v -0.375000 0.187500 -0.062500 +v -0.375000 0.312500 -0.062500 +v 0.375000 0.187500 0.062500 +v 0.375000 0.312500 0.062500 +v 0.375000 0.187500 -0.062500 +v 0.375000 0.312500 -0.062500 +v -0.374831 0.187348 0.062500 +v -0.156342 0.187363 0.062500 +v -0.374831 0.187348 -0.062500 +v -0.156342 0.187363 -0.062500 +v 0.374981 -0.343683 0.062500 +v 0.375065 -0.187304 0.062500 +v 0.374981 -0.343683 -0.062500 +v 0.375065 -0.187304 -0.062500 +vt 0.000000 0.750000 +vt 0.000000 0.500000 +vt 1.000000 0.500000 +vt 1.000000 0.750000 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 1.000000 -0.000000 +vt 1.000000 0.250000 +vt 0.000000 0.250000 +vt -0.000000 0.000000 +vt 0.250000 0.000000 +vt 0.250000 0.250000 +vt 0.250000 0.750000 +vt 0.250000 1.000000 +vt 0.500000 -0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 1.000000 0.625000 +vt 0.000000 0.625000 +vt 1.000000 0.875000 +vt 0.000000 0.875000 +vt -0.000000 0.687500 +vt 0.000000 0.562500 +vt 1.000000 0.562500 +vt 1.000000 0.687500 +vt 0.813740 0.249033 +vt 0.201557 0.249293 +vt 0.120995 0.125498 +vt 0.987404 0.125469 +vt 0.125000 0.375000 +vt 0.812500 0.375000 +vt 0.937500 0.500000 +vt 0.062500 0.500000 +vt 0.000000 0.125000 +vt 1.000000 0.125000 +vt 0.312500 0.437500 +vt 0.312500 0.312500 +vt 1.000000 0.312500 +vt 1.000000 0.437500 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn -0.578000 -0.816100 0.000000 +vn 0.576200 0.817300 0.000000 +usemtl None +s off +f 2/1/1 4/2/1 3/3/1 1/4/1 +f 4/4/2 8/5/2 7/6/2 3/1/2 +f 8/7/3 6/8/3 5/9/3 7/10/3 +f 6/2/4 2/9/4 1/8/4 5/3/4 +f 1/9/5 3/10/5 7/11/5 5/12/5 +f 6/6/6 8/1/6 4/13/6 2/14/6 +f 10/1/1 12/2/1 11/3/1 9/4/1 +f 12/2/2 16/9/2 15/8/2 11/3/2 +f 16/7/3 14/8/3 13/9/3 15/10/3 +f 14/4/4 10/5/4 9/6/4 13/1/4 +f 9/12/5 11/11/5 15/15/5 13/16/5 +f 14/14/6 16/13/6 12/17/6 10/18/6 +f 20/2/2 24/3/2 23/19/2 19/20/2 +f 22/1/4 18/4/4 17/21/4 21/22/4 +f 17/23/5 19/24/5 23/25/5 21/26/5 +f 22/21/6 24/5/6 20/6/6 18/22/6 +f 28/27/2 32/28/2 31/29/2 27/30/2 +f 30/31/4 26/32/4 25/33/4 29/34/4 +f 25/35/7 27/10/7 31/7/7 29/36/7 +f 30/37/8 32/38/8 28/39/8 26/40/8 diff --git a/mods/doors/models/doors_fencegate_open.obj b/mods/doors/models/doors_fencegate_open.obj new file mode 100644 index 00000000..6c6a9cf4 --- /dev/null +++ b/mods/doors/models/doors_fencegate_open.obj @@ -0,0 +1,112 @@ +# Blender v2.76 (sub 0) OBJ File: 'gate_open.blend' +# www.blender.org +mtllib gate_open.mtl +o Cube_Cube.001 +v -0.625000 -0.500000 0.125000 +v -0.625000 0.500000 0.125000 +v -0.625000 -0.500000 -0.125000 +v -0.625000 0.500000 -0.125000 +v -0.375000 -0.500000 0.125000 +v -0.375000 0.500000 0.125000 +v -0.375000 -0.500000 -0.125000 +v -0.375000 0.500000 -0.125000 +v 0.375000 -0.500000 0.125000 +v 0.375000 0.500000 0.125000 +v 0.375000 -0.500000 -0.125000 +v 0.375000 0.500000 -0.125000 +v 0.625000 -0.500000 0.125000 +v 0.625000 0.500000 0.125000 +v 0.625000 -0.500000 -0.125000 +v 0.625000 0.500000 -0.125000 +v 0.434859 0.187500 -0.872359 +v 0.434859 0.312500 -0.872359 +v 0.559859 0.187500 -0.872359 +v 0.559859 0.312500 -0.872359 +v 0.434859 0.187500 -0.122359 +v 0.434859 0.312500 -0.122359 +v 0.559859 0.187500 -0.122359 +v 0.559859 0.312500 -0.122359 +v 0.434859 0.187348 -0.872190 +v 0.434859 0.187363 -0.653701 +v 0.559859 0.187348 -0.872190 +v 0.559859 0.187363 -0.653701 +v 0.434859 -0.343683 -0.122379 +v 0.434859 -0.187304 -0.122294 +v 0.559859 -0.343683 -0.122379 +v 0.559859 -0.187304 -0.122294 +v 0.499560 -0.442900 0.005495 +vt 0.000000 0.750000 +vt 0.000000 0.500000 +vt 1.000000 0.500000 +vt 1.000000 0.750000 +vt 1.000000 1.000000 +vt -0.000000 1.000000 +vt 1.000000 -0.000000 +vt 1.000000 0.250000 +vt 0.000000 0.250000 +vt -0.000000 0.000000 +vt 0.250000 0.000000 +vt 0.250000 0.250000 +vt 0.250000 0.750000 +vt 0.250000 1.000000 +vt 0.500000 -0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 1.000000 0.625000 +vt 0.000000 0.625000 +vt 1.000000 0.875000 +vt 0.000000 0.875000 +vt -0.000000 0.687500 +vt 0.000000 0.562500 +vt 1.000000 0.562500 +vt 1.000000 0.687500 +vt 0.813740 0.249033 +vt 0.201557 0.249293 +vt 0.120995 0.125498 +vt 0.987404 0.125469 +vt 0.125000 0.375000 +vt 0.812500 0.375000 +vt 0.937500 0.500000 +vt 0.062500 0.500000 +vt 0.000000 0.125000 +vt 1.000000 0.125000 +vt 0.312500 0.437500 +vt 0.312500 0.312500 +vt 1.000000 0.312500 +vt 1.000000 0.437500 +vt 0.312500 0.625000 +vt 0.312500 0.500000 +vt 0.187500 0.500000 +vt 0.187500 0.625000 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 -0.816100 -0.578000 +vn 0.000000 0.817300 0.576200 +usemtl None +s off +f 2/1/1 4/2/1 3/3/1 1/4/1 +f 4/4/2 8/5/2 7/6/2 3/1/2 +f 8/7/3 6/8/3 5/9/3 7/10/3 +f 6/2/4 2/9/4 1/8/4 5/3/4 +f 1/9/5 3/10/5 7/11/5 5/12/5 +f 6/6/6 8/1/6 4/13/6 2/14/6 +f 10/1/1 12/2/1 11/3/1 9/4/1 +f 12/2/2 16/9/2 15/8/2 11/3/2 +f 16/7/3 14/8/3 13/9/3 15/10/3 +f 14/4/4 10/5/4 9/6/4 13/1/4 +f 9/12/5 11/11/5 15/15/5 13/16/5 +f 14/14/6 16/13/6 12/17/6 10/18/6 +f 20/2/3 24/3/3 23/19/3 19/20/3 +f 22/1/1 18/4/1 17/21/1 21/22/1 +f 17/23/5 19/24/5 23/25/5 21/26/5 +f 22/21/6 24/5/6 20/6/6 18/22/6 +f 28/27/3 32/28/3 31/29/3 27/30/3 +f 30/31/1 26/32/1 25/33/1 29/34/1 +f 25/35/7 27/10/7 31/7/7 29/36/7 +f 30/37/8 32/38/8 28/39/8 26/40/8 +f 17/41/2 18/42/2 20/43/2 19/44/2 diff --git a/mods/doors/sounds/doors_fencegate_close.ogg b/mods/doors/sounds/doors_fencegate_close.ogg new file mode 100644 index 00000000..d42590ff Binary files /dev/null and b/mods/doors/sounds/doors_fencegate_close.ogg differ diff --git a/mods/doors/sounds/doors_fencegate_open.ogg b/mods/doors/sounds/doors_fencegate_open.ogg new file mode 100644 index 00000000..f6dfd1d9 Binary files /dev/null and b/mods/doors/sounds/doors_fencegate_open.ogg differ diff --git a/mods/doors/textures/doors_brown.png b/mods/doors/textures/doors_brown.png deleted file mode 100644 index 8c8e3d89..00000000 Binary files a/mods/doors/textures/doors_brown.png and /dev/null differ diff --git a/mods/doors/textures/doors_door_glass.png b/mods/doors/textures/doors_door_glass.png new file mode 100644 index 00000000..f597299b Binary files /dev/null and b/mods/doors/textures/doors_door_glass.png differ diff --git a/mods/doors/textures/doors_door_obsidian_glass.png b/mods/doors/textures/doors_door_obsidian_glass.png new file mode 100644 index 00000000..107a5a1a Binary files /dev/null and b/mods/doors/textures/doors_door_obsidian_glass.png differ diff --git a/mods/doors/textures/doors_door_steel.png b/mods/doors/textures/doors_door_steel.png new file mode 100644 index 00000000..f42f3350 Binary files /dev/null and b/mods/doors/textures/doors_door_steel.png differ diff --git a/mods/doors/textures/doors_door_wood.png b/mods/doors/textures/doors_door_wood.png new file mode 100644 index 00000000..7b18203e Binary files /dev/null and b/mods/doors/textures/doors_door_wood.png differ diff --git a/mods/doors/textures/doors_glass_a.png b/mods/doors/textures/doors_glass_a.png deleted file mode 100644 index da254028..00000000 Binary files a/mods/doors/textures/doors_glass_a.png and /dev/null differ diff --git a/mods/doors/textures/doors_glass_b.png b/mods/doors/textures/doors_glass_b.png deleted file mode 100644 index da254028..00000000 Binary files a/mods/doors/textures/doors_glass_b.png and /dev/null differ diff --git a/mods/doors/textures/doors_glass_side.png b/mods/doors/textures/doors_glass_side.png deleted file mode 100644 index 755672bd..00000000 Binary files a/mods/doors/textures/doors_glass_side.png and /dev/null differ diff --git a/mods/doors/textures/doors_grey.png b/mods/doors/textures/doors_grey.png deleted file mode 100644 index ad110c7d..00000000 Binary files a/mods/doors/textures/doors_grey.png and /dev/null differ diff --git a/mods/doors/textures/doors_glass.png b/mods/doors/textures/doors_item_glass.png similarity index 100% rename from mods/doors/textures/doors_glass.png rename to mods/doors/textures/doors_item_glass.png diff --git a/mods/doors/textures/doors_obsidian_glass.png b/mods/doors/textures/doors_item_obsidian_glass.png similarity index 100% rename from mods/doors/textures/doors_obsidian_glass.png rename to mods/doors/textures/doors_item_obsidian_glass.png diff --git a/mods/doors/textures/doors_item_steel.png b/mods/doors/textures/doors_item_steel.png new file mode 100644 index 00000000..dd99e136 Binary files /dev/null and b/mods/doors/textures/doors_item_steel.png differ diff --git a/mods/doors/textures/doors_wood.png b/mods/doors/textures/doors_item_wood.png similarity index 100% rename from mods/doors/textures/doors_wood.png rename to mods/doors/textures/doors_item_wood.png diff --git a/mods/doors/textures/doors_obsidian_glass_a.png b/mods/doors/textures/doors_obsidian_glass_a.png deleted file mode 100644 index d5ac83d0..00000000 Binary files a/mods/doors/textures/doors_obsidian_glass_a.png and /dev/null differ diff --git a/mods/doors/textures/doors_obsidian_glass_b.png b/mods/doors/textures/doors_obsidian_glass_b.png deleted file mode 100644 index d5ac83d0..00000000 Binary files a/mods/doors/textures/doors_obsidian_glass_b.png and /dev/null differ diff --git a/mods/doors/textures/doors_obsidian_glass_side.png b/mods/doors/textures/doors_obsidian_glass_side.png deleted file mode 100644 index aa4c63aa..00000000 Binary files a/mods/doors/textures/doors_obsidian_glass_side.png and /dev/null differ diff --git a/mods/doors/textures/doors_steel.png b/mods/doors/textures/doors_steel.png deleted file mode 100644 index 042a1bc0..00000000 Binary files a/mods/doors/textures/doors_steel.png and /dev/null differ diff --git a/mods/doors/textures/doors_steel_a.png b/mods/doors/textures/doors_steel_a.png deleted file mode 100644 index 84ff11d8..00000000 Binary files a/mods/doors/textures/doors_steel_a.png and /dev/null differ diff --git a/mods/doors/textures/doors_steel_b.png b/mods/doors/textures/doors_steel_b.png deleted file mode 100644 index 77ffbe3a..00000000 Binary files a/mods/doors/textures/doors_steel_b.png and /dev/null differ diff --git a/mods/doors/textures/doors_wood_a.png b/mods/doors/textures/doors_wood_a.png deleted file mode 100644 index 86a747aa..00000000 Binary files a/mods/doors/textures/doors_wood_a.png and /dev/null differ diff --git a/mods/doors/textures/doors_wood_b.png b/mods/doors/textures/doors_wood_b.png deleted file mode 100644 index 96650982..00000000 Binary files a/mods/doors/textures/doors_wood_b.png and /dev/null differ diff --git a/mods/dye/init.lua b/mods/dye/init.lua index d7d18f7a..d414d77c 100644 --- a/mods/dye/init.lua +++ b/mods/dye/init.lua @@ -1,39 +1,58 @@ --- minetest/dye/init.lua - -- Other mods can use these for looping through available colors + dye = {} dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} -dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"} +dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", + "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"} --- Local stuff -local dyelocal = {} +-- Make dye names and descriptions available globally --- This collection of colors is partly a historic thing, partly something else. -dyelocal.dyes = { - {"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}}, - {"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}}, - {"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}}, - {"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}}, - {"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}}, - {"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}}, - {"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}}, - {"dark_green", "Dark green dye",{dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}}, - {"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}}, - {"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}}, - {"brown", "Brown dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}}, - {"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}}, - {"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}}, - {"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}}, - {"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}}, +dye.dyes = { + {"white", "White"}, + {"grey", "Grey"}, + {"dark_grey", "Dark grey"}, + {"black", "Black"}, + {"violet", "Violet"}, + {"blue", "Blue"}, + {"cyan", "Cyan"}, + {"dark_green", "Dark green"}, + {"green", "Green"}, + {"yellow", "Yellow"}, + {"brown", "Brown"}, + {"orange", "Orange"}, + {"red", "Red"}, + {"magenta", "Magenta"}, + {"pink", "Pink"}, +} + +-- This collection of colors is partly a historic thing, partly something else + +local dyes = { + {"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}}, + {"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}}, + {"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}}, + {"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}}, + {"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}}, + {"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}}, + {"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}}, + {"dark_green", "Dark green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}}, + {"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}}, + {"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}}, + {"brown", "Brown dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}}, + {"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}}, + {"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}}, + {"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1, unicolor_red_violet=1}}, + {"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}}, } -- Define items -for _, row in ipairs(dyelocal.dyes) do + +for _, row in ipairs(dyes) do local name = row[1] local description = row[2] local groups = row[3] - local item_name = "dye:"..name - local item_image = "dye_"..name..".png" + local item_name = "dye:" .. name + local item_image = "dye_" .. name .. ".png" minetest.register_craftitem(item_name, { inventory_image = item_image, description = description, @@ -41,11 +60,13 @@ for _, row in ipairs(dyelocal.dyes) do }) minetest.register_craft({ type = "shapeless", - output = item_name.." 4", - recipe = {"group:flower,color_"..name}, + output = item_name .. " 4", + recipe = {"group:flower,color_" .. name}, }) end --- manually add coal->black dye + +-- Manually add coal->black dye + minetest.register_craft({ type = "shapeless", output = "dye:black 4", @@ -55,33 +76,34 @@ minetest.register_craft({ -- Mix recipes -- Just mix everything to everything somehow sanely -dyelocal.mixbases = {"magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"} +local mixbases = {"pink", "magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"} -dyelocal.mixes = { - -- magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white - white = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet", "grey", "grey", "white", "white"}, - grey = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "pink", "dark_grey","grey", "grey"}, - dark_grey={"brown","brown", "brown", "brown", "brown","dark_green","dark_green","blue","blue","violet","black", "black"}, - black = {"black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black"}, - violet= {"magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"}, - blue = {"violet", "magenta","brown","brown","dark_green","cyan","cyan", "cyan", "blue"}, - cyan = {"blue","brown","dark_green","dark_grey","green","cyan","dark_green","cyan"}, - dark_green={"brown","brown","brown", "brown", "green", "green", "dark_green"}, - green = {"brown", "yellow","yellow","dark_green","green","green"}, - yellow= {"red", "orange", "yellow","orange", "yellow"}, - brown = {"brown", "brown","orange", "brown"}, - orange= {"red", "orange","orange"}, - red = {"magenta","red"}, - magenta={"magenta"}, +local mixes = { + -- pink, magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white + white = {"pink", "pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet","grey", "grey", "grey","white"}, + grey = {"pink", "pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet","dark_grey","grey", "grey"}, + dark_grey = {"brown", "brown", "brown", "brown", "brown", "brown", "dark_green","dark_green","blue", "blue", "violet","black", "dark_grey"}, + black = {"black", "black", "black", "black", "black", "black", "black", "black", "black","black", "black", "black"}, + violet = {"magenta","magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"}, + blue = {"violet", "violet", "magenta","brown", "brown", "dark_green","cyan", "cyan", "cyan", "blue"}, + cyan = {"brown", "blue", "brown", "dark_green","dark_grey", "green", "cyan", "dark_green","cyan"}, + dark_green = {"brown", "brown", "brown", "brown", "brown", "green", "green", "dark_green"}, + green = {"yellow", "brown", "yellow", "yellow", "dark_green","green", "green"}, + yellow = {"orange", "red", "orange", "yellow", "orange", "yellow"}, + brown = {"brown", "brown", "brown", "orange", "brown"}, + orange = {"orange", "red", "orange", "orange"}, + red = {"pink", "magenta","red"}, + magenta = {"magenta","magenta"}, + pink = {"pink"}, } -for one,results in pairs(dyelocal.mixes) do - for i,result in ipairs(results) do - local another = dyelocal.mixbases[i] +for one, results in pairs(mixes) do + for i, result in ipairs(results) do + local another = mixbases[i] minetest.register_craft({ type = "shapeless", - output = 'dye:'..result..' 2', - recipe = {'dye:'..one, 'dye:'..another}, + output = 'dye:' .. result .. ' 2', + recipe = {'dye:' .. one, 'dye:' .. another}, }) end end diff --git a/mods/farming/api.lua b/mods/farming/api.lua index 7123cbc1..a0c1992f 100644 --- a/mods/farming/api.lua +++ b/mods/farming/api.lua @@ -264,8 +264,8 @@ farming.register_plant = function(name, def) minetest.register_abm({ nodenames = {"group:" .. pname, "group:seed"}, neighbors = {"group:soil"}, - interval = 90, - chance = 2, + interval = 9, + chance = 20, action = function(pos, node) local plant_height = minetest.get_item_group(node.name, pname) diff --git a/mods/fire/init.lua b/mods/fire/init.lua index fc55b8dd..28f68e98 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -170,7 +170,7 @@ minetest.register_abm({ nodenames = {"fire:basic_flame", "fire:permanent_flame"}, neighbors = {"group:puts_out_fire"}, interval = 3, - chance = 2, + chance = 1, catch_up = false, action = function(p0, node, _, _) minetest.remove_node(p0) @@ -189,7 +189,7 @@ if minetest.setting_getbool("disable_fire") then minetest.register_abm({ nodenames = {"fire:basic_flame"}, interval = 7, - chance = 2, + chance = 1, catch_up = false, action = function(p0, node, _, _) minetest.remove_node(p0) @@ -235,8 +235,14 @@ else -- remove flammable nodes around flame local p = minetest.find_node_near(p0, 1, {"group:flammable"}) if p then - minetest.remove_node(p) - nodeupdate(p) + local node = minetest.get_node(p) + local def = minetest.registered_nodes[node.name] + if def.on_burn then + def.on_burn(p) + else + minetest.remove_node(p) + nodeupdate(p) + end end end end, diff --git a/mods/flowers/init.lua b/mods/flowers/init.lua index dd8e031d..dd90f4c9 100644 --- a/mods/flowers/init.lua +++ b/mods/flowers/init.lua @@ -76,8 +76,8 @@ end minetest.register_abm({ nodenames = {"group:flora"}, neighbors = {"default:dirt_with_grass", "default:desert_sand"}, - interval = 50, - chance = 25, + interval = 13, + chance = 96, action = function(pos, node) pos.y = pos.y - 1 local under = minetest.get_node(pos) diff --git a/mods/screwdriver/init.lua b/mods/screwdriver/init.lua index 34b4b4a8..6b82d042 100644 --- a/mods/screwdriver/init.lua +++ b/mods/screwdriver/init.lua @@ -36,7 +36,7 @@ local function screwdriver_handler(itemstack, user, pointed_thing, mode) local node = minetest.get_node(pos) local ndef = minetest.registered_nodes[node.name] -- verify node is facedir (expected to be rotatable) - if ndef.paramtype2 ~= "facedir" then + if not ndef or ndef.paramtype2 ~= "facedir" then return end -- Compute param2 diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua index ea2933b6..7688d905 100644 --- a/mods/stairs/init.lua +++ b/mods/stairs/init.lua @@ -233,7 +233,7 @@ end if replace then minetest.register_abm({ nodenames = {"group:slabs_replace"}, - interval = 8, + interval = 16, chance = 1, action = function(pos, node) node.name = minetest.registered_nodes[node.name].replace_name diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index cf2305ee..d7ff4122 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -235,11 +235,16 @@ minetest.register_node("tnt:tnt", { sounds = default.node_sound_wood_defaults(), on_punch = function(pos, node, puncher) if puncher:get_wielded_item():get_name() == "default:torch" then +<<<<<<< HEAD if(minetest.check_player_privs(puncher:get_player_name(), {trusted_player=true})) then minetest.sound_play("tnt_ignite", {pos=pos}) minetest.set_node(pos, {name="tnt:tnt_burning"}) minetest.get_node_timer(pos):start(4) end +======= + minetest.sound_play("tnt_ignite", {pos=pos}) + minetest.set_node(pos, {name="tnt:tnt_burning"}) +>>>>>>> dfee51c21e1131c9c80fc7382b000954962f8b49 end end, on_blast = function(pos, intensity) @@ -263,6 +268,9 @@ minetest.register_node("tnt:tnt_burning", { light_source = 5, drop = "", sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + minetest.get_node_timer(pos):start(4) + end, on_timer = boom, -- unaffected by explosions on_blast = function() end, @@ -383,7 +391,7 @@ minetest.register_node("tnt:gunpowder_burning", { minetest.register_abm({ nodenames = {"tnt:tnt", "tnt:gunpowder"}, neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"}, - interval = 1, + interval = 4, chance = 1, action = burn, }) @@ -402,8 +410,3 @@ minetest.register_craft({ {"", "group:wood", ""} } }) - -if minetest.setting_get("log_mods") then - minetest.debug("[TNT] Loaded!") -end - diff --git a/mods/walls/depends.txt b/mods/walls/depends.txt new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/mods/walls/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/walls/init.lua b/mods/walls/init.lua new file mode 100644 index 00000000..e3c1d68f --- /dev/null +++ b/mods/walls/init.lua @@ -0,0 +1,61 @@ + +--[[ + +Walls mod for Minetest + +Copyright (C) 2015 Auke Kok + +This program is free software. It comes without any warranty, to +the extent permitted by applicable law. You can redistribute it +and/or modify it under the terms of the Do What The Fuck You Want +To Public License, Version 2, as published by Sam Hocevar. See +http://sam.zoy.org/wtfpl/COPYING for more details. + +--]] + +walls = {} + +walls.register = function(wall_name, wall_desc, wall_texture, wall_mat, wall_sounds) + -- inventory node, and pole-type wall start item + minetest.register_node(wall_name, { + description = wall_desc, + drawtype = "nodebox", + node_box = { + type = "connected", + fixed = {{-1/4, -1/2, -1/4, 1/4, 1/2, 1/4}}, + -- connect_bottom = + connect_front = {{-3/16, -1/2, -1/2, 3/16, 3/8, -1/4}}, + connect_left = {{-1/2, -1/2, -3/16, -1/4, 3/8, 3/16}}, + connect_back = {{-3/16, -1/2, 1/4, 3/16, 3/8, 1/2}}, + connect_right = {{ 1/4, -1/2, -3/16, 1/2, 3/8, 3/16}}, + }, + connects_to = { "group:cracky", "group:wall", "group:stone" }, + paramtype = "light", + is_ground_content = false, + tiles = { wall_texture, }, + walkable = true, + groups = { cracky = 3, wall = 1, stone = 2 }, + sounds = wall_sounds, + }) + + -- crafting recipe + minetest.register_craft({ + output = wall_name .. " 6", + recipe = { + { '', '', '' }, + { wall_mat, wall_mat, wall_mat}, + { wall_mat, wall_mat, wall_mat}, + } + }) + +end + +walls.register("walls:cobble", "Cobblestone Wall", "default_cobble.png", + "default:cobble", default.node_sound_stone_defaults()) + +walls.register("walls:mossycobble", "Mossy Cobblestone Wall", "default_mossycobble.png", + "default:mossycobble", default.node_sound_stone_defaults()) + +walls.register("walls:desertcobble", "Desert Cobblestone Wall", "default_desert_cobble.png", + "default:desert_cobble", default.node_sound_stone_defaults()) + diff --git a/mods/xpanes/init.lua b/mods/xpanes/init.lua index ebd1566f..9189912e 100644 --- a/mods/xpanes/init.lua +++ b/mods/xpanes/init.lua @@ -173,7 +173,7 @@ xpanes.register_pane("bar", { textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"}, inventory_image = "xpanes_bar.png", wield_image = "xpanes_bar.png", - groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1}, + groups = {cracky=2, pane=1}, sounds = default.node_sound_stone_defaults(), recipe = { {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},