From 711d9fe88df965e7f90a8999b131c623019780cc Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Thu, 11 Feb 2016 21:43:00 +0100 Subject: [PATCH] Use string.sub wherever possible --- nodes.lua | 2 +- worktable.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nodes.lua b/nodes.lua index 53537c4..38da8e2 100644 --- a/nodes.lua +++ b/nodes.lua @@ -179,7 +179,7 @@ xdecor.register("cushion_block", { }) local function door_access(door) - return door:find("prison") + return door:sub(1,6) == "prison" end local door_types = { diff --git a/worktable.lua b/worktable.lua index 6f3a86b..d189e70 100644 --- a/worktable.lua +++ b/worktable.lua @@ -59,8 +59,8 @@ worktable.nodebox_blender = { } function worktable:get_recipe(item) - if item:find("^group:") then - if item:find("wool$") or item:find("dye$") then + if item:sub(1,6) == "group:" then + if item:sub(-4) == "wool" or item:sub(-3) == "dye" then item = item:sub(7)..":white" elseif minetest.registered_items["default:"..item:sub(7)] then item = item:gsub("group:", "default:") @@ -125,7 +125,7 @@ function worktable:craftguide_formspec(meta, pagenum, item, recipe_num, filter) local rows = math.ceil(table.maxn(items) / width) -- Lua 5.3 removed `table.maxn`, use `xdecor.maxn` in case of failure. local function is_group(item) - if item:find("^group:") then return "\nG" end + if item:sub(1,6) == "group:" then return "\nG" end return "" end