Skip to content

Commit

Permalink
fix bugs in the building_sign and the luacheck config
Browse files Browse the repository at this point in the history
  • Loading branch information
theFox6 committed Oct 12, 2020
1 parent b80d714 commit 6c8c436
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 14 deletions.
17 changes: 15 additions & 2 deletions .luacheck_tidy
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
allow_defined_top = true
max_line_length = 240

read_globals = {
-- minetest
"AreaStore",
"dump",
"minetest",
"vector",
"VoxelManip",
"VoxelArea",
"ItemStack",
-- mods
"default", "doors",
}

globals = {
-- modpack mods
"building_sign",
"working_villages",
-- submodule mods
"modutil",
"LuaVenusCompiler"
}

exclude_files = {
"working_villagers/modutil/VenusParser/testout"
-- bad syntax is tested here
"working_villagers/modutil/LuaVenusCompiler/testout"
}
44 changes: 34 additions & 10 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
allow_defined_top = true
max_line_length = 240

ignore = {
--setting a read-only field of a global variable
--"122",
--unused globals
--"131",
--setting and acessing undefined fields of global variables
--"14.",
--unused variables and arguments
"21.",
--setting and never acessing variables
"23.",
--whitespace
"61.",
--TODO: check which ones these are
"621",
"631"
}

read_globals = {
-- minetest
"AreaStore",
"dump",
"minetest",
"vector",
"VoxelManip",
"VoxelArea",
"ItemStack",
-- mods
"default", "doors",
}

ignore = {
"211",
"212",
"213",
"611",
"612",
"621",
"631"
globals = {
-- modpack mods
"building_sign",
"working_villages",
-- submodule mods
"modutil",
"LuaVenusCompiler"
}

allow_defined_top = true

exclude_files = {
-- development files
"working_villagers/development",
"working_villagers/modutil/VenusParser/testout"
-- bad syntax is tested here
"working_villagers/modutil/LuaVenusCompiler/testout"
}
43 changes: 43 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,49 @@ for developing jobs, villagers, etc. read [api.md](api.MD)
![Screenshot 3](screenshot.3.png)
![Screenshot 4](screenshot.4.png)

## Submodules
Currently working_villages only has the modutil portable submodule.
It is needed to be able to run without the modutil mod.
This means you can either download the modutil mod and enable it or get the submodule:

When cloning add "--recursive" option to clone including all submodules:
```
git clone --recursive https://github.com/theFox6/working_villages.git
```

If one of the submodule folders is empty use:
```
git submodule update --init
```
This will clone all missing submodules.

## Dependencies
working_villages needs modutil to load utilities it can also use modutil portable though
doors can be used by the villagers that's why there is a dependency

## missing modutil
If you clone the mod you either need to **install and activate the modutil mod** or you need to **[clone it recursively](#cloning)**.
If modutil is not present you will get the following error:
`.minetest/mods/working_villages/modutil/portable.lua: No such file or directory`

## cloning
When cloning first add "--recursive" option to clone including all submodules:
```
git clone --recursive https://github.com/theFox6/working_villages.git
```
else the submodule folders will be empty.

If one of the submodule folders is empty use:
```
git submodule update --init
```
This will clone all missing submodules.

To pull all changes in the repo including changes in the submodules use:
```
git pull --recurse-submodules
```

## License
* working_villages by theFox6 is avalible under the MIT License

Expand Down
10 changes: 10 additions & 0 deletions building_sign/areas.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
building_sign.require("building_store","venus")

local areas = {}
local cache = AreaStore()

function areas.to_string(area)
return ("%s %s"):format(minetest.pos_to_string(area[1]),minetest.pos_to_string(area[2]))
end

--TODO: redo this workaround
function areas.is_within(area, pos)
local aid = cache:insert_area(area[1], area[2], tostring(area))
if cache:get_areas_for_pos(pos)[aid] then
return true
end
return false
end

function areas.check_existing(pos)
for poshash,building in pairs(building_sign.building_store) do
if areas.is_within(building.area, pos) then
Expand Down
5 changes: 4 additions & 1 deletion building_sign/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ minetest.register_node("building_sign:building_marker", {
local meta = minetest.get_meta(pos)
local building = building_sign.areas.check_existing(pos)
if building then
--TODO: load from area
--TODO: load everything from area
if building.build_pos then
meta:set_string("build_pos",minetest.pos_to_string(building.build_pos))
end
else
meta:set_string("configured","false")
meta:set_string("state","unplanned")
Expand Down
2 changes: 2 additions & 0 deletions building_sign/schematics.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TODO: cleanup

local DEFAULT_NODE = building_sign.DEFAULT_NODE

function building_sign.get_registered_nodename(name)
if name:find("doors:") then
name = name:gsub("_[b]_[12]", "")
Expand Down
2 changes: 1 addition & 1 deletion building_sign/sign_meta.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function building:load_build_pos(meta)
function building_sign.building:load_build_pos(meta)
local pos = minetest.string_to_pos(meta:get_string("build_pos"))
if pos then
self.build_pos = pos
Expand Down

0 comments on commit 6c8c436

Please sign in to comment.