Skip to content
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
26 changes: 12 additions & 14 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
name: luacheck

on: [push, pull_request]

on:
push:
paths:
- "**.lua"
pull_request:
paths:
- "**.lua"
jobs:
build:

luacheck:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v2.3.4
- 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 ./
- name: Checkout
uses: actions/checkout@main
- name: Luacheck
uses: lunarmodules/luacheck@master
45 changes: 45 additions & 0 deletions .github/workflows/oxipng.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Optimize PNGs

on:
pull_request:
branches: [main, master]
paths:
- "**.png"

jobs:
optimize-pngs:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@main
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- uses: actions/cache@main
with:
path: ~/.cargo/bin/
key: ${{ runner.os }}-cargo-oxipng

- run: which oxipng || cargo install oxipng

- name: Optimize PNGs
run: oxipng -z --nc -p -s -r -o max .

- name: Commit
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "[ci] Optimize PNGs"
git push origin HEAD:${{ github.head_ref }}
else
echo "No files modified."
fi
4 changes: 2 additions & 2 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ read_globals = {
-- mod deps
"default", "digilines", "pipeworks", "technic",

-- Minetest
"minetest",
-- Luanti
"minetest", "core",
"vector", "ItemStack",
"dump"

Expand Down
385 changes: 385 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Space Cannon

[![ContentDB](https://content.luanti.org/packages/mt-mods/spacecannon/shields/downloads/)](https://content.luanti.org/packages/mt-mods/spacecannon/)
[![luacheck](https://github.com/mt-mods/spacecannon/actions/workflows/luacheck.yml/badge.svg)](https://github.com/mt-mods/spacecannon/actions/workflows/luacheck.yml)

Adds five scifi/space cannons with various projectile-speeds and explosion-strengths.
The cannons need HV-Power from a `technic` network and can be controlled via formspec/hand, mesecons or digilines.
They also need to charge first, which can take a couple of seconds depending on cannon-type.

The projectile detonates on impact but only in _non-protected_ areas!

## Screenshots

![Screenshot 1](/screenshot_1.png)
![Screenshot 2](/screenshot_2.png)
![Screenshot 3](/screenshot_3.png)

## Dependencies

- Luanti/Minetest v0.4.16
- [`technic`](https://github.com/minetest-mods/technic)

Supports:

- [`mesecons`](https://github.com/minetest-mods/mesecons)
- [`digilines`](https://github.com/minetest-mods/digilines)

## Mesecons

An "on" signal triggers a fire-action.

## Digilines

Fire a cannon:

```lua
if event.type == "program" then
digiline_send("cannon", { command = "fire", verbose = false })
end
```

Example response from a "get" request:

```lua
{
type = "digiline",
channel = "c7",
msg = {
HV_EU_input = 0,
HV_EU_demand = 0,
dir = {
y = 0,
x = 0,
z = 1
},
powerstorage = 10000,
ready = true,
origin = "c7",
name = "spacecannon:cannon_green",
pos = {
y = 10,
x = -64,
z = -53
}
}
}
```

The "fire" request can specify an optional "verbose" flag. If this flag
evaluates to true, then the following example response will be sent back.
Note that if you have a large number of cannons, you will likely want
to disable responses. N cannons firing and generating responses will
cause N^2 messages to be processed, as each cannon receives the fire response
from all of its peers. If N > 20, your LUAC will overheat. N > 900, and your
server admin will want to have a chat with you.

```lua
{
type = "digiline",
channel = "c2",
msg = {
pos = {
y = 10,
x = -59,
z = -53
},
origin = "c2",
success = true
}
}
```

## Api

Modify the ability to shoot depending on position or playername:

```lua
spacecannon.can_shoot = function(pos, playername)
return true
end
```

## Contributors

- @BuckarooBanzay
- @dennisjenkins75
- @kiedtl

## License

Code: [MIT](/LICENSE#Code)
Media: [CC-BY-SA 3.0](/LICENSE#Media)

## Attributions

- [sounds/spacecannon_shoot.ogg](https://freesound.org/people/jonccox/sounds/175261/)
18 changes: 10 additions & 8 deletions ammo.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
minetest.register_craftitem("spacecannon:railgun_slug", {
description = "Railgun slug",
inventory_image = "spacecannon_railgun_slug.png",
stack_max = 13,
local S = core.get_translator(core.get_current_modname())

core.register_craftitem("spacecannon:railgun_slug", {
description = S("Railgun slug"),
inventory_image = "spacecannon_railgun_slug.png",
stack_max = 13,
})

minetest.register_craft({
core.register_craft({
output = "spacecannon:railgun_slug 2",
recipe = {
{ "", "technic:uranium0_ingot", ""},
{"basic_materials:carbon_steel_bar", "technic:stainless_steel_ingot", "basic_materials:carbon_steel_bar"},
{ "technic:stainless_steel_ingot", "technic:stainless_steel_ingot", "technic:stainless_steel_ingot"}
{ "", "technic:uranium0_ingot", "" },
{ "basic_materials:carbon_steel_bar", "technic:stainless_steel_ingot", "basic_materials:carbon_steel_bar" },
{ "technic:stainless_steel_ingot", "technic:stainless_steel_ingot", "technic:stainless_steel_ingot" },
},
})
Loading