sorcery  Diff

Differences From Artifact [26814ac7ca]:

To Artifact [8384a43ac0]:


    36     36   		local meta = minetest.get_meta(pos)
    37     37   		local inv = meta:get_inventory()
    38     38   		if inv:is_empty('charge') then return false end
    39     39   		
    40     40   		local ley = sorcery.ley.estimate(pos)
    41     41   		local charged = false
    42     42   		for i=1,inv:get_size('charge') do
    43         -			local repair_per_tick = (65536 / 64) * (15 * ley.force)
           43  +			local curve = function(x) return ((x*10)^2)/10 end
    44     44   			local item = inv:get_stack('charge',i)
    45     45   			if minetest.get_item_group(item:get_name(), 'sorcery_wand') ~= 0 then
           46  +				local mese = 1
           47  +				if sorcery.wands.util.getproto(item).gem == 'mese' then
           48  +					mese = 1.5 end
           49  +				local repair_per_tick = (65536 / 80) * curve(ley.force) * mese
    46     50   				local spell = item:get_meta():get_string('sorcery_wand_spell')
    47     51   				if spell == '' then goto skip end
    48     52   				local aff = sorcery.data.spells[spell].leytype
    49     53   				if aff == ley.aff[1] or aff == ley.aff[2] then
    50     54   					repair_per_tick = repair_per_tick * 2 end
    51         -			else goto skip end -- item is not magical
    52         -			print('repair cycle! repairing item'..item:get_name()..' by',repair_per_tick * (elapse / 60))
    53         -			item:set_wear(math.max(0,item:get_wear() - repair_per_tick * (elapse / 60)))
           55  +				item:set_wear(math.max(0,item:get_wear() - repair_per_tick * (elapse / 60)))
           56  +			else 
           57  +				local e = sorcery.enchant.get(item)
           58  +				if #e.spells == 0 then goto skip end -- item is not magical
           59  +				local mat = sorcery.enchant.getsubj(item)
           60  +				if e.energy < mat.data.maxenergy then
           61  +					local energy_per_tick = (100 * curve(ley.force)) + ((mat.data.energysource or 0)*2)
           62  +					e.energy = math.min(e.energy + energy_per_tick, mat.data.maxenergy)
           63  +					sorcery.enchant.set(item,e,true)
           64  +				else goto skip end -- already fully charged
           65  +			end
           66  +			-- print('repair cycle! repairing item'..item:get_name()..' by',repair_per_tick * (elapse / 60))
    54     67   			inv:set_stack('charge',i,item)
    55     68   			charged = true
    56     69   		::skip::end
    57     70   
    58     71   		return charged
    59     72   	end;
    60     73   
    61     74   	on_construct = function(pos)
    62     75   		local meta = minetest.get_meta(pos)
    63     76   		local inv = meta:get_inventory()
    64     77   		inv:set_size('charge', 3)
           78  +		meta:set_string('infotext','Harvester')
    65     79   		meta:set_string('formspec', [[
    66     80   			size[8,5]
    67     81   			list[context;charge;2.5,0;3,1;]
    68     82   			list[current_player;main;0,1.3;8,4;]
    69     83   			listring[]
    70     84   		]])
    71     85   	end;