parent
5edecca440
commit
65c5fd7fbf
|
@ -0,0 +1,215 @@
|
|||
base_game API
|
||||
======================
|
||||
GitHub Repo: https://github.com/SmallJoker/base_game
|
||||
Original file: https://github.com/minetest/minetest_game/blob/master/game_api.txt
|
||||
|
||||
Please note:
|
||||
[XYZ] refers to a section the Minetest API
|
||||
[#ABC] refers to a section in this document
|
||||
^ Explanation for line above
|
||||
|
||||
Bucket API
|
||||
----------
|
||||
The bucket API allows registering new types of buckets for non-default liquids.
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:lava_source", -- Source node name
|
||||
"default:lava_flowing", -- Flowing node name
|
||||
"bucket:bucket_lava", -- Name to be used for bucket
|
||||
"bucket_lava.png", -- Bucket texture (for wielditem and inventory_image)
|
||||
"Lava Bucket" -- Bucket description
|
||||
)
|
||||
|
||||
Doors API
|
||||
---------
|
||||
The doors mod allows modders to register custom doors.
|
||||
|
||||
doors.register_door(name, def)
|
||||
-> name: Description of the door
|
||||
-> def: See [#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 = see [Node boxes] (Optional)
|
||||
node_box_top = see [Node boxes] (Optional)
|
||||
selection_box_bottom = see [Node boxes] (Optional)
|
||||
selection_box_top = 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)
|
||||
}
|
||||
|
||||
Farming API
|
||||
-----------
|
||||
The farming API allows you to easily register plants and hoes.
|
||||
|
||||
farming.hoe_on_use(itemstack, user, pointed_thing, uses) -> itemstack
|
||||
^ Turns nodes with group soil=1 into soil
|
||||
-> itemstack of the tool
|
||||
-> uses: maximal uses of the tool
|
||||
minetest.register_tool("foo:bar", {
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
return farming.hoe_on_use(itemstack, user, pointed_thing, 30)
|
||||
end,
|
||||
})
|
||||
|
||||
farming.register_plant(modname, name, def)
|
||||
-> name: Plant name (strawberry, wheat, ..)
|
||||
-> def: See [#Plant definition]
|
||||
|
||||
#Plant definition
|
||||
-----------------
|
||||
{
|
||||
image_seed = "unknown_item.png",
|
||||
image_plant = "unknown_node.png",
|
||||
^ Use the question mark to insert the grow step there. ("farming_cotton_?.png", "farming_wheat_?.png", ..)
|
||||
steps = 8,
|
||||
^ How many steps the plant has to grow, until it can be harvested
|
||||
interval = 10, -- Interval * 10 = chance
|
||||
}
|
||||
|
||||
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_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
|
||||
|
||||
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()
|
||||
|
||||
Player API
|
||||
----------
|
||||
The player API can register player models and update the player's appearence
|
||||
Those functions are not available when setting "disable_player_model" is set to "true"!
|
||||
|
||||
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.registered_player_models[name]
|
||||
^ Get a model's definition
|
||||
-> see [#Model definition]
|
||||
|
||||
default.player_set_model(player, model_name)
|
||||
^ Change a player's model
|
||||
-> player: PlayerRef
|
||||
-> model_name: model registered with default.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 = { -- Optional, defaults will be used instead
|
||||
-- <anim_name> = { x = <start_frame>, y = <end_frame> },
|
||||
foo = {x = 0, y = 19},
|
||||
bar = {x = 20, y = 39},
|
||||
-- ...
|
||||
},
|
||||
}
|
||||
|
||||
Mobs API
|
||||
----------
|
||||
|
||||
mobs:register_mob(name, def)
|
||||
-> name: Entity name ("mobs:stone_monster", "mobs:sheep", ..)
|
||||
-> def: see [#Mob definition]
|
||||
|
||||
Mob Definition
|
||||
----------------
|
||||
{
|
||||
hp_max = 0, -- Should be higher than zero..
|
||||
physical = true, -- /Does it fall?/
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, -- see [Node boxes]
|
||||
collide_with_objects = true,
|
||||
visual = nil, -- "mesh"
|
||||
visual_size = table, -- {x = 10, y = 10} to start the fun
|
||||
mesh = nil, -- Mesh filename
|
||||
textures = table, -- Textures of the mob
|
||||
makes_footstep_sound = false, -- coming soon
|
||||
view_range = 0, -- Is it blind?
|
||||
walk_velocity = 0, -- Normal walking speed
|
||||
run_velocity = 0, -- Speed while running to a player
|
||||
damage = 0, -- How much a mob hurts the player (type "monster" only)
|
||||
light_damage = 0, -- The env damages the mob
|
||||
water_damage = 0,
|
||||
lava_damage = 0,
|
||||
drops = {
|
||||
{
|
||||
name = "foo:bar",
|
||||
chance = 1,
|
||||
min = 2,
|
||||
max = 6
|
||||
},
|
||||
..
|
||||
},
|
||||
armor = 0, -- Value of armor
|
||||
drawtype = nil, -- "front", "side"
|
||||
on_rightclick = nil, -- [on_rightclick]
|
||||
type = def.type, -- "monster", "animal"
|
||||
attack_type = nil, -- "dogfight" ???
|
||||
sounds = table, -- ??? profit!
|
||||
animation = table, -- Definition of mesh animations
|
||||
follow = nil, -- Follow a wielditem (Optional)
|
||||
jump = true,
|
||||
}
|
|
@ -1,55 +1,6 @@
|
|||
-- Minetest 0.4 mod: player
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
--[[
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
default.player_register_model(name, def)
|
||||
^ Register a new model to be used by players.
|
||||
^ <name> is the model filename such as "character.x", "foo.b3d", etc.
|
||||
^ See Model Definition below for format of <def>.
|
||||
|
||||
default.registered_player_models[name]
|
||||
^ See Model Definition below for format.
|
||||
|
||||
default.player_set_model(player, model_name)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <model_name> is a model registered with player_register_model.
|
||||
|
||||
default.player_set_animation(player, anim_name [, speed])
|
||||
^ <player> is a PlayerRef.
|
||||
^ <anim_name> is the name of the animation.
|
||||
^ <speed> is in frames per second. If nil, default from the model is used
|
||||
|
||||
default.player_set_textures(player, textures)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <textures> is an array of textures
|
||||
^ If <textures> is nil, the default textures from the model def are used
|
||||
|
||||
default.player_get_animation(player)
|
||||
^ <player> is a PlayerRef.
|
||||
^ Returns a table containing fields "model", "textures" and "animation".
|
||||
^ Any of the fields of the returned table may be nil.
|
||||
|
||||
Model Definition
|
||||
----------------
|
||||
|
||||
model_def = {
|
||||
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 = {
|
||||
-- <anim_name> = {x = <start_frame>, y = <end_frame>},
|
||||
foo = {x = 0, y = 19},
|
||||
bar = {x = 20, y = 39},
|
||||
-- ...
|
||||
},
|
||||
}
|
||||
]]
|
||||
|
||||
|
||||
default.registered_player_models = {}
|
||||
|
||||
-- Local for speed.
|
||||
|
|
|
@ -17,15 +17,12 @@ function mobs:register_mob(name, def)
|
|||
light_damage = def.light_damage,
|
||||
water_damage = def.water_damage,
|
||||
lava_damage = def.lava_damage,
|
||||
disable_fall_damage = def.disable_fall_damage,
|
||||
drops = def.drops,
|
||||
armor = def.armor,
|
||||
drawtype = def.drawtype,
|
||||
on_rightclick = def.on_rightclick,
|
||||
type = def.type,
|
||||
attack_type = def.attack_type,
|
||||
arrow = def.arrow,
|
||||
shoot_interval = def.shoot_interval,
|
||||
sounds = def.sounds,
|
||||
animation = def.animation,
|
||||
follow = def.follow,
|
||||
|
|
|
@ -53,14 +53,8 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
|
|||
end,
|
||||
})
|
||||
|
||||
-- for replace ABM
|
||||
minetest.register_node(":stairs:stair_" .. subname.."upside_down", {
|
||||
replace_name = "stairs:stair_" .. subname,
|
||||
groups = {slabs_replace=1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "stairs:stair_" .. subname .. " 4",
|
||||
output = "stairs:stair_" .. subname .. " 8",
|
||||
recipe = {
|
||||
{recipeitem, "", ""},
|
||||
{recipeitem, recipeitem, ""},
|
||||
|
@ -68,9 +62,8 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
|
|||
},
|
||||
})
|
||||
|
||||
-- Flipped recipe for the silly minecrafters
|
||||
minetest.register_craft({
|
||||
output = "stairs:stair_" .. subname .. " 4",
|
||||
output = "stairs:stair_" .. subname .. " 8",
|
||||
recipe = {
|
||||
{"", "", recipeitem},
|
||||
{"", recipeitem, recipeitem},
|
||||
|
@ -175,12 +168,6 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||
end,
|
||||
})
|
||||
|
||||
-- for replace ABM
|
||||
minetest.register_node(":stairs:slab_" .. subname.."upside_down", {
|
||||
replace_name = "stairs:slab_"..subname,
|
||||
groups = {slabs_replace=1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "stairs:slab_" .. subname .. " 6",
|
||||
recipe = {
|
||||
|
@ -189,23 +176,6 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||
})
|
||||
end
|
||||
|
||||
-- Replace old "upside_down" nodes with new param2 versions
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:slabs_replace"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
node.name = minetest.registered_nodes[node.name].replace_name
|
||||
node.param2 = node.param2 + 20
|
||||
if node.param2 == 21 then
|
||||
node.param2 = 23
|
||||
elseif node.param2 == 23 then
|
||||
node.param2 = 21
|
||||
end
|
||||
minetest.set_node(pos, node)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Nodes will be called stairs:{stair,slab}_<subname>
|
||||
function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)
|
||||
stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds)
|
||||
|
|
Loading…
Reference in New Issue