From 633335898d10a41590bed487d2ab3ec1e28bb37b Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 9 Jul 2016 14:45:03 +0100 Subject: [PATCH] Use string:split() from the Lua API instead of defining a new function https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1759 --- mods/story/init.lua | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/mods/story/init.lua b/mods/story/init.lua index 38d3502..2d04346 100644 --- a/mods/story/init.lua +++ b/mods/story/init.lua @@ -1,21 +1,5 @@ story = {} --- string -function string:split(inSplitPattern, outResults) - if not outResults then - outResults = {} - end - local theStart = 1 - local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart ) - while theSplitStart do - table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) ) - theStart = theSplitEnd + 1 - theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart ) - end - table.insert( outResults, string.sub( self, theStart ) ) - return outResults -end - -- form story.talk_form = "size[8,7.5;]" @@ -32,7 +16,7 @@ end function story.show_dialog(player, text) local lines = text:split("\n") for i,t in ipairs(lines) do - minetest.after((i-1)*2.3, function(player, t) + minetest.after((i-1)*2.3, function(player, t) cmsg.push_message_player(player, t) end, player,t) end