From 92b45b2a189b703fc7cfc8ddbc09a7ad563a13bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 27 Jan 2017 07:41:10 +0100 Subject: [CSM] implement client side mod loading (#5123) * client side mods are located in clientmods/ * move builtin/preview.lua to clientmods/preview/init.lua as a preview mod * refactor ModConfiguration class to work properly with client and server using child objects * move some Server constructor mod load code to ModConfiguration to reduce code duplication between client and server * remove mods.{cpp,h} unused functions * use UNORDERED_SET instead of std::set in some modspec storages --- clientmods/preview/init.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 clientmods/preview/init.lua (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua new file mode 100644 index 000000000..4c01d665f --- /dev/null +++ b/clientmods/preview/init.lua @@ -0,0 +1,42 @@ +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_shutdown(function() + print("[PREVIEW] shutdown client") +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_receiving_chat_messages(function(message) + print("[PREVIEW] Received message " .. message) + return false +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_sending_chat_messages(function(message) + print("[PREVIEW] Sending message " .. message) + return false +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_hp_modification(function(hp) + print("[PREVIEW] HP modified " .. hp) +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_damage_taken(function(hp) + print("[PREVIEW] Damage taken " .. hp) +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_globalstep(function(dtime) + -- print("[PREVIEW] globalstep " .. dtime) +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_chatcommand("dump", { + func = function(param) + return true, dump(_G) + end, +}) + +core.after(2, function() + print("After 2") +end) -- cgit v1.2.3 From ba66fce8339f818a638f97679bd29da064a8c1c6 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Sat, 28 Jan 2017 18:31:23 +0100 Subject: [CSM] storage + fixes --- clientmods/preview/init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 4c01d665f..f03e8e112 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -1,3 +1,5 @@ +local modname = core.get_current_modname() or "??" + -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_shutdown(function() print("[PREVIEW] shutdown client") @@ -38,5 +40,5 @@ core.register_chatcommand("dump", { }) core.after(2, function() - print("After 2") + print("[PREVIEW] loaded " .. modname .. " mod") end) -- cgit v1.2.3 From 073f5cf03d95ce1cdf04ce8a0adcaf1fc571d95f Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 29 Jan 2017 17:43:44 +0000 Subject: [CSM] Add `on_dignode` callback (#5140) --- clientmods/preview/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index f03e8e112..3085eda24 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -42,3 +42,9 @@ core.register_chatcommand("dump", { core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") end) + +core.register_on_dignode(function(pos, node) + print("pos:" .. dump(pos)) + print("node:" .. dump(node)) + return false +end) \ No newline at end of file -- cgit v1.2.3 From 37df9cb7d764891f29b433e80a0d5663fee1a94f Mon Sep 17 00:00:00 2001 From: red-001 Date: Mon, 30 Jan 2017 19:10:37 +0000 Subject: [CSM] Add `get_node` and `get_node_or_nil` --- clientmods/preview/init.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 3085eda24..91b12d810 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -39,6 +39,14 @@ core.register_chatcommand("dump", { end, }) +core.register_chatcommand("test_node", { + func = function(param) + core.display_chat_message(dump(core.get_node({x=0, y=0, z=0}))) + core.display_chat_message(dump(core.get_node_or_nil({x=0, y=0, z=0}))) + end, +}) + + core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") end) @@ -47,4 +55,4 @@ core.register_on_dignode(function(pos, node) print("pos:" .. dump(pos)) print("node:" .. dump(node)) return false -end) \ No newline at end of file +end) -- cgit v1.2.3 From 0727bb3ddd9c550ff962af4546bac8cc058bce73 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 29 Jan 2017 18:28:38 +0000 Subject: [CSM] Add `on_punchnode` callback --- clientmods/preview/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 91b12d810..db4f28350 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -52,6 +52,14 @@ core.after(2, function() end) core.register_on_dignode(function(pos, node) + print("The local player dug a node!") + print("pos:" .. dump(pos)) + print("node:" .. dump(node)) + return false +end) + +core.register_on_punchnode(function(pos, node) + print("The local player punched a node!") print("pos:" .. dump(pos)) print("node:" .. dump(node)) return false -- cgit v1.2.3 From 88df9fb5b6c78df9485e8bf3750e2608bd78e14c Mon Sep 17 00:00:00 2001 From: red-001 Date: Tue, 31 Jan 2017 13:18:52 +0000 Subject: Add `get_wielded_item` --- clientmods/preview/init.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index db4f28350..2ca4594d3 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -60,6 +60,28 @@ end) core.register_on_punchnode(function(pos, node) print("The local player punched a node!") + local itemstack = core.get_wielded_item() + --[[ + -- getters + print(dump(itemstack:is_empty())) + print(dump(itemstack:get_name())) + print(dump(itemstack:get_count())) + print(dump(itemstack:get_wear())) + print(dump(itemstack:get_meta())) + print(dump(itemstack:get_metadata())) + print(dump(itemstack:is_known())) + --print(dump(itemstack:get_definition())) + print(dump(itemstack:get_tool_capabilities())) + print(dump(itemstack:to_string())) + print(dump(itemstack:to_table())) + -- setters + print(dump(itemstack:set_name("default:dirt"))) + print(dump(itemstack:set_count("95"))) + print(dump(itemstack:set_wear(934))) + print(dump(itemstack:get_meta())) + print(dump(itemstack:get_metadata())) + --]] + print(dump(itemstack:to_table())) print("pos:" .. dump(pos)) print("node:" .. dump(node)) return false -- cgit v1.2.3 From eb88e5dd4b181a90b382c036cf6c4f42e63e8cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Thu, 16 Mar 2017 07:53:39 +0100 Subject: Add ModStorageAPI to client side modding (#5396) mod storage is located into user_path / client / mod_storage --- clientmods/preview/init.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 2ca4594d3..60dccf304 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -1,4 +1,5 @@ local modname = core.get_current_modname() or "??" +local modstorage = core.get_mod_storage() -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_shutdown(function() @@ -49,6 +50,8 @@ core.register_chatcommand("test_node", { core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") + modstorage:set_string("current_mod", modname) + print(modstorage:get_string("current_mod")) end) core.register_on_dignode(function(pos, node) -- cgit v1.2.3 From 40ce538aad9af8f7634c4ba7e9f12246fb23b31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Thu, 16 Mar 2017 10:34:54 +0100 Subject: [CSM] Add minimap API modifiers (#5399) * Rename Mapper (too generic) to Minimap * Add lua functions to get/set position, angle, mode for minimap * Client: rename m_mapper to m_minimap * Add minimap to core.ui namespace (core.ui.minimap) * Add various functions to manage minimap (show, hide, toggle_shape) * Cleanup trivial declaration in client --- clientmods/preview/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 60dccf304..bdda7fe4e 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -47,9 +47,21 @@ core.register_chatcommand("test_node", { end, }) +local function preview_minimap() + local minimap = core.ui.minimap + minimap:show() + minimap:set_mode(4) + minimap:set_pos({x=5, y=50, z=5}) + minimap:toggle_shape() + + print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) .. + " position => " .. dump(minimap:get_pos()) .. + " angle => " .. dump(minimap:get_angle())) +end core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") + preview_minimap() modstorage:set_string("current_mod", modname) print(modstorage:get_string("current_mod")) end) -- cgit v1.2.3 From 0891975ad6c8d6d3e15b20f33b22cf5baca7eb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 17 Mar 2017 07:48:29 +0100 Subject: [CSM] Add core.get_timeofday & core.get_day_count env calls (#5401) * [CSM] Add core.get_timeofday & core.get_day_count env calls * [CSM] Add core.get_node_level, core.get_node_max_level, core.find_node_near --- clientmods/preview/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index bdda7fe4e..3f85d576d 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -64,6 +64,15 @@ core.after(2, function() preview_minimap() modstorage:set_string("current_mod", modname) print(modstorage:get_string("current_mod")) + + print("[PREVIEW] Day count: " .. core.get_day_count() .. + " time of day " .. core.get_timeofday()) + + print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) .. + " max level " .. core.get_node_max_level({x=0, y=20, z=0})) + + print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10, + {"group:tree", "default:dirt", "default:stone"}))) end) core.register_on_dignode(function(pos, node) -- cgit v1.2.3 From 7b74f04a611ddaf36d79c0c9ebbf7f2b89c12a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 17 Mar 2017 07:54:49 +0100 Subject: [CSM] Fix minimap problems (#5405) This fixes issue #5404 --- clientmods/preview/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 3f85d576d..25a61da51 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -49,8 +49,8 @@ core.register_chatcommand("test_node", { local function preview_minimap() local minimap = core.ui.minimap - minimap:show() minimap:set_mode(4) + minimap:show() minimap:set_pos({x=5, y=50, z=5}) minimap:toggle_shape() @@ -61,9 +61,13 @@ end core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") - preview_minimap() modstorage:set_string("current_mod", modname) print(modstorage:get_string("current_mod")) + preview_minimap() +end) + +core.after(5, function() + core.ui.minimap:show() print("[PREVIEW] Day count: " .. core.get_day_count() .. " time of day " .. core.get_timeofday()) -- cgit v1.2.3 From d31750cb9375a961bf225ede210435751edfe7c9 Mon Sep 17 00:00:00 2001 From: red-001 Date: Fri, 17 Mar 2017 18:20:13 +0000 Subject: Give CSM access to use `core.colorize()` (#5113) --- clientmods/preview/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 25a61da51..008f7ac14 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -40,6 +40,12 @@ core.register_chatcommand("dump", { end, }) +core.register_chatcommand("colorize_test", { + func = function(param) + return true, core.colorize("red", param) + end, +}) + core.register_chatcommand("test_node", { func = function(param) core.display_chat_message(dump(core.get_node({x=0, y=0, z=0}))) -- cgit v1.2.3 From 9efc5da0fb7d276deff55db6e4eb89d24ca72b5d Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Wed, 22 Mar 2017 15:13:03 -0500 Subject: [CSM] Add function to get player names in range (#5435) * [CSM] Add function to get currently connected player names --- clientmods/preview/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 008f7ac14..c57a62155 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -102,7 +102,7 @@ core.register_on_punchnode(function(pos, node) print(dump(itemstack:get_count())) print(dump(itemstack:get_wear())) print(dump(itemstack:get_meta())) - print(dump(itemstack:get_metadata())) + print(dump(itemstack:get_metadata() print(dump(itemstack:is_known())) --print(dump(itemstack:get_definition())) print(dump(itemstack:get_tool_capabilities())) @@ -120,3 +120,10 @@ core.register_on_punchnode(function(pos, node) print("node:" .. dump(node)) return false end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_chatcommand("list_players", { + func = function(param) + core.display_chat_message(dump(core.get_player_names())) + end +}) -- cgit v1.2.3 From 63ac62ec8abe30f0d6dd2cfe0ddaab291c36893f Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 1 Apr 2017 12:40:56 +0100 Subject: [CSM] Add function and chat command to disconnect from server. (#5487) --- clientmods/preview/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index c57a62155..07464e927 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -127,3 +127,10 @@ core.register_chatcommand("list_players", { core.display_chat_message(dump(core.get_player_names())) end }) + +core.register_chatcommand("disconnect", { + description = "Exit to main menu", + func = function(param) + core.disconnect() + end, +}) -- cgit v1.2.3 From 88b9b9652ab77f91eaa7c6e40b8a48e3a35a7948 Mon Sep 17 00:00:00 2001 From: red-001 Date: Thu, 6 Apr 2017 21:50:45 +0100 Subject: [CSM] Add function to get the server protocol version. (#5529) --- clientmods/preview/init.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 07464e927..3c96fae55 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -69,6 +69,7 @@ core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") modstorage:set_string("current_mod", modname) print(modstorage:get_string("current_mod")) + print("Server version:" .. core.get_protocol_version()) preview_minimap() end) -- cgit v1.2.3 From f73534640a18709921519ee43110292cf658e67f Mon Sep 17 00:00:00 2001 From: Vincent Glize Date: Sat, 8 Apr 2017 08:20:30 +0200 Subject: [CSM] Add event on_connect player API lua (#5540) * Add event on_connect player API lua --- clientmods/preview/init.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 3c96fae55..5c0628bfe 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -6,6 +6,10 @@ core.register_on_shutdown(function() print("[PREVIEW] shutdown client") end) +core.register_on_connect(function() + print("[PREVIEW] Player connection completed") +end) + -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_receiving_chat_messages(function(message) print("[PREVIEW] Received message " .. message) -- cgit v1.2.3 From e8d872332040c16714ff6410d1f859adcec4766e Mon Sep 17 00:00:00 2001 From: red-001 Date: Mon, 10 Apr 2017 20:13:20 +0100 Subject: [CSM] Move `.list_players` and `.disconnect` to builtin. (#5550) --- clientmods/preview/init.lua | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 5c0628bfe..df07f8c3f 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -126,16 +126,3 @@ core.register_on_punchnode(function(pos, node) return false end) --- This is an example function to ensure it's working properly, should be removed before merge -core.register_chatcommand("list_players", { - func = function(param) - core.display_chat_message(dump(core.get_player_names())) - end -}) - -core.register_chatcommand("disconnect", { - description = "Exit to main menu", - func = function(param) - core.disconnect() - end, -}) -- cgit v1.2.3 From e80a83d1cb9d01273ddca1c075c25cd01c291ca7 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Fri, 14 Apr 2017 02:04:41 -0500 Subject: [CSM] Add function to set minimap shape (#5569) * [CSM] Add function to set minimap shape Also deprecates `toggle_shape`. * Oh fish, I messed that one up! * Fix Style * Sorry, I missed something I still had the `luamethod` call in there! * Add getters * Remove extra line * Remove useless variable Please review again @nerzhul . Thanks! * Satisfy nerzhul --- clientmods/preview/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index df07f8c3f..4b31fa323 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -62,7 +62,7 @@ local function preview_minimap() minimap:set_mode(4) minimap:show() minimap:set_pos({x=5, y=50, z=5}) - minimap:toggle_shape() + minimap:set_shape(math.random(0, 1)) print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) .. " position => " .. dump(minimap:get_pos()) .. -- cgit v1.2.3 From dc5bc6cac7b81ab27e0064bc25b5fd1d8d617340 Mon Sep 17 00:00:00 2001 From: Vincent Glize Date: Sat, 29 Apr 2017 12:08:16 +0200 Subject: [CSM] Add event on_place_node API lua (#5548) * [CSM] Add event on_place_node API lua --- clientmods/preview/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 4b31fa323..255c0b83f 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -10,6 +10,13 @@ core.register_on_connect(function() print("[PREVIEW] Player connection completed") end) +core.register_on_placenode(function(pointed_thing, node) + print("The local player place a node!") + print("pointed_thing :" .. dump(pointed_thing)) + print("node placed :" .. dump(node)) + return false +end) + -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_receiving_chat_messages(function(message) print("[PREVIEW] Received message " .. message) -- cgit v1.2.3 From ae0d8f74d747fab2fbe5b4553818e0f938e3289d Mon Sep 17 00:00:00 2001 From: red-001 Date: Wed, 19 Apr 2017 14:16:54 +0100 Subject: Add function to get server info. --- clientmods/preview/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 255c0b83f..fb606b3f4 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -8,6 +8,11 @@ end) core.register_on_connect(function() print("[PREVIEW] Player connection completed") + local server_info = core.get_server_info() + print("Server version: " .. server_info.protocol_version) + print("Server ip: " .. server_info.ip) + print("Server address: " .. server_info.address) + print("Server port: " .. server_info.port) end) core.register_on_placenode(function(pointed_thing, node) @@ -80,7 +85,6 @@ core.after(2, function() print("[PREVIEW] loaded " .. modname .. " mod") modstorage:set_string("current_mod", modname) print(modstorage:get_string("current_mod")) - print("Server version:" .. core.get_protocol_version()) preview_minimap() end) -- cgit v1.2.3 From 5ebf8f945050e9c74a3bb6784a0844d1fb68bdff Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 6 May 2017 20:12:44 +0100 Subject: [CSM] add `on_item_use` (#5544) --- clientmods/preview/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index fb606b3f4..821f7c714 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -22,6 +22,13 @@ core.register_on_placenode(function(pointed_thing, node) return false end) +core.register_on_item_use(function(itemstack, pointed_thing) + print("The local player used an item!") + print("pointed_thing :" .. dump(pointed_thing)) + print("item = " .. itemstack:get_name()) + return false +end) + -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_receiving_chat_messages(function(message) print("[PREVIEW] Received message " .. message) -- cgit v1.2.3 From 673ac55a9db4728a6817e284196e7acdd8f3daaf Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 20 May 2017 10:12:37 +0200 Subject: [CSM] Fix crash when the minimap is disabled. Caused by e25a38e --- clientmods/preview/init.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'clientmods/preview') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 821f7c714..f3992612a 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -78,6 +78,10 @@ core.register_chatcommand("test_node", { local function preview_minimap() local minimap = core.ui.minimap + if not minimap then + print("[PREVIEW] Minimap is disabled. Skipping.") + return + end minimap:set_mode(4) minimap:show() minimap:set_pos({x=5, y=50, z=5}) @@ -96,7 +100,9 @@ core.after(2, function() end) core.after(5, function() - core.ui.minimap:show() + if core.ui.minimap then + core.ui.minimap:show() + end print("[PREVIEW] Day count: " .. core.get_day_count() .. " time of day " .. core.get_timeofday()) -- cgit v1.2.3