sorcery  Diff

Differences From Artifact [e883d78392]:

To Artifact [64ce434f04]:

  • File lib/str.lua — part of check-in [3f6a913e4e] at 2020-09-29 12:40:28 on branch trunk — * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior * initial documentation commit * initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes (user: lexi, size: 2303) [annotate] [blame] [check-ins using]

     9      9   	['\xf2'] = '\2';
    10     10   	['\xf3'] = '\3';
    11     11   }
    12     12   return {
    13     13   	capitalize = function(str)
    14     14   		return string.upper(string.sub(str, 1,1)) .. string.sub(str, 2)
    15     15   	end;
           16  +
           17  +	explode = function(str,delim)
           18  +		local i = 1
           19  +		local tbl = {}
           20  +		repeat
           21  +			local ss = string.sub(str, i)
           22  +			local d = string.find(ss, delim, 1, true) or string.len(ss)+1
           23  +			tbl[#tbl+1] = string.sub(ss,1,d-1)
           24  +			i = i + d 
           25  +		until i > string.len(str)
           26  +		return tbl
           27  +	end;
    16     28   
    17     29   	rand = function(min,max)
    18     30   		if not min then min = 16  end
    19     31   		if not max then max = min end
    20     32   		local str = ''
    21     33   		local r_int   =            0x39 - 0x30
    22     34   		local r_upper = r_int   + (0x5a - 0x41)