Compare commits

4 Commits

Author SHA1 Message Date
b565ca2c40 update for new functions 2025-06-14 15:55:11 +10:00
10c67ce6af add reference to engine documentation
fixes #2
2025-05-22 18:37:47 +10:00
730f88ff07 allow empty stacks in inventory set_stack
fixes #4
2025-05-22 18:23:34 +10:00
26580085f3 fix copy-paste mistakes in docs 2024-10-30 02:03:59 +11:00
3 changed files with 26 additions and 8 deletions

8
API.md
View File

@ -1,5 +1,7 @@
# API Documentation
This documentation covers the API specific to `fakelib`. For documentation of the functionality provided by the fake player, metatdata and inventory, refer to the [Lua API](https://github.com/minetest/minetest/blob/master/doc/lua_api.md), as they function the same as the real thing.
## Quick Links
- [`fakelib.is_player(x)`](#fakelibis_playerx)
@ -59,7 +61,7 @@ Creates a new fake player.
#### **`fakelib.create_inventory([sizes])`**
Creates a new fake player.
Creates a new fake inventory.
**Arguments**
@ -67,7 +69,7 @@ Creates a new fake player.
#### **`fakelib.create_metadata([data])`**
Creates a new fake player.
Creates a new fake metadata object.
**Arguments**
@ -134,4 +136,4 @@ local data = {
energy = 300,
}
local meta = fakelib.create_metadata(data)
```
```

View File

@ -139,7 +139,7 @@ function fake_inventory:set_stack(listname, i, stack)
stack = ItemStack(stack)
i = math.floor(i)
local list = self.lists[tostring(listname)]
if not list or not list[i] or stack:is_empty() then
if not list or not list[i] then
return false
end
list[i] = stack

View File

@ -141,6 +141,8 @@ function fake_player:get_player_control()
end
controls.LMB = controls.dig
controls.RMB = controls.place
controls.movement_x = 0
controls.movement_y = 0
return controls
end
@ -236,6 +238,10 @@ function fake_player.get_breath()
return 10
end
function fake_player.get_camera()
return {mode = "any"}
end
function fake_player.get_children()
return {}
end
@ -255,6 +261,14 @@ function fake_player.get_eye_offset()
return vector.zero(), vector.zero(), vector.zero()
end
function fake_player.get_flags()
return {
breathing = true,
drowning = true,
node_damage = true,
}
end
function fake_player.get_formspec_prepend()
return ""
end
@ -457,15 +471,17 @@ do
"settexturemod", "setvelocity", "setyaw",
-- Non-functional get/set functions
"add_velocity", "get_attach", "get_attribute", "get_day_night_ratio",
"get_observers", "get_effective_observers",
"hud_add", "hud_change", "hud_get", "hud_remove", "hud_set_flags",
"hud_set_hotbar_image", "hud_set_hotbar_itemcount",
"hud_set_hotbar_selected_image", "override_day_night_ratio",
"set_animation", "set_animation_frame_speed", "set_armor_groups",
"set_attach", "set_attribute", "set_bone_override", "set_bone_position",
"set_breath", "set_clouds", "set_detach", "set_eye_offset",
"set_formspec_prepend", "set_fov", "set_hp", "set_inventory_formspec",
"set_lighting", "set_local_animation", "set_minimap_modes", "set_moon",
"set_nametag_attributes", "set_physics_override",
"set_breath", "set_camera", "set_clouds", "set_detach",
"set_eye_offset", "set_formspec_prepend", "set_flags", "set_fov",
"set_hp", "set_inventory_formspec", "set_lighting",
"set_local_animation", "set_minimap_modes", "set_moon",
"set_nametag_attributes", "set_observers", "set_physics_override",
"set_properties", "set_sky", "set_stars", "set_sun",
-- Other functions that do nothing
"punch", "respawn", "right_click", "send_mapblock",