From fecc16731f60ffc014ed7a66bd73cf4f99af9435 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Sun, 8 Dec 2024 00:58:04 +0300 Subject: [PATCH] examples --- .gitignore | 3 ++ examples/01_list_all_tools.py | 12 +++++ examples/02_player_locator.py | 2 +- examples/Chatbot.py | 8 ---- examples/mineclonia/01_build_tree.py | 44 +++++++++++++++++++ .../{donut.py => minetest_game/01_donut.py} | 0 examples/spawn_a_house.py | 4 -- 7 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 examples/01_list_all_tools.py delete mode 100644 examples/Chatbot.py create mode 100644 examples/mineclonia/01_build_tree.py rename examples/{donut.py => minetest_game/01_donut.py} (100%) delete mode 100644 examples/spawn_a_house.py diff --git a/.gitignore b/.gitignore index cbf968d..5b150fc 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,6 @@ __pycache__/ # miney tmp Minetest + +samples/ +samples/** \ No newline at end of file diff --git a/examples/01_list_all_tools.py b/examples/01_list_all_tools.py new file mode 100644 index 0000000..99123de --- /dev/null +++ b/examples/01_list_all_tools.py @@ -0,0 +1,12 @@ +from miney.minetest import Minetest + + +mt = Minetest(server='bvn13.me', port=29999, playername='bvn13') + +print("Connected to", mt) + +for tool_type in mt.tool: + print(tool_type) + +for type in mt.node.type: + print(type) \ No newline at end of file diff --git a/examples/02_player_locator.py b/examples/02_player_locator.py index 862068f..4fea1b2 100644 --- a/examples/02_player_locator.py +++ b/examples/02_player_locator.py @@ -1,7 +1,7 @@ from miney.minetest import Minetest -mt = Minetest(server='127.0.0.1', port=29999, playername='bvn13') +mt = Minetest(server='bvn13.me', port=29999, playername='bvn13') print("Connected to", mt) diff --git a/examples/Chatbot.py b/examples/Chatbot.py deleted file mode 100644 index de4b3b7..0000000 --- a/examples/Chatbot.py +++ /dev/null @@ -1,8 +0,0 @@ -""" -This example shows a simple chatbot, that listens on commands but also on any messages. - -""" -from miney import Minetest - -mt = Minetest() - diff --git a/examples/mineclonia/01_build_tree.py b/examples/mineclonia/01_build_tree.py new file mode 100644 index 0000000..cfa5889 --- /dev/null +++ b/examples/mineclonia/01_build_tree.py @@ -0,0 +1,44 @@ +from miney.minetest import Minetest + + +def build_it(mt, px, py, pz, name): + mt.node.set(nodes={ + "x": px, + "y": py, + "z": pz + }, name=name) + + +def build_tree(mt, px, py, pz): + print("Building tree") + for i in range(0, 10): + build_it(mt, px, py + i, pz, "mcl_trees:stripped_oak") + print("Trunk is done") + print("Building leaves") + for i in range(3, 11): + print(f"Building leaves at {i}") + volume = 12 - i + for x in range(int(-volume / 2 - 1), int(volume / 2 + 1)): + for z in range(int(-volume / 2 - 1), int(volume / 2 + 1)): + if not (x == 0 and z == 0): + build_it(mt, px + x, py + i, pz + z, "mcl_trees:leaves_dark_oak") + print("Leaves are done") + + +def main(): + mt = Minetest(server='bvn13.me', port=29999, playername='bvn13') + print("Connected to", mt) + players = mt.player + if len(players): + for player in players: + if player.name == 'bvn13': + pp = player.position + px = pp["x"] + py = pp["y"] + pz = pp["z"] + build_tree(mt, px + 1, py, pz + 1) + else: + raise Exception("There is no player with name bvn13 on server") + + +main() diff --git a/examples/donut.py b/examples/minetest_game/01_donut.py similarity index 100% rename from examples/donut.py rename to examples/minetest_game/01_donut.py diff --git a/examples/spawn_a_house.py b/examples/spawn_a_house.py deleted file mode 100644 index da628b6..0000000 --- a/examples/spawn_a_house.py +++ /dev/null @@ -1,4 +0,0 @@ -import miney - -mt = miney.Minetest -