1 local modname = core.get_current_modname() or "??"
2 local modstorage = core.get_mod_storage()
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")
9 core.register_on_connect(function()
10 print("[PREVIEW] Player connection completed")
11 local server_info = core.get_server_info()
12 print("Server version: " .. server_info.protocol_version)
13 print("Server ip: " .. server_info.ip)
14 print("Server address: " .. server_info.address)
15 print("Server port: " .. server_info.port)
18 core.register_on_placenode(function(pointed_thing, node)
19 print("The local player place a node!")
20 print("pointed_thing :" .. dump(pointed_thing))
21 print("node placed :" .. dump(node))
25 core.register_on_item_use(function(itemstack, pointed_thing)
26 print("The local player used an item!")
27 print("pointed_thing :" .. dump(pointed_thing))
28 print("item = " .. itemstack:get_name())
32 -- This is an example function to ensure it's working properly, should be removed before merge
33 core.register_on_receiving_chat_message(function(message)
34 print("[PREVIEW] Received message " .. message)
38 -- This is an example function to ensure it's working properly, should be removed before merge
39 core.register_on_sending_chat_message(function(message)
40 print("[PREVIEW] Sending message " .. message)
44 -- This is an example function to ensure it's working properly, should be removed before merge
45 core.register_on_hp_modification(function(hp)
46 print("[PREVIEW] HP modified " .. hp)
49 -- This is an example function to ensure it's working properly, should be removed before merge
50 core.register_on_damage_taken(function(hp)
51 print("[PREVIEW] Damage taken " .. hp)
54 -- This is an example function to ensure it's working properly, should be removed before merge
55 core.register_globalstep(function(dtime)
56 -- print("[PREVIEW] globalstep " .. dtime)
59 -- This is an example function to ensure it's working properly, should be removed before merge
60 core.register_chatcommand("dump", {
61 func = function(param)
66 core.register_chatcommand("colorize_test", {
67 func = function(param)
68 return true, core.colorize("red", param)
72 core.register_chatcommand("test_node", {
73 func = function(param)
74 core.display_chat_message(dump(core.get_node({x=0, y=0, z=0})))
75 core.display_chat_message(dump(core.get_node_or_nil({x=0, y=0, z=0})))
79 local function preview_minimap()
80 local minimap = core.ui.minimap
82 print("[PREVIEW] Minimap is disabled. Skipping.")
87 minimap:set_pos({x=5, y=50, z=5})
88 minimap:set_shape(math.random(0, 1))
90 print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
91 " position => " .. dump(minimap:get_pos()) ..
92 " angle => " .. dump(minimap:get_angle()))
95 core.after(2, function()
96 print("[PREVIEW] loaded " .. modname .. " mod")
97 modstorage:set_string("current_mod", modname)
98 print(modstorage:get_string("current_mod"))
102 core.after(5, function()
103 if core.ui.minimap then
104 core.ui.minimap:show()
107 print("[PREVIEW] Day count: " .. core.get_day_count() ..
108 " time of day " .. core.get_timeofday())
110 print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) ..
111 " max level " .. core.get_node_max_level({x=0, y=20, z=0}))
113 print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10,
114 {"group:tree", "default:dirt", "default:stone"})))
117 core.register_on_dignode(function(pos, node)
118 print("The local player dug a node!")
119 print("pos:" .. dump(pos))
120 print("node:" .. dump(node))
124 core.register_on_punchnode(function(pos, node)
125 print("The local player punched a node!")
126 local itemstack = core.get_wielded_item()
129 print(dump(itemstack:is_empty()))
130 print(dump(itemstack:get_name()))
131 print(dump(itemstack:get_count()))
132 print(dump(itemstack:get_wear()))
133 print(dump(itemstack:get_meta()))
134 print(dump(itemstack:get_metadata()
135 print(dump(itemstack:is_known()))
136 --print(dump(itemstack:get_definition()))
137 print(dump(itemstack:get_tool_capabilities()))
138 print(dump(itemstack:to_string()))
139 print(dump(itemstack:to_table()))
141 print(dump(itemstack:set_name("default:dirt")))
142 print(dump(itemstack:set_count("95")))
143 print(dump(itemstack:set_wear(934)))
144 print(dump(itemstack:get_meta()))
145 print(dump(itemstack:get_metadata()))
147 print(dump(itemstack:to_table()))
148 print("pos:" .. dump(pos))
149 print("node:" .. dump(node))
153 core.register_chatcommand("privs", {
154 func = function(param)
155 return true, core.privs_to_string(minetest.get_privilege_list())