holostorage/items/storage_disk.lua

31 lines
946 B
Lua
Raw Normal View History

2018-04-07 18:32:41 +00:00
-- Storage disks
2018-04-08 14:11:39 +00:00
holostorage.disks = {}
2018-04-07 18:32:41 +00:00
2018-04-08 14:11:39 +00:00
function holostorage.disks.register_disk(index, desc, capacity)
2018-04-07 18:32:41 +00:00
local mod = minetest.get_current_modname()
minetest.register_craftitem(mod..":storage_disk"..index, {
description = desc.."\nStores "..capacity.." Stacks",
2018-04-08 14:11:39 +00:00
inventory_image = "holostorage_disk"..index..".png",
groups = {holostorage_disk = 1},
holostorage_capacity = capacity,
holostorage_name = "disk"..index,
2018-04-07 18:32:41 +00:00
stack_max = 1,
on_secondary_use = function (itemstack, user, pointed_thing)
return stack
end
})
end
2018-04-08 09:39:06 +00:00
-- Make sure stack is disk
2018-04-08 14:11:39 +00:00
function holostorage.disks.is_valid_disk(stack)
2018-04-08 09:39:06 +00:00
local stack_name = stack:get_name()
2018-04-08 14:11:39 +00:00
return minetest.get_item_group(stack_name, "holostorage_disk") > 0
2018-04-07 18:32:41 +00:00
end
local capacities = {1000, 8000, 16000, 32000, 64000}
local descriptions = {"1K Disk", "8K Disk", "16K Disk", "32K Disk", "64K Disk"}
for i = 1, 5 do
2018-04-08 14:11:39 +00:00
holostorage.disks.register_disk(i, descriptions[i], capacities[i])
2018-04-07 18:32:41 +00:00
end