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 -- 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)
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)
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)
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)
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)
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)
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})))
50 local function preview_minimap()
51 local minimap = core.ui.minimap
54 minimap:set_pos({x=5, y=50, z=5})
55 minimap:toggle_shape()
57 print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
58 " position => " .. dump(minimap:get_pos()) ..
59 " angle => " .. dump(minimap:get_angle()))
62 core.after(2, function()
63 print("[PREVIEW] loaded " .. modname .. " mod")
65 modstorage:set_string("current_mod", modname)
66 print(modstorage:get_string("current_mod"))
68 print("[PREVIEW] Day count: " .. core.get_day_count() ..
69 " time of day " .. core.get_timeofday())
71 print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) ..
72 " max level " .. core.get_node_max_level({x=0, y=20, z=0}))
74 print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10,
75 {"group:tree", "default:dirt", "default:stone"})))
78 core.register_on_dignode(function(pos, node)
79 print("The local player dug a node!")
80 print("pos:" .. dump(pos))
81 print("node:" .. dump(node))
85 core.register_on_punchnode(function(pos, node)
86 print("The local player punched a node!")
87 local itemstack = core.get_wielded_item()
90 print(dump(itemstack:is_empty()))
91 print(dump(itemstack:get_name()))
92 print(dump(itemstack:get_count()))
93 print(dump(itemstack:get_wear()))
94 print(dump(itemstack:get_meta()))
95 print(dump(itemstack:get_metadata()))
96 print(dump(itemstack:is_known()))
97 --print(dump(itemstack:get_definition()))
98 print(dump(itemstack:get_tool_capabilities()))
99 print(dump(itemstack:to_string()))
100 print(dump(itemstack:to_table()))
102 print(dump(itemstack:set_name("default:dirt")))
103 print(dump(itemstack:set_count("95")))
104 print(dump(itemstack:set_wear(934)))
105 print(dump(itemstack:get_meta()))
106 print(dump(itemstack:get_metadata()))
108 print(dump(itemstack:to_table()))
109 print("pos:" .. dump(pos))
110 print("node:" .. dump(node))