Move cannons config to minetest.conf

Warning: Please update the config, if you dont want griefer!
master
adrido 2022-06-06 10:31:47 +02:00
parent 1836df7205
commit 0232bd25f3
6 changed files with 79 additions and 100 deletions

View File

@ -37,7 +37,7 @@ local exploding={
end,
}
if cannons.config:get_bool("enable_explosion") then
if minetest.settings:get_bool("cannons_enable_explosion") then
cannons.register_muni("cannons:ball_exploding_stack_1",exploding)
end
local fire={
@ -73,7 +73,7 @@ local fire={
end,
}
if cannons.config:get_bool("enable_fire") then
if minetest.settings:get_bool("cannons_enable_fire") then
cannons.register_muni("cannons:ball_fire_stack_1",fire)
end

View File

@ -1,40 +1,19 @@
cannons = {}
cannons.MODPATH = minetest.get_modpath(minetest.get_current_modname())
local worldpath = minetest.get_worldpath()
cannons.config = Settings(worldpath.."/cannons.conf")
local conf_table = cannons.config:to_table()
--look into readme.txt how to change settings
local defaults = {
enable_explosion = "true",
enable_fire = "true",
convert_old_nodes = "false",
}
for k, v in pairs(defaults) do
if conf_table[k] == nil then
cannons.config:set(k, v)
end
end
dofile(cannons.MODPATH .."/functions.lua")
dofile(cannons.MODPATH .."/items.lua")
dofile(cannons.MODPATH .."/cannonballs.lua")
if cannons.config:get_bool("convert_old_nodes") then
dofile(cannons.MODPATH .."/convert.lua")
end
if minetest.get_modpath("tnt") then
minetest.log("info","TNT mod is aviable. registering some TNT stuff")
dofile(cannons.MODPATH .."/tnt.lua")
end
if minetest.get_modpath("locks") then
minetest.log("warning","locks mod enabled. dont execute locks.lua because this is an unstable beta version!")
--if minetest.get_modpath("locks") then
-- minetest.log("warning","locks mod enabled. dont execute locks.lua because this is an unstable beta version!")
--dofile(cannons.MODPATH .."/locks.lua")--if the locks mod is installed execute this file
end
--end
if minetest.get_modpath("moreores") then
minetest.log("info","moreores mod enabled. execute moreores.lua")
dofile(cannons.MODPATH .."/moreores.lua")--if the moreores mod is installed execute this file

View File

@ -117,7 +117,7 @@ minetest.register_craft({
},
})
if cannons.config:get_bool("enable_explosion") then
if minetest.settings:get_bool("cannons_enable_explosion") then
minetest.register_craft({
output = 'cannons:ball_exploding 2',
recipe = {
@ -128,7 +128,7 @@ minetest.register_craft({
})
end
if cannons.config:get_bool("enable_fire") then
if minetest.settings:get_bool("cannons_enable_fire") then
minetest.register_craft({
output = 'cannons:ball_fire 2',
recipe = {
@ -372,7 +372,7 @@ cannons.generate_and_register_ball_node("cannons:ball_steel", {
})
--explosion cannon ball
if cannons.config:get_bool("enable_explosion") then
if minetest.settings:get_bool("cannons_enable_explosion") then
cannons.generate_and_register_ball_node("cannons:ball_exploding", {
description = "Exploding Cannon Ball",
stack_max = 99,
@ -386,7 +386,7 @@ cannons.generate_and_register_ball_node("cannons:ball_exploding", {
end
--fire cannon ball
if cannons.config:get_bool("enable_fire") then
if minetest.settings:get_bool("cannons_enable_fire") then
cannons.generate_and_register_ball_node("cannons:ball_fire", {
description = "Burning Cannon Ball",
stack_max = 99,

6
mod.conf Normal file
View File

@ -0,0 +1,6 @@
name = cannons
title = Cannons
description = Adds cannons to the game. To shoot insert muni and gunpowder and punch the cannon with a torch. The muni can destroy nodes and hurts players.
depends = default, bucket
optional_depends = mesecons, locks, moreores, tnt, fire
min_minetest_version = 5.0

129
readme.md
View File

@ -1,4 +1,5 @@
# Welcome to the cannons mod #
cannons is a mod for the game minetest written by Kingarthurs Team
(Semmett9, eythen, and addi)
@ -9,49 +10,40 @@ the cannonball will damage the other players.
if it wears armor the damage will be calculated.
## configure cannons ##
create a file caled cannons.conf in your world dir.
add the folowing lines to it:
change the settings in your minetest.conf:
```conf
cannons_enable_explosion = "true"
cannons_enable_fire = "true"
```
#!conf
enable_explosion = "true"
enable_fire = "true"
```
now you can change it. eg. if you want to disable fire then cange
*enable_fire = "true"*
to
*enable_fire = "false"*
thats all :-)
## Dependencies
## Dependencies ##
* default
* bucket
* fire(optional)
## get cannons
## get cannons ##
relases are in the [donwloads Tab](https://bitbucket.org/kingarthursteam/cannons/downloads#tag-downloads)
swith there to tab 'Tags'
its also aviable as a git repo:
```
$ git clone https://kingarthursteam@bitbucket.org/kingarthursteam/canons.git
```bash
git clone https://kingarthursteam@bitbucket.org/kingarthursteam/canons.git
```
## Craft Rezieps
## Craft Rezieps ##
Bucket with salt:
![Bucket with salt salt](https://bitbucket.org/kingarthursteam/cannons/wiki/crafts/bucket_with_salt.png)
Salt (shapeless):
Salt (shapeless):
![salt](https://bitbucket.org/kingarthursteam/cannons/wiki/crafts/salt.png)
@ -70,65 +62,62 @@ Stone Stand:
![stone stand](https://bitbucket.org/kingarthursteam/cannons/wiki/crafts/stone_stand.png)
## Screenshots
## Screenshots ##
![Cannon Tower](https://bitbucket.org/kingarthursteam/cannons/wiki/screenshots/screenshot_1531516.png)
![Cannon Tower 2](https://bitbucket.org/kingarthursteam/cannons/wiki/screenshots/screenshot_1849086.png)
![Cannon Tower 3](https://bitbucket.org/kingarthursteam/cannons/wiki/screenshots/screenshot_5781410.png)
## Create your own Cannonball!
## Create your own Cannonball ##
```
#!lua
```lua
local ball_wood={
physical = false,
timer=0,
textures = {"cannons_wood_bullet.png"},
lastpos={},
damage=20,
range=1,
gravity=10,
velocity=40,
name="cannons:wood_bullet",
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
minetest.chat_send_all(playername .." tried to catch a cannonball")
end,
on_mob_hit = function(self,pos,mob)
mob:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
if node.name == "default:dirt_with_grass" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
elseif node.name == "default:water_source" then
minetest.sound_play("cannons_splash",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
else
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end
end,
physical = false,
timer=0,
textures = {"cannons_wood_bullet.png"},
lastpos={},
damage=20,
range=1,
gravity=10,
velocity=40,
name="cannons:wood_bullet",
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
minetest.chat_send_all(playername .." tried to catch a cannonball")
end,
on_mob_hit = function(self,pos,mob)
mob:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
if node.name == "default:dirt_with_grass" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
elseif node.name == "default:water_source" then
minetest.sound_play("cannons_splash",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
else
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end
end,
}
cannons.register_muni("cannons:ball_wood",ball_wood)
```
Have fun!
Have fun!

5
settingtypes.txt Normal file
View File

@ -0,0 +1,5 @@
# enables en exploding Cannonball
cannons_enable_explosion (Enable explotion) bool true
# enables an burning Cannonball
cannons_enable_fire (Enable Fire) bool true