]> git.lizzy.rs Git - dragonfireclient.git/blob - clientmods/preview/init.lua
07464e9271f5b282846fa263810c523107e0f3c1
[dragonfireclient.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("colorize_test", {
44         func = function(param)
45                 return true, core.colorize("red", param)
46         end,
47 })
48
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})))
53         end,
54 })
55
56 local function preview_minimap()
57         local minimap = core.ui.minimap
58         minimap:set_mode(4)
59         minimap:show()
60         minimap:set_pos({x=5, y=50, z=5})
61         minimap:toggle_shape()
62
63         print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
64                         " position => " .. dump(minimap:get_pos()) ..
65                         " angle => " .. dump(minimap:get_angle()))
66 end
67
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"))
72         preview_minimap()
73 end)
74
75 core.after(5, function()
76         core.ui.minimap:show()
77
78         print("[PREVIEW] Day count: " .. core.get_day_count() ..
79                 " time of day " .. core.get_timeofday())
80
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}))
83
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"})))
86 end)
87
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))
92         return false
93 end)
94
95 core.register_on_punchnode(function(pos, node)
96         print("The local player punched a node!")
97         local itemstack = core.get_wielded_item()
98         --[[
99         -- getters
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()))
111         -- setters
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()))
117         --]]
118         print(dump(itemstack:to_table()))
119         print("pos:" .. dump(pos))
120         print("node:" .. dump(node))
121         return false
122 end)
123
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()))
128         end
129 })
130
131 core.register_chatcommand("disconnect", {
132         description = "Exit to main menu",
133         func = function(param)
134                 core.disconnect()
135         end,
136 })