sorcery  Diff

Differences From Artifact [8e18232927]:

To Artifact [378fef1f36]:

  • File gems.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: 6366) [annotate] [blame] [check-ins using]

     1      1   --- gemstones
     2      2   local shards_per_gem = 9
     3      3   
     4         -sorcery.register_gem = function(name,gem)
            4  +local register_gem = function(name,gem)
     5      5   	local itemname = gem.foreign or 'sorcery:gem_' .. name
     6      6   	local shardname = gem.foreign_shard or 'sorcery:gem_' .. name .. '_shard'
     7      7   	local amuletname = gem.foreign_amulet or 'sorcery:gem_' .. name .. '_amulet'
     8      8   
     9      9   	sorcery.data.gems[name].parts = {
    10     10   		item = itemname;
    11     11   		shard = shardname;
................................................................................
    36     36   			inventory_image = 'sorcery_gem_' .. name .. '_shard.png';
    37     37   			groups = { gemshard = 1; crystalshard = 1; sorcery_shard = 1; };
    38     38   			_sorcery = {
    39     39   				material = {
    40     40   					gem = true;
    41     41   					id = name, data = gem;
    42     42   					raw = true, value = 1;
           43  +				};
           44  +				recipe = {
           45  +					canonical = {
           46  +						craft = {
           47  +							{'','xdecor:hammer',''};
           48  +							{'',itemname,''};
           49  +						};
           50  +					}
    43     51   				};
    44     52   			};
    45     53   		})
    46     54   	end
    47     55   	if not gem.foreign_amulet then
    48     56   		minetest.register_craftitem(amuletname, {
    49     57   			description = sorcery.lib.str.capitalize(name) .. ' amulet';
................................................................................
   194    202   		minetest.override_item(ore, {drop = newdrops})
   195    203   		-- might be possible to just edit it in place, since we're
   196    204   		-- referring to registered_nodes anyway, but i don't want
   197    205   		-- to chance it; god knows what's going on under the hood
   198    206   	end
   199    207   end
   200    208   
   201         -for g,v in pairs(sorcery.data.gems) do sorcery.register_gem(g,v) end
          209  +-- for g,v in pairs(sorcery.data.gems) do sorcery.register_gem(g,v) end
          210  +sorcery.register.gems.foreach('sorcery:generate',{},register_gem)
   202    211   
   203    212   sorcery.gem = {
   204    213   	getdrops = function(fac)
   205    214   		items = {}
   206    215   		for g,v in pairs(sorcery.data.gems) do
   207    216   			items[#items + 1] = {
   208    217   				rarity = gem.rarity * fac;