Overview
| Comment: | coin press fixes |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
38ae8734536a304dadba361fb3d994c8 |
| 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 ... 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 ... 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
local slot_ingot = inv:get_stack('ingot',1)
local slot_gem = inv:get_stack('gem',1)
local metalname, gemname
local coincount
if not inv:is_empty('ingot') then
local id = slot_ingot:get_name()
for name,metal in pairs(sorcery.data.metals) do
if id == metal.parts.ingot then
metalname = name
coincount = slot_ingot:get_count()
goto foundmetal
end
end
end
inv:set_stack('output',1,ItemStack(nil))
................................................................................
listring[current_player;main]
]])
end;
allow_metadata_inventory_put = function(pos,list,idx,stack,user)
local id = stack:get_name()
if list == 'ingot' then
for name,metal in pairs(sorcery.data.metals) do
if id == metal.parts.ingot then goto okay end
end
elseif list == 'gem' then
for name,gem in pairs(sorcery.data.gems) do
if gem.foreign then
if id == gem.foreign then goto okay end
else
if id == 'sorcery:gem_' .. name then goto okay end
end
end
end
do return 0 end
::okay:: return max_components
................................................................................
on_metadata_inventory_take = function(pos,list,idx,stack,user)
local meta = minetest.get_meta(pos)
if list == 'output' then
local items_used = math.floor(stack:get_count() / coins_per_ingot)
local inv = meta:get_inventory()
local reduce_slot = function(slot)
local i = inv:get_stack(slot,1)
i:take_item(items_used) inv:set_stack(slot,1,i)
end
reduce_slot('ingot')
if not inv:is_empty('gem') then reduce_slot('gem') end
minetest.sound_play('sorcery_coins', { pos = pos, gain = 0.7 })
end
update_press_output(meta)
end;
|
| > | > > | > > > > > > > > > > > > > > > |
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 ... 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 ... 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
local slot_ingot = inv:get_stack('ingot',1)
local slot_gem = inv:get_stack('gem',1)
local metalname, gemname
local coincount
if not inv:is_empty('ingot') then
local id = slot_ingot:get_name()
for name,metal in pairs(sorcery.data.metals) do
if id == metal.parts.ingot or
id == minetest.registered_aliases[metal.parts.ingot] then
metalname = name
coincount = slot_ingot:get_count()
goto foundmetal
end
end
end
inv:set_stack('output',1,ItemStack(nil))
................................................................................
listring[current_player;main]
]])
end;
allow_metadata_inventory_put = function(pos,list,idx,stack,user)
local id = stack:get_name()
if list == 'ingot' then
for name,metal in pairs(sorcery.data.metals) do
if id == metal.parts.ingot or
id == minetest.registered_aliases[metal.parts.ingot]
then goto okay end
end
elseif list == 'gem' then
for name,gem in pairs(sorcery.data.gems) do
if gem.foreign then
if id == gem.foreign or
id == minetest.registered_aliases[gem.foreign]
then goto okay end
else
if id == 'sorcery:gem_' .. name then goto okay end
end
end
end
do return 0 end
::okay:: return max_components
................................................................................
on_metadata_inventory_take = function(pos,list,idx,stack,user)
local meta = minetest.get_meta(pos)
if list == 'output' then
local items_used = math.floor(stack:get_count() / coins_per_ingot)
local inv = meta:get_inventory()
local reduce_slot = function(slot)
local i = inv:get_stack(slot,1)
local s = i:get_name()
i:take_item(items_used) inv:set_stack(slot,1,i)
if slot == 'gem' then
for k,v in pairs(sorcery.data.gems) do
if v.parts.item == s then
local repl = ItemStack {
name = v.parts.shard;
count = items_used;
}
u.node.insert(repl, 'gem', pos, user, inv)
break
end
end
end
end
reduce_slot('ingot')
if not inv:is_empty('gem') then reduce_slot('gem') end
minetest.sound_play('sorcery_coins', { pos = pos, gain = 0.7 })
end
update_press_output(meta)
end;
|
Modified lib/node.lua from [b21e3fad50] to [3d99ab5529].
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
is_clear = function(pos) if not sorcery.lib.node.is_air(pos) then return false end local ents = minetest.get_objects_inside_radius(pos,0.5) if #ents > 0 then return false end return true end; tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION -- this is going to require some explanation. -- -- for various purposes, we want to be able to tell the difference between -- a tree that has grown naturally from the grown vs. a couple of trunk nodes -- that the player has jammed together, even if she's built her own counterfeit |
> > > > > > > > > > > > > > > > |
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
is_clear = function(pos) if not sorcery.lib.node.is_air(pos) then return false end local ents = minetest.get_objects_inside_radius(pos,0.5) if #ents > 0 then return false end return true end; insert = function(item, slot, npos, user, inv) inv = inv or minetest.get_meta(npos):get_inventory() if inv:room_for_item(slot,item) then inv:add_item(slot,item) else repeat if user then local ui = user:get_inventory() if ui:room_for_item('main', item) then ui:add_item('main', item) break end end minetest.add_item(npos, item) until true end end; tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION -- this is going to require some explanation. -- -- for various purposes, we want to be able to tell the difference between -- a tree that has grown naturally from the grown vs. a couple of trunk nodes -- that the player has jammed together, even if she's built her own counterfeit |