Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add compatability with reworked moreblocks/stairplus #91

Merged
merged 1 commit into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<script src="js/components/group-info.js"></script>
<script src="js/components/cnc-list.js"></script>
<script src="js/components/moreblocks-list.js"></script>
<script src="js/components/stairsplus-list.js"></script>
<script src="js/components/recipe-info.js"></script>
<script src="js/components/abm-list.js"></script>
<script src="js/components/abm-info.js"></script>
Expand Down
3 changes: 3 additions & 0 deletions app/js/components/item-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ Vue.component("item-detail", {
<a v-if="item.circular_saw" class="btn btn-xs btn-secondary" href="#/moreblocks">
<i class="fa fa-th-large"></i> Circular-saw
</a>
<a v-if="item.new_circular_saw" class="btn btn-xs btn-secondary" href="#/stairsplus">
<i class="fa fa-th-large"></i> Circular-saw
</a>
<a v-if="item.cnc" class="btn btn-xs btn-secondary" href="#/cnc">
<i class="fa fa-th"></i> Technic CNC
</a>
Expand Down
8 changes: 8 additions & 0 deletions app/js/components/nav-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Vue.component("nav-bar", {
has_moreblocks: function(){
return mtinfo.items["moreblocks:circular_saw"];
},
has_stairsplus: function(){
return mtinfo.items["stairsplus:circular_saw"];
},
has_technic_cnc: function(){
return mtinfo.items["technic:cnc"];
}
Expand Down Expand Up @@ -36,6 +39,11 @@ Vue.component("nav-bar", {
<router-link to="/moreblocks" class="nav-link">
<i class="fa fa-th-large"></i> Moreblocks
</router-link>
</li>
<li v-if="has_stairsplus" class="nav-item">
<router-link to="/stairsplus" class="nav-link">
<i class="fa fa-th-large"></i> Stairs+
</router-link>
</li>
<li v-if="has_technic_cnc" class="nav-item">
<router-link to="/cnc" class="nav-link">
Expand Down
47 changes: 47 additions & 0 deletions app/js/components/stairsplus-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

Vue.component("stairsplus-list", {
data: function(){
return {
page: +this.$route.query.page || 1
};
},
watch: {
$route: function(){
this.page = +this.$route.query.page || 1;
}
},
computed: {
list: function(){
return Object.keys(mtinfo.items)
.map(name => mtinfo.items[name])
.filter(item => item.new_circular_saw);
}
},
template:`
<div>
<h3>Circular saw compatible nodes</h3>
<paged-table v-bind:list="list" v-bind:page="page">
<template v-slot:header>
<th>Mod</th>
<th>Type</th>
<th>Image</th>
<th>Nodename</th>
</template>
<template v-slot:row="{ item }">
<td>{{ item.name.substring(0, item.name.indexOf(":")) }}</td>
<td>
<span class="badge badge-secondary">{{ item.type }}</span>
</td>
<td>
<item-preview :name="item.name" size="32"/>
</td>
<td>
<router-link :to="'/items/' + item.name">
{{ item.name }}
</router-link>
</td>
</template>
</paged-table>
</div>
`
});
3 changes: 3 additions & 0 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const router = new VueRouter({
}, {
path: "/moreblocks",
component: { template: `<moreblocks-list/>` }
}, {
path: "/stairsplus",
component: { template: `<stairsplus-list/>` }
}, {
path: "/cnc",
component: { template: `<cnc-list/>` }
Expand Down
11 changes: 8 additions & 3 deletions items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ local item_mapped_keys = {
"mtinfo"
}

local has_old_moreblocks = minetest.get_modpath("moreblocks") and minetest.global_exists("circular_saw")
local has_new_stairsplus = minetest.get_modpath("stairsplus") and stairsplus.api
local has_technic_cnc = minetest.get_modpath("technic_cnc")

function mtinfo.export_items()
local data = {}
local has_moreblocks = minetest.get_modpath("moreblocks")
local has_technic_cnc = minetest.get_modpath("technic_cnc")

mtinfo.map_list(data, minetest.registered_items, item_mapped_keys, function(def)
if def.groups and def.groups.not_in_creative_inventory then
Expand All @@ -44,10 +46,13 @@ function mtinfo.export_items()
return true
end
end, function(name, item, def)
if has_moreblocks and circular_saw.known_nodes[name] then
if has_old_moreblocks and circular_saw.known_nodes[name] then
-- moreblocks enabled
item.circular_saw = true
end
if has_new_stairsplus and stairsplus.api.get_shapes_hash(name) then
item.new_circular_saw = true
end
if has_technic_cnc and minetest.registered_items[name .. "_technic_cnc_slope"] then
-- partial or full cnc support
item.cnc = true
Expand Down
2 changes: 1 addition & 1 deletion mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = mtinfo
optional_depends = technic, moreblocks
optional_depends = technic, moreblocks, stairsplus
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Generates a static info-page about the world, stats include:
## Usage

* Install the mod
* Enable the setting in minetest.conf (`mtinfo.enabled = true`)
* Start the world
* Open the generated `index.html` in the world-folder `mtinfo` with a web-browser

Expand Down