From 219a886ab418f9b739da07cb560e4bf796dd45d9 Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Tue, 2 Jul 2024 22:53:01 +0200 Subject: [PATCH] Adds preconditions --- internal.lua | 12 ++++++++++++ item_melon.lua | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal.lua b/internal.lua index 7518fce..066a5c4 100644 --- a/internal.lua +++ b/internal.lua @@ -19,3 +19,15 @@ local function get_node_definition() end function yl_canned_food.get_node_definition() return get_node_definition() end + +local function can_set(pos) + local light = minetest.get_node_light(pos) + if (light and light > 5) then + return false + end + return true +end + +function yl_canned_food.can_set(pos) + return can_set(pos) +end \ No newline at end of file diff --git a/item_melon.lua b/item_melon.lua index 636e4a3..0e4604b 100644 --- a/item_melon.lua +++ b/item_melon.lua @@ -24,10 +24,10 @@ table.insert(stages, { duration = 10, --duration = "10", next_stages = { - { "yl_canned_food:melon_jam_3", 50 }, - { "yl_canned_food:melon_jam_4", 50 }, - { "default:cobble", 50 } - }, + { "yl_canned_food:melon_jam_3", 50, yl_canned_food.can_set}, + { "yl_canned_food:melon_jam_4", 50}, + { "default:cobble", 50, yl_canned_food.can_set} + }, --node definition tiles = {"yl_canned_food_melon_jam_2.png"}, description = "Awesome melon jam Stage 2",