Skip to content

Commit

Permalink
Fix many warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Panquesito7 committed Jun 21, 2020
1 parent b9b3bfe commit ea89040
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 132 deletions.
6 changes: 3 additions & 3 deletions skyblock/register_misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ minetest.register_on_generated(function(minp, maxp, seed)

-- add cloud floor
local cloud_y = skyblock.world_bottom-2
if minp.y<=cloud_y and maxp.y>=cloud_y then
if minp.y<=cloud_y and maxp.y>=cloud_y then
for x=minp.x,maxp.x do
for z=minp.z,maxp.z do
data[area:index(x,cloud_y,z)] = id_cloud
Expand All @@ -100,7 +100,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
end

-- add starting blocks
--[[
local start_pos_list = skyblock.get_start_positions_in_mapchunk(minp, maxp)
Expand All @@ -115,7 +115,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
vm:write_to_map(data)
-- vm:update_liquids()
data = nil
end)
end)


-- no placing low nodes
Expand Down
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 = 15,
can_dig = function(pos, player)
return false
end,
Expand Down
18 changes: 9 additions & 9 deletions skyblock/skyblock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ end
function skyblock.spawn_player(player)
local player_name = player:get_player_name()
skyblock.log('skyblock.spawn_player() '..player_name)

-- find the player spawn point
local spawn = skyblock.get_spawn(player_name)
if spawn == nil then
spawn = skyblock.get_next_spawn()
skyblock.set_spawn(player_name,spawn)
end

-- add the start block and teleport the player
skyblock.make_spawn_blocks(spawn,player_name)
player:set_pos({x=spawn.x,y=spawn.y+6,z=spawn.z})
Expand All @@ -150,10 +150,10 @@ end
-- load schem
local schempath = minetest.get_modpath(minetest.get_current_modname())..'/schems'
function skyblock.load_schem(origin, filename)
local file, err = io.open(schempath..'/'..filename, 'rb')
local file,_ = io.open(schempath..'/'..filename, 'rb')
local value = file:read('*a')
file:close()

local nodes = minetest.deserialize(value)
if not nodes then return nil end

Expand Down Expand Up @@ -221,7 +221,7 @@ local function sindex(y, x) -- returns the value at (x, y) in a spiral that star
return (2*l-1)^2+4*l+2*l*sn(x+y)+sn(y^2-x^2)*(l-(av(y)==l and sn(y)*x or sn(x)*y)) -- OH GOD WHAT
end
local function spiralt(side)
local ret, id, start, stop = {}, 0, math.floor((-side+1)/2), math.floor((side-1)/2)
local ret,_ , start, stop = {}, 0, math.floor((-side+1)/2), math.floor((side-1)/2)
for i = 1, side do
for j = 1, side do
local id = side^2 - sindex(stop - i + 1,start + j - 1)
Expand Down Expand Up @@ -284,7 +284,7 @@ local function load_start_positions()
io.close(output)
input = io.open(filename..'.start_positions', 'r')
end

-- read start positions
skyblock.log('read start positions')
while true do
Expand All @@ -303,21 +303,21 @@ load_start_positions() -- run it now
-- load the last start position from disk
local function load_last_start_id()
local input = io.open(filename..'.last_start_id', 'r')

-- create last_start_id file if needed
if not input then
local output = io.open(filename..'.last_start_id', 'w')
output:write(last_start_id)
io.close(output)
input = io.open(filename..'.last_start_id', 'r')
end

-- read last start id
last_start_id = input:read('*n')
if last_start_id == nil then
last_start_id = 0
end
io.close(input)

end
load_last_start_id() -- run it now
1 change: 0 additions & 1 deletion skyblock_levels/register_abm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ minetest.register_abm({

if minetest.get_node(pos).name == 'air' then
local rand = math.random(1,8);
local node
if rand==1 then
node = 'default:junglegrass'
elseif rand==2 then
Expand Down
2 changes: 1 addition & 1 deletion skyblock_levels/register_command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ minetest.register_chatcommand('level', {
privs = {level = true},
params = "<player_name> <level>",
func = function(name, param)
local found, _, player_name, level = param:find("^([^%s]+)%s+(.+)$")
local _, _, player_name, level = param:find("^([^%s]+)%s+(.+)$")
if not player_name then
player_name = name
end
Expand Down
6 changes: 3 additions & 3 deletions skyblock_levels/register_misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ minetest.register_on_dieplayer(function(player)
else
skyblock.feats.reset_level(player_name)
end

-- back to start of this level

end)

-- player receive fields
Expand All @@ -59,6 +59,6 @@ if minetest.get_modpath('unified_inventory') then
tooltip = 'Skyblock Quests',
action = function(player)
skyblock.feats.update(player:get_player_name())
end,
end,
})
end
4 changes: 2 additions & 2 deletions skyblock_levels/skyblock.craft_guide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ skyblock.craft_guide.image_button_link = function(stack_string)
if group_placeholder[stack_string] then
stack_string = group_placeholder[stack_string]
group = 'G'
end
end
local stack = ItemStack(stack_string)
local new_node_name = stack_string
if( stack and stack:get_name()) then
Expand Down Expand Up @@ -133,7 +133,7 @@ skyblock.craft_guide.get_formspec = function(node_name, fields)
if outstack and outstack:get_count() and outstack:get_count()>1 then
formspec = formspec..'label[4.5,3;'..tostring(outstack:get_count())..']'
end

if receipe.type=='normal' then
receipe.type = 'craft'
elseif receipe.type=='cooking' then
Expand Down
46 changes: 25 additions & 21 deletions skyblock_levels/skyblock.feats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ function skyblock.feats.update(player_name)
end
end
minetest.log('action', player_name..' completed level '..level)

skyblock.feats.add(0,info.player_name,'level')
skyblock.levels[level+1].init(info.player_name)
info = skyblock.levels[level+1].get_info(info.player_name)
end

-- update formspecs
local player = minetest.get_player_by_name(player_name)
if player then
Expand Down Expand Up @@ -227,11 +227,11 @@ for _,v in ipairs({'doors:door_wood','doors:door_glass','doors:door_steel','door
on_place(v,1);
end
for _,v in ipairs({
'default:cactus',
'farming:seed_wheat',
'farming:seed_cotton',
'default:cactus',
'farming:seed_wheat',
'farming:seed_cotton',
'default:sign_wall',
'default:sign_wall_wood',
'default:sign_wall_wood',
'default:apple'}) do
on_place(v,0);
end
Expand Down Expand Up @@ -272,28 +272,32 @@ local function bucket_on_use(itemstack, user, pointed_thing)
if pointed_thing.type ~= 'node' then
return
end

-- Check if protected
if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
return
end

-- Get the Node and Registered Item
local n = minetest.get_node_or_nil(pointed_thing.under)
local ndef
if n then
ndef = minetest.registered_items[n.name]
end
-- Call on_rightclick if the pointed node defines it
if ndef and ndef.on_rightclick and user and not user:get_player_control().sneak then
return ndef.on_rightclick(pointed_thing.under, n, user, itemstack) or itemstack
end
-- Check if pointing to a liquid source
local ndef
if n then
ndef = minetest.registered_items[n.name]
end

-- Call on_rightclick if the pointed node defines it
if ndef and ndef.on_rightclick and user and not user:get_player_control().sneak then
return ndef.on_rightclick(pointed_thing.under, n, user, itemstack) or itemstack
end

-- Check if pointing to a liquid source
local liquid = bucket.liquids[n.name]
if liquid ~= nil and liquid.source == n.name and liquid.itemname ~= nil then

-- begin track bucket feats
skyblock.feats.bucket_on_use(itemstack, user, pointed_thing)
-- end track bucket feats

minetest.env:add_node(pointed_thing.under, {name='air'})
return {name=liquid.itemname}
end
Expand Down Expand Up @@ -323,7 +327,7 @@ local function bucket_water_on_use(itemstack, user, pointed_thing)
if ndef and ndef.on_rightclick and user and not user:get_player_control().sneak then
return ndef.on_rightclick(pointed_thing.under, n, user, itemstack) or itemstack
end
-- Check if pointing to a liquid
-- Check if pointing to a liquid
if bucket.liquids[n.name] == nil then
-- Not a liquid

Expand All @@ -333,8 +337,8 @@ local function bucket_water_on_use(itemstack, user, pointed_thing)
local range = tonumber(minetest.settings:get("bucket_use_range")) or false -- how far from spawn you can use water
local pos = pointed_thing.under
if range and (spawn==nil
or (pos.x-spawn.x > range or pos.x-spawn.x < range*-1)
or (pos.y-spawn.y > range/2 or pos.y-spawn.y < range*-1/2)
or (pos.x-spawn.x > range or pos.x-spawn.x < range*-1)
or (pos.y-spawn.y > range/2 or pos.y-spawn.y < range*-1/2)
or (pos.z-spawn.z > range or pos.z-spawn.z < range*-1)) then
minetest.chat_send_player(player_name, 'Cannot use bucket so far from your home.')
return
Expand Down Expand Up @@ -441,7 +445,7 @@ function skyblock.feats.save(data,player_name)
if not file then
mkdir(filepath)
file = io.open(filepath..'/'..player_name, 'wb')
if not file then
if not file then
skyblock.log('cannot open feat file for writing "'..filepath..'/'..player_name..'"')
end
end
Expand Down
46 changes: 23 additions & 23 deletions skyblock_levels/skyblock.levels.1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,47 @@ skyblock.levels[level].feats = {
{
name = 'dig 10 Dirt',
hint = nil,
feat = 'dig_dirt',
count = 10,
feat = 'dig_dirt',
count = 10,
reward = 'default:stick',
dignode = {'default:dirt', 'default:dirt_with_grass', 'default:dirt_with_grass_footsteps'},
},
{
name = 'place 10 Dirt',
hint = 'default:dirt',
feat = 'place_dirt',
count = 10,
feat = 'place_dirt',
count = 10,
reward = 'default:leaves 6',
placenode = {'default:dirt'},
},
{
name = 'craft a Sapling and grow a Tree',
hint = 'default:sapling',
feat = 'place_sapling',
count = 1,
feat = 'place_sapling',
count = 1,
reward = 'default:tree',
placenode = {'default:sapling'},
},
{
name = 'craft an Axe and dig 16 Tree',
hint = 'default:axe_wood',
feat = 'dig_tree',
count = 16,
feat = 'dig_tree',
count = 16,
reward = 'default:cobble 8',
dignode = {'default:tree'},
},
{
name = 'craft and place a Furnace',
hint = 'default:furnace',
feat = 'place_furnace',
count = 1,
feat = 'place_furnace',
count = 1,
reward = 'default:axe_steel',
placenode = {'default:furnace'},
},
{
name = 'craft and place 50 Cobblestone',
hint = 'default:cobble',
feat = 'place_cobble',
feat = 'place_cobble',
count = 50,
reward = 'stairs:stair_cobble 4',
placenode = {'default:cobble'},
Expand All @@ -87,7 +87,7 @@ skyblock.levels[level].feats = {
name = 'craft and place a Chest',
hint = 'default:chest',
feat = 'place_chest',
count = 1,
count = 1,
reward = 'default:papyrus 5',
placenode = {'default:chest'},
},
Expand Down Expand Up @@ -131,13 +131,13 @@ end

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

Expand All @@ -146,10 +146,10 @@ skyblock.levels[level].get_info = function(player_name)
..'label[0,1.0;We can no longer live on the surface.]'
..'label[0,1.5;Can you help us rebuild in the sky?]'
..'label[0,2.0;Complete the quests to receive great rewards!]'

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

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)
Expand All @@ -159,7 +159,7 @@ skyblock.levels[level].get_info = function(player_name)
end

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

return info
end

Expand Down Expand Up @@ -194,7 +194,7 @@ skyblock.levels[level].bucket_on_use = function(player_name, pointed_thing)
end

-- track bucket water feats
skyblock.levels[level].bucket_water_on_use = function(player_name, pointed_thing)
skyblock.levels[level].bucket_water_on_use = function(player_name, pointed_thing)
skyblock.levels.bucket_water_on_use(level, player_name, pointed_thing)
end

Expand Down
Loading

0 comments on commit ea89040

Please sign in to comment.