sorcery  Check-in [38ae873453]

Overview
Comment:coin press fixes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 38ae8734536a304dadba361fb3d994c8ec434461f892e4fc923a916721a11fea
User & Date: lexi on 2021-07-06 14:32:32
Other Links: manifest | tags
Context
2021-07-06
16:55
add leyline debugger check-in: ef607df117 user: lexi tags: trunk
14:32
coin press fixes check-in: 38ae873453 user: lexi tags: trunk
13:35
tweaks, add getting started guide check-in: 6a4d5ed7c7 user: lexi tags: trunk
Changes

Modified coins.lua from [3ea00fa42e] to [f621f46631].

    64     64   	local slot_ingot = inv:get_stack('ingot',1)
    65     65   	local slot_gem   = inv:get_stack('gem',1)
    66     66   	local metalname, gemname
    67     67   	local coincount
    68     68   	if not inv:is_empty('ingot') then
    69     69   		local id = slot_ingot:get_name()
    70     70   		for name,metal in pairs(sorcery.data.metals) do
    71         -			if id == metal.parts.ingot then
           71  +			if id == metal.parts.ingot or
           72  +				id == minetest.registered_aliases[metal.parts.ingot] then
    72     73   				metalname = name
    73     74   				coincount = slot_ingot:get_count()
    74     75   				goto foundmetal
    75     76   			end
    76     77   		end
    77     78   	end
    78     79   	inv:set_stack('output',1,ItemStack(nil))
................................................................................
   146    147   					listring[current_player;main]
   147    148   		]])
   148    149   	end;
   149    150   	allow_metadata_inventory_put = function(pos,list,idx,stack,user)
   150    151   		local id = stack:get_name()
   151    152   		if list == 'ingot' then
   152    153   			for name,metal in pairs(sorcery.data.metals) do
   153         -				if id == metal.parts.ingot then goto okay end
          154  +				if id == metal.parts.ingot or
          155  +					id == minetest.registered_aliases[metal.parts.ingot]
          156  +				then goto okay end
   154    157   			end
   155    158   		elseif list == 'gem' then
   156    159   			for name,gem in pairs(sorcery.data.gems) do
   157    160   				if gem.foreign then
   158         -					if id == gem.foreign then goto okay end
          161  +					if id == gem.foreign or
          162  +						id == minetest.registered_aliases[gem.foreign]
          163  +					then goto okay end
   159    164   				else
   160    165   					if id == 'sorcery:gem_' .. name then goto okay end
   161    166   				end
   162    167   			end
   163    168   		end
   164    169   		do return 0 end
   165    170   		::okay:: return max_components
................................................................................
   179    184   	on_metadata_inventory_take = function(pos,list,idx,stack,user)
   180    185   		local meta = minetest.get_meta(pos)
   181    186   		if list == 'output' then
   182    187   			local items_used = math.floor(stack:get_count() / coins_per_ingot)
   183    188   			local inv = meta:get_inventory()
   184    189   			local reduce_slot = function(slot)
   185    190   				local i = inv:get_stack(slot,1)
          191  +				local s = i:get_name()
   186    192   				i:take_item(items_used) inv:set_stack(slot,1,i)
          193  +				if slot == 'gem' then
          194  +					for k,v in pairs(sorcery.data.gems) do
          195  +						if v.parts.item == s then
          196  +							local repl = ItemStack {
          197  +								name = v.parts.shard;
          198  +								count = items_used;
          199  +							}
          200  +							u.node.insert(repl, 'gem', pos, user, inv)
          201  +							break
          202  +						end
          203  +					end
          204  +				end
   187    205   			end
   188    206   			reduce_slot('ingot')
   189    207   			if not inv:is_empty('gem') then reduce_slot('gem') end
   190    208   			minetest.sound_play('sorcery_coins', { pos = pos, gain = 0.7 })
   191    209   		end
   192    210   		update_press_output(meta)
   193    211   	end;

Modified lib/node.lua from [b21e3fad50] to [3d99ab5529].

   130    130   
   131    131   	is_clear = function(pos)
   132    132   		if not sorcery.lib.node.is_air(pos) then return false end
   133    133   		local ents = minetest.get_objects_inside_radius(pos,0.5)
   134    134   		if #ents > 0 then return false end
   135    135   		return true
   136    136   	end;
          137  +
          138  +	insert = function(item, slot, npos, user, inv)
          139  +		inv = inv or minetest.get_meta(npos):get_inventory()
          140  +		if inv:room_for_item(slot,item) then
          141  +			inv:add_item(slot,item)
          142  +		else repeat
          143  +			if user then
          144  +				local ui = user:get_inventory()
          145  +				if ui:room_for_item('main', item) then
          146  +					ui:add_item('main', item)
          147  +					break
          148  +				end
          149  +			end
          150  +			minetest.add_item(npos, item)
          151  +		until true end
          152  +	end;
   137    153   
   138    154   	tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION
   139    155   		-- this is going to require some explanation.
   140    156   		--
   141    157   		-- for various purposes, we want to be able to tell the difference between
   142    158   		-- a tree that has grown naturally from the grown vs. a couple of trunk nodes
   143    159   		-- that the player has jammed together, even if she's built her own counterfeit