Skip to content

Commit

Permalink
Merge pull request #83 from Panquesito7/github_actions
Browse files Browse the repository at this point in the history
Add GitHub workflow and `.luacheckrc` file
  • Loading branch information
cornernote committed Jul 15, 2020
2 parents da34e76 + 7626037 commit 65cc7d6
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 132 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
on: [push, pull_request]
name: build
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""
20 changes: 20 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
unused_args = false
allow_defined_top = true
max_line_length = 999

globals = {
"skyblock", "minetest",
}

read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}},

"VoxelArea", "unified_inventory",
"core", "ItemStack", "default",

"bucket",
}

files["skyblock/register_misc.lua"].ignore = { "vm", "area", "data" }
files["skyblock/skyblock.lua"].ignore = { "filename", "t" }
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Skyblock for Minetest

[![Build status](https://github.com/cornernote/minetest-skyblock/workflows/build/badge.svg)](https://github.com/cornernote/minetest-skyblock/actions)
[![home](https://img.shields.io/badge/skyblock-home-blue.svg?style=flat-square)](https://cornernote.github.io/minetest-skyblock/)
[![chat](https://img.shields.io/badge/gitter-join%20chat-blue.svg?style=flat-square)](https://gitter.im/cornernote/minetest-skyblock)
[![download](https://img.shields.io/github/tag/cornernote/minetest-skyblock.svg?style=flat-square&label=release)](https://github.com/cornernote/minetest-skyblock/releases)
Expand Down
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
Loading

0 comments on commit 65cc7d6

Please sign in to comment.