Skip to content

Commit

Permalink
Merge pull request #87 from Panquesito7/fix_some_issues
Browse files Browse the repository at this point in the history
Minor improvements and fixes in the code
  • Loading branch information
cornernote authored Aug 14, 2021
2 parents 65cc7d6 + 42b6533 commit 5f5bd8b
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 40 deletions.
3 changes: 2 additions & 1 deletion skyblock/mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name = skyblock
depends = default
depends = default
description = Build a world starting from a small island in the sky.
2 changes: 1 addition & 1 deletion skyblock/register_node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ minetest.register_node('skyblock:quest', {
is_ground_content = true,
paramtype = 'light',
sunlight_propagates = true,
light_source = 15,
light_source = 14,
can_dig = function(pos, player)
return false
end,
Expand Down
2 changes: 1 addition & 1 deletion skyblock/skyblock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ end
function skyblock.make_spawn_blocks(pos, player_name)
skyblock.log('skyblock.make_spawn_blocks('..skyblock.dump_pos(pos)..', '..player_name..') ')
skyblock.load_schem(pos, skyblock.schem)
--minetest.env:add_node(pos, {name='skyblock:quest'})
--minetest.add_node(pos, {name='skyblock:quest'})
end

-- make spawn blocks on generated
Expand Down
1 change: 1 addition & 0 deletions skyblock_levels/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dofile(modpath..'/skyblock.levels.1.lua')
dofile(modpath..'/skyblock.levels.2.lua')
dofile(modpath..'/skyblock.levels.3.lua')
dofile(modpath..'/skyblock.levels.4.lua')
dofile(modpath..'/skyblock.levels.5.lua')

dofile(modpath..'/register_abm.lua')
dofile(modpath..'/register_craft.lua')
Expand Down
43 changes: 27 additions & 16 deletions skyblock_levels/register_command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,38 @@ License: GPLv3


-- register register_privilege
minetest.register_privilege('level', 'Can use /level')
minetest.register_privilege('level', 'Can use /setlevel')

-- level
minetest.register_chatcommand('level', {
description = 'Get or change a players current level.',
privs = {level = true},
params = "<player_name> <level>",
-- getlevel
minetest.register_chatcommand('getlevel', {
description = 'Get a player\'s current level.',
params = "<player_name>",
func = function(name, param)
local _, _, player_name, level = param:find("^([^%s]+)%s+(.+)$")
if not player_name then
local player_name = param
if player_name == "" then
player_name = name
end
level = tonumber(level)
if not level then
minetest.chat_send_player(name, player_name..' is on level '..skyblock.feats.get_level(player_name))
return
end
if skyblock.feats.set_level(player_name, level) then
minetest.chat_send_player(name, player_name..' has been set to level '..level)
minetest.chat_send_player(name, player_name..' is on level '..skyblock.feats.get_level(player_name))
return
end,
})

-- setlevel
minetest.register_chatcommand('setlevel', {
description = 'Set a player\'s current level',
privs = {level = true},
params = "<player_name> <level>",
func = function(name, param)
local found, _, player_name, level = param:find("^([^%s]+)%s+(.+)$")
if found and player_name and level then
level = tonumber(level)
if skyblock.feats.set_level(player_name, level) then
minetest.chat_send_player(name, player_name..' has been set to level '..level)
else
minetest.chat_send_player(name, 'cannot change '..player_name..' to level '..level)
end
else
minetest.chat_send_player(name, 'cannot change '..player_name..' to level '..level)
return false, "Invalid use."
end
end,
})
Expand Down
3 changes: 3 additions & 0 deletions skyblock_levels/skyblock.feats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ end
-- set feat
function skyblock.feats.set(level,player_name,feat,value)
skyblock.log('skyblock.feats.set('..level..','..player_name..','..feat..')')
if not players_feat[player_name] then
players_feat[player_name] = skyblock.feats.load(player_name) or {[0] = {}}
end
players_feat[player_name][level][feat] = value
if level~=0 or feat~='level' then
local rewarded = skyblock.levels[level].reward_feat(player_name,feat)
Expand Down
4 changes: 2 additions & 2 deletions skyblock_levels/skyblock.levels.3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ level 3 feats and rewards:
* place_steelblock x4 default:obsidian_shard
* place_sand x50 wool:green 50
* dig_stone_with_copper x4 wool:orange 50
* place_bar x8 default:mese_crystal
* place_bar_flat x8 default:mese_crystal
* dig_stone_with_mese x4 default:gold_lump
* place_water_infinite x8 default:diamond
Expand Down Expand Up @@ -94,7 +94,7 @@ skyblock.levels[level].feats = {
{
name = 'place 8 Iron Bars',
hint = 'xpanes:bar_flat',
feat = 'place_bar',
feat = 'place_bar_flat',
count = 8,
reward = 'default:mese_crystal',
placenode = {'xpanes:bar_flat'},
Expand Down
167 changes: 148 additions & 19 deletions skyblock_levels/skyblock.levels.4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ License: GPLv3
]]--

--[[
Level 4 mostly revolving around farming and dying
level 4 feats and rewards:
* craft_diamondhoe farming:seed_wheat
* use_hoe x40 farming:melon_slice
* plant_wheatseed default:cactus
* craft_flour farming:seed_cotton x10
* place_snowblock x50 dye:red x20
* dig_cactus x10 dye:white x20
* dig_geranium x5 flowers:mushroom_brown x2
* dig_tulip x5 flowers:mushroom_red x2
* dig_brownmushroom x15 farming:corn x50
* craft_ethanol default:meselamp x5
]]--

local level = 4

--
Expand All @@ -17,46 +34,158 @@ local level = 4
skyblock.levels[level] = {}

-- feats
skyblock.levels[level].feats = {}
-- Parts of this are purely hypothetical and not implement yet
skyblock.levels[level].feats = {
{
name = "Craft a mese hoe",
hint = "farming:hoe_mese",
feat = "craft_mesehoe",
count = 1,
reward = "farming:seed_wheat 2",
craft = {"farming:hoe_mese"}
},
{
name = "Use the hoe 40 times",
hint = "farming:hoe_mese",
feat = "use_hoe",
count = 40,
reward = "farming:melon_slice",
hoeuse = {}
},
{
name = "Plant 10 wheat seeds",
hint = "farming:seed_wheat",
feat = "place_wheatseed",
count = 10,
reward = "default:cactus",
placenode = {"farming:seed_wheat"}
},
{
name = "Craft 4 lumps of flour",
hint = "farming:flour",
feat = "craft_flour",
count = 4,
reward = "farming:seed_cotton 10",
craft = {"farming:flour"},
},
{
name = "Place 50 snow blocks",
hint = "default:snowblock",
feat = "place_snowblock",
count = 50,
reward = "dye:red 20",
placenode = {"default:snowblock"},
},
{
name = "Dig 10 cacti",
hint = "default:cactus",
feat = "dig_cactus",
count = 10,
reward = "dye:white 20",
dignode = {"default:cactus"},
},
{
name = "Pick 5 Geranium flowers",
hint = "flowers:geranium",
feat = "dig_geranium",
count = 5,
reward = "flowers:mushroom_brown 2",
dignode = {"flowers:geranium"},
},
{
name = "Pick 5 orange tulips",
hint = "flowers:tulip",
feat = "dig_tulip",
count = 5,
reward = "flowers:mushroom_red 2",
dignode = {"flowers:tulip"},
},
{
name = "Dig 10 brown mushrooms",
hint = "flowers:mushroom_brown",
feat = "dig_brownmushroom",
count = 10,
reward = "farming:corn",
dignode = {"flowers:mushroom_brown"},
},
{
name = "Make ethanol!",
hint = "farming:corn",
feat = "craft_ethanol",
count = 1,
reward = "default:meselamp 5",
craft = {"farming:bottle_ethanol"},
}
}

-- init level
skyblock.levels[level].init = function(player_name)
local privs = core.get_player_privs(player_name)
privs['fly'] = true
privs['fast'] = true
core.set_player_privs(player_name, privs)
minetest.chat_send_player(player_name, 'You can now use FLY and FAST !')
end

-- get level information
skyblock.levels[level].get_info = function(player_name)
local info = {
level=level,
total=1,
total=10,
count=0,
player_name=player_name,
infotext='',
formspec = '',
formspec_quest = '',
}

local text = 'label[0,0.5; THE END]'
..'label[0,1.0; I hope you enjoyed your journey, and you]'
..'label[0,1.5; are welcome to stay and keep building]'
..'label[0,2.0; your new sky world.]'
local text = 'label[0,2.7; --== Quests ==--]'
..'label[0,0.5; Time Goes On, '..player_name..'...]'
..'label[0,1.0; You may wonder, traveller, where some of your]'
..'label[0,1.5; precious items are. Be patient...]'
..'label[0,2.0; They will come to you in time...]'

info.formspec = skyblock.levels.get_inventory_formspec(level,info.player_name,true)..text
info.formspec_quest = skyblock.levels.get_inventory_formspec(level,info.player_name)..text
info.infotext = 'THE END! for '.. player_name ..' ... or is it ...'

for k,v in ipairs(skyblock.levels[level].feats) do
info.formspec = info.formspec..skyblock.levels.get_feat_formspec(info,k,v.feat,v.count,v.name,v.hint,true)
info.formspec_quest = info.formspec_quest..skyblock.levels.get_feat_formspec(info,k,v.feat,v.count,v.name,v.hint)
end
if info.count>0 then
info.count = info.count/2 -- only count once
end

info.infotext = 'LEVEL '..info.level..' for '..info.player_name..': '..info.count..' of '..info.total

return info
end

-- no feat tracking
skyblock.levels[level].reward_feat = function(player_name, feat) end
skyblock.levels[level].on_placenode = function(pos, newnode, placer, oldnode) end
skyblock.levels[level].on_dignode = function(pos, oldnode, digger) end
skyblock.levels[level].on_item_eat = function(player_name, itemstack) end
skyblock.levels[level].on_craft = function(player_name, itemstack) end
-- Reward feats
skyblock.levels[level].reward_feat = function(player_name, feat)
return skyblock.levels.reward_feat(level, player_name, feat)
end

-- Track node placement
skyblock.levels[level].on_placenode = function(pos, newnode, placer, oldnode)
skyblock.levels.on_placenode(level, pos, newnode, placer, oldnode)
end

-- Track node digging
skyblock.levels[level].on_dignode = function(pos, oldnode, digger)
skyblock.levels.on_dignode(level, pos, oldnode, digger)
end

-- track eating feats
skyblock.levels[level].on_item_eat = function(player_name, itemstack)
skyblock.levels.on_item_eat(level, player_name, itemstack)
end

-- track crafting feats
skyblock.levels[level].on_craft = function(player_name, itemstack)
skyblock.levels.on_craft(level, player_name, itemstack)
end

-- track hoe use
skyblock.levels[level].hoe_on_use = function(player_name, pointed_thing, wieldeditem)
skyblock.levels.hoe_on_use(level, player_name, pointed_thing, wieldeditem)
end

skyblock.levels[level].bucket_on_use = function(player_name, pointed_thing) end
skyblock.levels[level].bucket_water_on_use = function(player_name, pointed_thing) end
skyblock.levels[level].bucket_lava_on_use = function(player_name, pointed_thing) end
skyblock.levels[level].bucket_lava_on_use = function(player_name, pointed_thing) end
62 changes: 62 additions & 0 deletions skyblock_levels/skyblock.levels.5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
--[[
Skyblock for Minetest
Copyright (c) 2015 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-skyblock
License: GPLv3
]]--

local level = 5

--
-- PUBLIC FUNCTIONS
--

skyblock.levels[level] = {}

-- feats
skyblock.levels[level].feats = {}

-- init level
skyblock.levels[level].init = function(player_name)
local privs = core.get_player_privs(player_name)
privs['fly'] = true
privs['fast'] = true
core.set_player_privs(player_name, privs)
minetest.chat_send_player(player_name, 'You can now use FLY and FAST !')
end

-- get level information
skyblock.levels[level].get_info = function(player_name)
local info = {
level=level,
total=1,
count=0,
player_name=player_name,
infotext='',
formspec = '',
formspec_quest = '',
}

local text = 'label[0,0.5; THE END]'
..'label[0,1.0; I hope you enjoyed your journey, and you]'
..'label[0,1.5; are welcome to stay and keep building]'
..'label[0,2.0; your new sky world.]'

info.formspec = skyblock.levels.get_inventory_formspec(level,info.player_name,true)..text
info.formspec_quest = skyblock.levels.get_inventory_formspec(level,info.player_name)..text
info.infotext = 'THE END! for '.. player_name ..' ... or is it ...'
return info
end

-- no feat tracking
skyblock.levels[level].reward_feat = function(player_name, feat) end
skyblock.levels[level].on_placenode = function(pos, newnode, placer, oldnode) end
skyblock.levels[level].on_dignode = function(pos, oldnode, digger) end
skyblock.levels[level].on_item_eat = function(player_name, itemstack) end
skyblock.levels[level].on_craft = function(player_name, itemstack) end
skyblock.levels[level].bucket_on_use = function(player_name, pointed_thing) end
skyblock.levels[level].bucket_water_on_use = function(player_name, pointed_thing) end
skyblock.levels[level].bucket_lava_on_use = function(player_name, pointed_thing) end

0 comments on commit 5f5bd8b

Please sign in to comment.