]> git.lizzy.rs Git - minetest.git/blob - clientmods/preview/init.lua
bdda7fe4ebd7a4cc43e79e132f60c488ab300882
[minetest.git] / clientmods / preview / init.lua
1 local modname = core.get_current_modname() or "??"
2 local modstorage = core.get_mod_storage()
3
4 -- This is an example function to ensure it's working properly, should be removed before merge
5 core.register_on_shutdown(function()
6         print("[PREVIEW] shutdown client")
7 end)
8
9 -- This is an example function to ensure it's working properly, should be removed before merge
10 core.register_on_receiving_chat_messages(function(message)
11         print("[PREVIEW] Received message " .. message)
12         return false
13 end)
14
15 -- This is an example function to ensure it's working properly, should be removed before merge
16 core.register_on_sending_chat_messages(function(message)
17         print("[PREVIEW] Sending message " .. message)
18         return false
19 end)
20
21 -- This is an example function to ensure it's working properly, should be removed before merge
22 core.register_on_hp_modification(function(hp)
23         print("[PREVIEW] HP modified " .. hp)
24 end)
25
26 -- This is an example function to ensure it's working properly, should be removed before merge
27 core.register_on_damage_taken(function(hp)
28         print("[PREVIEW] Damage taken " .. hp)
29 end)
30
31 -- This is an example function to ensure it's working properly, should be removed before merge
32 core.register_globalstep(function(dtime)
33         -- print("[PREVIEW] globalstep " .. dtime)
34 end)
35
36 -- This is an example function to ensure it's working properly, should be removed before merge
37 core.register_chatcommand("dump", {
38         func = function(param)
39                 return true, dump(_G)
40         end,
41 })
42
43 core.register_chatcommand("test_node", {
44         func = function(param)
45                 core.display_chat_message(dump(core.get_node({x=0, y=0, z=0})))
46                 core.display_chat_message(dump(core.get_node_or_nil({x=0, y=0, z=0})))
47         end,
48 })
49
50 local function preview_minimap()
51         local minimap = core.ui.minimap
52         minimap:show()
53         minimap:set_mode(4)
54         minimap:set_pos({x=5, y=50, z=5})
55         minimap:toggle_shape()
56
57         print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
58                         " position => " .. dump(minimap:get_pos()) ..
59                         " angle => " .. dump(minimap:get_angle()))
60 end
61
62 core.after(2, function()
63         print("[PREVIEW] loaded " .. modname .. " mod")
64         preview_minimap()
65         modstorage:set_string("current_mod", modname)
66         print(modstorage:get_string("current_mod"))
67 end)
68
69 core.register_on_dignode(function(pos, node)
70         print("The local player dug a node!")
71         print("pos:" .. dump(pos))
72         print("node:" .. dump(node))
73         return false
74 end)
75
76 core.register_on_punchnode(function(pos, node)
77         print("The local player punched a node!")
78         local itemstack = core.get_wielded_item()
79         --[[
80         -- getters
81         print(dump(itemstack:is_empty()))
82         print(dump(itemstack:get_name()))
83         print(dump(itemstack:get_count()))
84         print(dump(itemstack:get_wear()))
85         print(dump(itemstack:get_meta()))
86         print(dump(itemstack:get_metadata()))
87         print(dump(itemstack:is_known()))
88         --print(dump(itemstack:get_definition()))
89         print(dump(itemstack:get_tool_capabilities()))
90         print(dump(itemstack:to_string()))
91         print(dump(itemstack:to_table()))
92         -- setters
93         print(dump(itemstack:set_name("default:dirt")))
94         print(dump(itemstack:set_count("95")))
95         print(dump(itemstack:set_wear(934)))
96         print(dump(itemstack:get_meta()))
97         print(dump(itemstack:get_metadata()))
98         --]]
99         print(dump(itemstack:to_table()))
100         print("pos:" .. dump(pos))
101         print("node:" .. dump(node))
102         return false
103 end)