add oresplus and shop mods

This commit is contained in:
elite 2017-07-06 14:34:28 -04:00
parent ad3be77f32
commit 316fc0abec
23 changed files with 551 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@ -0,0 +1,10 @@
## Ores Plus ##
##### A mod for Minetest adding a reasonable bunch of Minecraft-inspired ores in an efficient way. #####
##### List of ores : bedrock, emerald, glowstone and golden apple. #####
### Credits ###
##### Special thanks to Gambit for the textures from PixelBOX #####
![Preview](http://i.imgur.com/iHuKziF.png)

View File

@ -0,0 +1 @@
default

108
worldmods/oresplus/init.lua Normal file
View File

@ -0,0 +1,108 @@
------ MAPGEN ------
local ores_datas = {
{"bedrock", "default:stone", 1*1*1, 5, 2, -30912, -30896},
{"golden_apple", "default:apple", 6*6*6, 2, 2, 4, 64},
{"stone_with_emerald", "default:stone", 28*28*28, 2, 3, -30896, -1024},
{"stone_with_glowstone_dust", "default:stone", 24*24*24, 2, 3, -30896, -512}
}
for _, o in pairs(ores_datas) do
minetest.register_ore({
ore_type = "scatter",
ore = "oresplus:"..o[1],
wherein = o[2],
clust_scarcity = o[3],
clust_num_ores = o[4],
clust_size = o[5],
height_min = o[6],
height_max = o[7]
})
end
------ NODES ------
minetest.register_node("oresplus:bedrock", {
description = "Bedrock",
tile_images = {"oresplus_bedrock.png"},
groups = {unbreakable=1},
sounds = default.node_sound_stone_defaults()
})
for _, n in pairs({"emerald", "glowstone_dust"}) do
minetest.register_node("oresplus:stone_with_"..n, {
description = string.gsub(n:gsub("^%l", string.upper), "_d", " D").." Ore",
paramtype = "light",
tiles = {"default_stone.png^oresplus_mineral_"..n..".png"},
groups = {cracky=2},
drop = "oresplus:"..n,
sounds = default.node_sound_stone_defaults()
})
minetest.register_craftitem("oresplus:"..n, {
description = string.gsub(n:gsub("^%l", string.upper), "_d", " D"),
inventory_image = "oresplus_"..n..".png",
wield_image = "oresplus_"..n..".png"
})
end
for _, b in pairs({ {"emerald_block", 0}, {"glowstone", 13} }) do
minetest.register_node("oresplus:"..b[1], {
description = string.gsub(b[1]:gsub("^%l", string.upper), "_b", " B"),
paramtype = "light",
light_source = b[2],
tiles = {"oresplus_"..b[1]..".png"},
groups = {cracky=2},
sounds = default.node_sound_stone_defaults()
})
end
minetest.register_node("oresplus:golden_apple", {
description = "Golden Apple",
drawtype = "plantlike",
paramtype = "light",
tiles = {"oresplus_golden_apple.png"},
inventory_image = "oresplus_golden_apple.png",
wield_image = "oresplus_golden_apple.png",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.2, -0.4, -0.2, 0.2, 0.1, 0.2}
},
groups = {fleshy=3, dig_immediate=3, flammable=1, leafdecay=3, leafdecay_drop=1},
on_use = minetest.item_eat(20)
})
------ CRAFTS ------
minetest.register_craft({
output = "oresplus:emerald 9",
recipe = {{"oresplus:emerald_block"}}
})
minetest.register_craft({
output = "oresplus:emerald_block",
recipe = {
{"oresplus:emerald", "oresplus:emerald", "oresplus:emerald"},
{"oresplus:emerald", "oresplus:emerald", "oresplus:emerald"},
{"oresplus:emerald", "oresplus:emerald", "oresplus:emerald"}
}
})
minetest.register_craft({
output = "oresplus:glowstone",
recipe = {
{"oresplus:glowstone_dust", "oresplus:glowstone_dust"},
{"oresplus:glowstone_dust", "oresplus:glowstone_dust"}
}
})
minetest.register_craft({
output = "oresplus:golden_apple",
recipe = {
{"default:gold_ingot", "default:gold_ingot", "default:gold_ingot"},
{"default:gold_ingot", "default:apple", "default:gold_ingot"},
{"default:gold_ingot", "default:gold_ingot", "default:gold_ingot"}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

View File

@ -0,0 +1,2 @@
default
playereffects

12
worldmods/shop/init.lua Normal file
View File

@ -0,0 +1,12 @@
shop = {}
--[[shop.formspec_register =
"size[8,8]"..default.gui_bg..default.gui_bg_img..default.gui_slots..
"label[0,0;Register]"..
"list[current_name;shopregister;0,0.25;8;4]"..
"list[current_player;main;0,4;8,4;]"--]]
-- Shop Register & Coin
dofile(minetest.get_modpath("shop") .. "/mapgen.lua")
dofile(minetest.get_modpath("shop") .. "/privs_shop.lua")
dofile(minetest.get_modpath("shop") .. "/register.lua")

44
worldmods/shop/mapgen.lua Normal file
View File

@ -0,0 +1,44 @@
-- More gold at lower depths.
minetest.register_ore({
ore_type = "scatter",
ore = "default:stone_with_gold",
wherein = "default:stone",
clust_scarcity = 15 * 15 * 15,
clust_num_ores = 3,
clust_size = 2,
y_min = -255,
y_max = -64,
})
minetest.register_ore({
ore_type = "scatter",
ore = "default:stone_with_gold",
wherein = "default:stone",
clust_scarcity = 13 * 13 * 13,
clust_num_ores = 5,
clust_size = 3,
y_min = -1023,
y_max = -256,
})
minetest.register_ore({
ore_type = "scatter",
ore = "default:stone_with_gold",
wherein = "default:stone",
clust_scarcity = 11 * 11 * 11,
clust_num_ores = 7,
clust_size = 5,
y_min = -4095,
y_max = -1024,
})
minetest.register_ore({
ore_type = "scatter",
ore = "default:stone_with_gold",
wherein = "default:stone",
clust_scarcity = 9 * 9 * 9,
clust_num_ores = 11,
clust_size = 7,
y_min = -31000,
y_max = -4096,
})

View File

@ -0,0 +1,168 @@
-- Privs Shop
-- Global privs shop price, settable by /shop
shop.price = 1
-- Formspec
function shop.setform(pos)
local spos = pos.x..","..pos.y..","..pos.z
local formspec =
"size[8,6]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Priv Shop]" ..
"label[2.45,0.25;Fly]" ..
"label[4.45,0.25;Fast]" ..
"list[nodemeta:" ..spos.. ";fly;2.5,0.75;1,1;]" ..
"list[nodemeta:" ..spos.. ";fast;4.5,0.75;1,1;]" ..
"item_image[2.5,0.75;1,1;shop:coin]" ..
"item_image[4.5,0.75;1,1;shop:coin]" ..
"label[2.45,1.75;" .. shop.price .. " sec/$]" ..
"label[4.45,1.75;" .. shop.price .. " sec/$]" ..
"list[current_player;main;0,2.25;8,4;]"
return formspec
end
function shop.buy(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if listname == "fly" then
local count = stack:get_count()
inv:remove_item("fly", stack)
local name = player:get_player_name()
local time = count * shop.price
local q = playereffects.get_player_effects(name)
for i=1, #q do
if q[i].effect_type_id == "fly" then
local countdown_fly = playereffects.get_remaining_effect_time(q[i].effect_id)
local effectid_fly = playereffects.apply_effect_type("fly", time + countdown_fly, player)
return
end
end
local effectid_fly = playereffects.apply_effect_type("fly", time, player)
elseif listname == "fast" then
local count = stack:get_count()
inv:remove_item("fast", stack)
local name = player:get_player_name()
local time = count * shop.price
local q = playereffects.get_player_effects(name)
for i=1, #q do
if q[i].effect_type_id == "fast" then
local countdown_fast = playereffects.get_remaining_effect_time(q[i].effect_id)
local effectid_fast = playereffects.apply_effect_type("fast", time + countdown_fast, player)
return
end
end
local effectid_fast = playereffects.apply_effect_type("fast", time, player)
end
end
minetest.register_alias("shop:shop", "shop:privs")
minetest.register_node("shop:privs", {
description = "Privs Shop",
tiles = {"xdecor_barrel_top.png^shop_wings.png",
"xdecor_barrel_top.png",
"xdecor_barrel_top.png^shop_wings.png",
"xdecor_barrel_top.png^shop_wings.png",
"xdecor_barrel_top.png^shop_wings.png",
"xdecor_barrel_top.png^shop_wings.png"},
is_ground_content = true,
groups = {cracky=2, choppy=3, oddly_breakable_by_hand=1},
paramtype2 = "facedir",
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Shop for privs")
local inv = meta:get_inventory()
inv:set_size("fly", 1)
inv:set_size("fast", 1)
end,
on_rightclick = function(pos, node, clicker, itemstack)
minetest.show_formspec(clicker:get_player_name(), "shop:privs", shop.setform(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
shop.buy(pos, listname, index, stack, player)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local s = stack:get_name()
local c = stack:get_count()
if listname == "fly" then
if s == "shop:coin" then
return -1
else
return 0
end
elseif listname == "fast" then
if s == "shop:coin" then
return -1
else
return 0
end
else
return 0
end
end
})
-- playereffects registration
playereffects.register_effect_type("fly", "Fly mode available", nil, {"fly"},
function(player)
local playername = player:get_player_name()
local privs = minetest.get_player_privs(playername)
privs.fly = true
minetest.set_player_privs(playername, privs)
end,
function(effect, player)
local privs = minetest.get_player_privs(effect.playername)
privs.fly = nil
minetest.set_player_privs(effect.playername, privs)
end,
false,
false)
playereffects.register_effect_type("fast", "Fast mode available", nil, {"fast"},
function(player)
local playername = player:get_player_name()
local privs = minetest.get_player_privs(playername)
privs.fast = true
minetest.set_player_privs(playername, privs)
end,
function(effect, player)
local privs = minetest.get_player_privs(effect.playername)
privs.fast = nil
minetest.set_player_privs(effect.playername, privs)
end,
false,
false)
-- /shop chat command registration
minetest.register_chatcommand("shop", {
params = "<price>",
privs = {server=true},
description = "Adjust privs shop price",
func = function(name, param)
param = tonumber(param)
if param then
local price = math.floor(math.abs(param))
if price < 60 then
shop.price = price
end
end
end
})
minetest.register_craft({
output = "shop:privs",
recipe = {
{"group:wood", "default:mese", "group:wood"},
{"group:wood", "default:goldblock", "group:wood"},
{"group:wood", "default:diamondblock", "group:wood"}
}
})

193
worldmods/shop/register.lua Normal file
View File

@ -0,0 +1,193 @@
local function get_register_formspec(pos)
local meta = minetest.get_meta(pos)
local spos = pos.x.. "," ..pos.y .. "," .. pos.z
local formspec =
"size[8,6.5]" ..
--default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,1;Sell]" ..
"label[3,1;For]" ..
"button[0,0;2,1;stock;Stock]" ..
"button[3,0;2,1;register;Register]" ..
"button_exit[7,0;1,1;exit;X]" ..
"button[7,1;1,1;ok;OK]" ..
"list[nodemeta:" .. spos .. ";sell;1,1;1,1;]" ..
"list[nodemeta:" .. spos .. ";buy;4,1;1,1;]" ..
"list[current_player;main;0,2.75;8,4;]"
return formspec
end
local formspec_register =
"size[8,9]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Register]" ..
"list[current_name;register;0,0.75;8,4;]" ..
"list[current_player;main;0,5.25;8,4;]" ..
"listring[]"
local formspec_stock =
"size[8,9]" ..
--default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Stock]" ..
"list[current_name;stock;0,0.75;8,4;]" ..
"list[current_player;main;0,5.25;8,4;]" ..
"listring[]"
minetest.register_privilege("shop_admin", "Shop administration and maintainence")
minetest.register_node("shop:register", {
description = "Shop",
tiles = {
"shop_shop_topbottom.png",
"shop_shop_topbottom.png",
"shop_shop_side.png",
"shop_shop_side.png",
"shop_shop_side.png",
"shop_shop_front.png",
},
groups = {choppy = 3, oddly_breakable_by_hand = 1},
paramtype2 = "facedir",
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local owner = placer:get_player_name()
meta:set_string("owner", owner)
meta:set_string("infotext", "Shop (Owned by " .. owner .. ")")
meta:set_string("formspec", get_register_formspec(pos))
local inv = meta:get_inventory()
inv:set_size("buy", 1)
inv:set_size("sell", 1)
inv:set_size("stock", 8*4)
inv:set_size("register", 8*4)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local player = sender:get_player_name()
local inv = meta:get_inventory()
local s = inv:get_list("sell")
local b = inv:get_list("buy")
local stk = inv:get_list("stock")
local reg = inv:get_list("register")
local pinv = sender:get_inventory()
if fields.register then
if player ~= owner and (not minetest.check_player_privs(player, "shop_admin")) then
minetest.chat_send_player(player, "Only the shop owner can open the register.")
return
else
minetest.show_formspec(player, "shop:shop", formspec_register)
end
elseif fields.stock then
if player ~= owner and (not minetest.check_player_privs(player, "shop_admin")) then
minetest.chat_send_player(player, "Only the shop owner can open the stock.")
return
else
minetest.show_formspec(player, "shop:shop", formspec_stock)
end
elseif fields.ok then
if inv:is_empty("sell") or
inv:is_empty("buy") or
(not inv:room_for_item("register", b[1])) then
minetest.chat_send_player(player, "Shop closed.")
return
end
if (pinv:contains_item("main", b[1]) or
pinv:contains_item("funds", b[1])) and
inv:contains_item("stock", s[1]) and
pinv:room_for_item("main", s[1]) then
pinv:remove_item("main", b[1])
inv:add_item("register", b[1])
inv:remove_item("stock", s[1])
pinv:add_item("main", s[1])
else
minetest.chat_send_player(player, "No funds.")
end
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
local s = inv:get_list("sell")
local n = stack:get_name()
local playername = player:get_player_name()
if playername ~= owner and
(not minetest.check_player_privs(playername, "shop_admin")) then
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local playername = player:get_player_name()
if playername ~= owner and
(not minetest.check_player_privs(playername, "shop_admin"))then
return 0
else
return stack:get_count()
end
end,
allow_metadata_inventory_move = function(pos, _, _, _, _, count, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local playername = player:get_player_name()
if playername ~= owner and
(not minetest.check_player_privs(playername, "shop_admin")) then
return 0
else
return count
end
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
return player:get_player_name() == owner and
inv:is_empty("register") and
inv:is_empty("stock") and
inv:is_empty("buy") and
inv:is_empty("sell")
end,
})
minetest.register_craftitem("shop:coin", {
description = "Gold Coin",
inventory_image = "shop_coin.png",
})
-- Crafts & Craft Items
minetest.register_craft({
output = "shop:coin 9",
recipe = {
{"default:gold_ingot"},
}
})
minetest.register_craft({
output = "default:gold_ingot",
recipe = {
{"shop:coin", "shop:coin", "shop:coin"},
{"shop:coin", "shop:coin", "shop:coin"},
{"shop:coin", "shop:coin", "shop:coin"}
}
})
minetest.register_craft({
output = "shop:register",
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"group:wood", "default:goldblock", "group:wood"},
{"group:wood", "group:wood", "group:wood"}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B