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("colorize_test", {
44 func = function(param)
45 return true, core.colorize("red", param)
49 core.register_chatcommand("test_node", {
50 func = function(param)
51 core.display_chat_message(dump(core.get_node({x=0, y=0, z=0})))
52 core.display_chat_message(dump(core.get_node_or_nil({x=0, y=0, z=0})))
56 local function preview_minimap()
57 local minimap = core.ui.minimap
60 minimap:set_pos({x=5, y=50, z=5})
61 minimap:toggle_shape()
63 print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
64 " position => " .. dump(minimap:get_pos()) ..
65 " angle => " .. dump(minimap:get_angle()))
68 core.after(2, function()
69 print("[PREVIEW] loaded " .. modname .. " mod")
70 modstorage:set_string("current_mod", modname)
71 print(modstorage:get_string("current_mod"))
75 core.after(5, function()
76 core.ui.minimap:show()
78 print("[PREVIEW] Day count: " .. core.get_day_count() ..
79 " time of day " .. core.get_timeofday())
81 print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) ..
82 " max level " .. core.get_node_max_level({x=0, y=20, z=0}))
84 print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10,
85 {"group:tree", "default:dirt", "default:stone"})))
88 core.register_on_dignode(function(pos, node)
89 print("The local player dug a node!")
90 print("pos:" .. dump(pos))
91 print("node:" .. dump(node))
95 core.register_on_punchnode(function(pos, node)
96 print("The local player punched a node!")
97 local itemstack = core.get_wielded_item()
100 print(dump(itemstack:is_empty()))
101 print(dump(itemstack:get_name()))
102 print(dump(itemstack:get_count()))
103 print(dump(itemstack:get_wear()))
104 print(dump(itemstack:get_meta()))
105 print(dump(itemstack:get_metadata()
106 print(dump(itemstack:is_known()))
107 --print(dump(itemstack:get_definition()))
108 print(dump(itemstack:get_tool_capabilities()))
109 print(dump(itemstack:to_string()))
110 print(dump(itemstack:to_table()))
112 print(dump(itemstack:set_name("default:dirt")))
113 print(dump(itemstack:set_count("95")))
114 print(dump(itemstack:set_wear(934)))
115 print(dump(itemstack:get_meta()))
116 print(dump(itemstack:get_metadata()))
118 print(dump(itemstack:to_table()))
119 print("pos:" .. dump(pos))
120 print("node:" .. dump(node))
124 -- This is an example function to ensure it's working properly, should be removed before merge
125 core.register_chatcommand("list_players", {
126 func = function(param)
127 core.display_chat_message(dump(core.get_player_names()))
131 core.register_chatcommand("disconnect", {
132 description = "Exit to main menu",
133 func = function(param)