mirror of
https://git.minetest.org/BuckarooBanzay/digibuilder.git
synced 2024-12-12 00:43:20 +01:00
basic skeleton
This commit is contained in:
commit
4040119fba
17
.github/workflows/luacheck.yml
vendored
Normal file
17
.github/workflows/luacheck.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: luacheck
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: apt
|
||||
run: sudo apt-get install -y luarocks
|
||||
- name: luacheck install
|
||||
run: luarocks install --local luacheck
|
||||
- name: luacheck run
|
||||
run: $HOME/.luarocks/bin/luacheck ./
|
20
.luacheckrc
Normal file
20
.luacheckrc
Normal file
@ -0,0 +1,20 @@
|
||||
globals = {
|
||||
"digibuilder"
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
-- Stdlib
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
"VoxelManip",
|
||||
|
||||
-- Minetest
|
||||
"minetest",
|
||||
"vector", "ItemStack",
|
||||
"dump", "VoxelArea",
|
||||
|
||||
-- Deps
|
||||
"digilines",
|
||||
"mesecons",
|
||||
"default"
|
||||
}
|
0
common.lua
Normal file
0
common.lua
Normal file
33
digiline.lua
Normal file
33
digiline.lua
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
digibuilder.digiline_effector = function(pos, _, channel, msg)
|
||||
|
||||
local msgt = type(msg)
|
||||
if msgt ~= "table" then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local set_channel = meta:get_string("channel")
|
||||
if set_channel == "" then
|
||||
-- backward compatibility with old static channel
|
||||
set_channel = "jumpdrive"
|
||||
end
|
||||
|
||||
if channel ~= set_channel then
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
digibuilder.digiline_rules = {
|
||||
-- digilines.rules.default
|
||||
{x= 1,y= 0,z= 0},{x=-1,y= 0,z= 0}, -- along x beside
|
||||
{x= 0,y= 0,z= 1},{x= 0,y= 0,z=-1}, -- along z beside
|
||||
{x= 1,y= 1,z= 0},{x=-1,y= 1,z= 0}, -- 1 node above along x diagonal
|
||||
{x= 0,y= 1,z= 1},{x= 0,y= 1,z=-1}, -- 1 node above along z diagonal
|
||||
{x= 1,y=-1,z= 0},{x=-1,y=-1,z= 0}, -- 1 node below along x diagonal
|
||||
{x= 0,y=-1,z= 1},{x= 0,y=-1,z=-1}, -- 1 node below along z diagonal
|
||||
{x= 0,y= 1,z= 0},{x= 0,y=-1,z= 0}, -- along y above and below
|
||||
}
|
21
formspec.lua
Normal file
21
formspec.lua
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
function digibuilder.update_formspec(meta)
|
||||
local formspec =
|
||||
"size[8,9;]" ..
|
||||
|
||||
-- main inventory
|
||||
"list[context;main;0,3.25;8,1;]" ..
|
||||
|
||||
-- player inventory
|
||||
"list[current_player;main;0,4.5;8,4;]" ..
|
||||
|
||||
-- digiline channel
|
||||
"field[4.3,9;3.2,1;digiline_channel;Digiline channel;" .. (meta:get_string("channel") or "") .. "]" ..
|
||||
"button_exit[7,8.7;1,1;set_digiline_channel;Set]" ..
|
||||
|
||||
-- listring stuff
|
||||
"listring[context;main]" ..
|
||||
"listring[current_player;main]"
|
||||
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
9
init.lua
Normal file
9
init.lua
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
digibuilder = {}
|
||||
|
||||
local MP = minetest.get_modpath("digibuilder")
|
||||
|
||||
-- common functions
|
||||
dofile(MP.."/common.lua")
|
||||
dofile(MP.."/digiline.lua")
|
||||
dofile(MP.."/node.lua")
|
14
license.txt
Normal file
14
license.txt
Normal file
@ -0,0 +1,14 @@
|
||||
Copyright (C) 2020 / Buckaroo Banzay
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2
mod.conf
Normal file
2
mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = digibuilder
|
||||
depends = digilines, default
|
126
node.lua
Normal file
126
node.lua
Normal file
@ -0,0 +1,126 @@
|
||||
|
||||
|
||||
minetest.register_node("digibuilder:digibuilder", {
|
||||
description = "Digibuilder",
|
||||
|
||||
tiles = {"digibuilder.png"},
|
||||
|
||||
tube = {
|
||||
insert_object = function(pos, _, stack, _)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, _, stack, _)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
stack = stack:peek_item(1)
|
||||
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {bottom = 1}
|
||||
},
|
||||
|
||||
light_source = 13,
|
||||
groups = {
|
||||
cracky = 3,
|
||||
oddly_breakable_by_hand = 3,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1
|
||||
},
|
||||
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
|
||||
digiline = {
|
||||
receptor = {
|
||||
rules = digibuilder.digiline_rules,
|
||||
action = function() end
|
||||
},
|
||||
effector = {
|
||||
rules = digibuilder.digiline_rules,
|
||||
action = digibuilder.digiline_effector
|
||||
}
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
-- default digiline channel
|
||||
meta:set_string("channel", "digibuilder")
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
-- start nodetimer if not started
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(2)
|
||||
end
|
||||
|
||||
-- inventory
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
|
||||
-- formspec
|
||||
digibuilder.update_formspec(meta)
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
local name = player:get_player_name()
|
||||
|
||||
return inv:is_empty("main") and
|
||||
inv:is_empty("upgrade") and
|
||||
not minetest.is_protected(pos, name)
|
||||
end,
|
||||
|
||||
on_timer = function()--pos, elapsed)
|
||||
|
||||
-- restart timer
|
||||
return true
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, _, fields, sender)
|
||||
--local meta = minetest.get_meta(pos);
|
||||
|
||||
if not sender then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.is_protected(pos, sender:get_player_name()) then
|
||||
-- not allowed
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if fields.save then
|
||||
print("save")
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
-- inventory protection
|
||||
allow_metadata_inventory_take = function(pos, _, _, stack, player)
|
||||
if player and player:is_player() and minetest.is_protected(pos, player:get_player_name()) then
|
||||
-- protected
|
||||
return 0
|
||||
end
|
||||
|
||||
return stack:get_count()
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = function(pos, _, _, stack, player)
|
||||
if player and player:is_player() and minetest.is_protected(pos, player:get_player_name()) then
|
||||
-- protected
|
||||
return 0
|
||||
end
|
||||
|
||||
return stack:get_count()
|
||||
end,
|
||||
|
||||
on_punch = function()--pos, node, puncher)
|
||||
--TODO show marker on punch
|
||||
end
|
||||
})
|
171
readme.md
Normal file
171
readme.md
Normal file
@ -0,0 +1,171 @@
|
||||
Minetest jumpdrive
|
||||
======
|
||||
|
||||
![](https://github.com/mt-mods/jumpdrive/workflows/luacheck/badge.svg)
|
||||
![](https://github.com/mt-mods/jumpdrive/workflows/integration-test/badge.svg)
|
||||
|
||||
|
||||
A simple [Jumpdrive](https://en.wikipedia.org/wiki/Jump_drive) for minetest
|
||||
|
||||
Take your buildings with you on your journey
|
||||
|
||||
* Github: [https://github.com/thomasrudin-mt/jumpdrive](https://github.com/thomasrudin-mt/jumpdrive)
|
||||
* Forum topic: [https://forum.minetest.net/viewtopic.php?f=9&t=20073](https://forum.minetest.net/viewtopic.php?f=9&t=20073)
|
||||
|
||||
# Operation
|
||||
|
||||
* Place a 'jumpdrive:engine' into the center of your creation.
|
||||
* Connect the engine to a technic HV network
|
||||
* Let the engine charge
|
||||
* Choose your target coordinates (should be air or ignore blocks)
|
||||
* Select your cube-radius
|
||||
* Click "show" and check the green (source) and red (target) destination markers if everything is in range
|
||||
* Click "jump"
|
||||
|
||||
# Compatibility
|
||||
|
||||
Optional dependencies:
|
||||
* Mesecon interaction (execute jump on signal)
|
||||
* Technic rechargeable (HV)
|
||||
* Travelnet box (gets rewired after jump)
|
||||
* Elevator (on_place gets called after jump)
|
||||
* Locator (gets removed and added after each jump)
|
||||
* Pipeworks teleport tubes (with a patch to pipeworks)
|
||||
* Beds (thx to @tuedel)
|
||||
* Ropes (thx to @tuedel)
|
||||
* Mission-wand as coordinate bookmark (thx to @SwissalpS)
|
||||
* Areas
|
||||
* Drawers
|
||||
|
||||
# Fuel
|
||||
|
||||
The engine can be connected to a technic HV network or fuelled with power items.
|
||||
Power items are one of the following
|
||||
* `default:mese_crystal_fragment`
|
||||
* `default:mese_crystal`
|
||||
* `default:mese`
|
||||
|
||||
# Energy requirements
|
||||
|
||||
The energy requirements formula looks like this: **10 x radius x distance**
|
||||
|
||||
For example:
|
||||
* Distance: 100 blocks
|
||||
* Radius: 5 blocks
|
||||
* Required energy: 10 x 5 x 100 = 5000
|
||||
|
||||
# Upgrades
|
||||
|
||||
If the `technic` mod is installed the following items can be used in the upgrade slot:
|
||||
* `technic:red_energy_crystal` increases power storage
|
||||
* `technic:green_energy_crystal` increases power storage
|
||||
* `technic:blue_energy_crystal` increases power storage
|
||||
* `technic:control_logic_unit` increases power recharge rate
|
||||
|
||||
# Protection
|
||||
|
||||
The source and destination areas are checked for protection so you can't remove and jump into someone else's buildings.
|
||||
|
||||
|
||||
# Screenshots
|
||||
|
||||
Interface:
|
||||
|
||||
![](screenshots/screenshot_20180507_200309.png?raw=true)
|
||||
|
||||
Example:
|
||||
|
||||
![](screenshots/screenshot_20180507_200203.png?raw=true)
|
||||
|
||||
# Advanced operation
|
||||
|
||||
## Coordinate bookmarking
|
||||
|
||||
You can place empty books into the drive inventory and write the coordinates to it with the "Write to book" button
|
||||
The "Read from book" reads the coordinates from the next book in the inventory
|
||||
|
||||
## Diglines
|
||||
|
||||
* See: [Digilines](doc/digiline.md)
|
||||
|
||||
# Settings
|
||||
|
||||
Settings in minetest.conf:
|
||||
|
||||
* **jumpdrive.max_radius** max radius of the jumpdrive (default: *15*)
|
||||
* **jumpdrive.max_area_radius** max radius of the area jumpdrive (default: *25*)
|
||||
* **jumpdrive.powerstorage** power storage of the drive (default: *1000000*)
|
||||
* **jumpdrive.power_requirement** power requirement for chargin (default: *2500*)
|
||||
|
||||
# Lua api
|
||||
|
||||
## Preflight check
|
||||
|
||||
The preflight check can be overriden to execute additional checks:
|
||||
|
||||
```lua
|
||||
jumpdrive.preflight_check = function(source, destination, radius, player)
|
||||
-- check for height limit, only space travel allowed
|
||||
if destination.y < 1000 then
|
||||
return { success=false, message="Atmospheric travel not allowed!" }
|
||||
end
|
||||
|
||||
-- everything ok
|
||||
return { success=true }
|
||||
end
|
||||
```
|
||||
|
||||
## Fuel calc
|
||||
|
||||
The default fuel calc can be overwritten by a depending mod:
|
||||
|
||||
```lua
|
||||
-- calculates the power requirements for a jump
|
||||
jumpdrive.calculate_power = function(radius, distance, sourcePos, targetPos)
|
||||
return 10 * distance * radius
|
||||
end
|
||||
```
|
||||
|
||||
# Sources
|
||||
|
||||
* jumprive_engine.ogg: https://freesound.org/people/kaboose102/sounds/340257/
|
||||
|
||||
# Contributors
|
||||
|
||||
* @tuedel
|
||||
* @SwissalpS
|
||||
* @Panquesito7
|
||||
* @OgelGames
|
||||
* @S-S-X
|
||||
|
||||
# History
|
||||
|
||||
## Next
|
||||
* optional technic mod
|
||||
* upgrade slots
|
||||
|
||||
## 2.0
|
||||
|
||||
* various fixes and optimizations
|
||||
* Fleetcontroller
|
||||
* Digiline interface
|
||||
* mod.conf (minetest >= 5.0)
|
||||
* Beds,ropes,missions compatibility
|
||||
* calculate_power() override
|
||||
* overlap check
|
||||
* No fuel consumption if creative
|
||||
* Protection checks for source and destination
|
||||
* preflight check with custom override
|
||||
* Settings in minetest.conf
|
||||
* vacuum compatibility (jump into vacuum with air filled vessel)
|
||||
|
||||
## 1.1
|
||||
|
||||
* improved performance
|
||||
* Documentation
|
||||
* Removed complicated cascade function
|
||||
|
||||
## 1.0
|
||||
|
||||
* Initial version
|
||||
* Cascade operation (with issues)
|
Loading…
Reference in New Issue
Block a user