Update slingshot mod to v0.3...

Release: https://github.com/AntumMT/mod-slingshot/releases/tag/v0.3
master
Jordan Irwin 2021-06-10 13:10:58 -07:00
parent 767d9180c8
commit a9f60e93d0
24 changed files with 489 additions and 259 deletions

View File

@ -39,7 +39,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* [minetest_game][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa3.0]) -- version: [5.4.1][ver.minetest_game] *2021-04-10*
* equipment/
* [airtanks][] ([MIT][lic.airtanks]) -- version: [b686694 Git][ver.airtanks] *2021-03-13* ([patched][patch.airtanks])
* [slingshot][] ([MIT][lic.slingshot] / [CC0][lic.cc0]) -- version [0.1][ver.slingshot] *2017-08-16*
* [slingshot][] ([MIT][lic.slingshot] / [CC0][lic.cc0]) -- version [0.3][ver.slingshot] *2021-06-10*
* [throwing][] ([WTFPL][lic.wtfpl]) -- version: [90bcf43 Git][ver.throwing] *2013-09-27* ([patched][patch.throwing])
* [xtraarmor][] ([CC BY-SA][lic.ccbysa3.0]) -- version: 0.3
* furniture/
@ -617,7 +617,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.sfinv_buttons]: http://repo.or.cz/minetest_sfinv_buttons.git/tree/ebb1f7c
[ver.signs_lib]: https://gitlab.com/VanessaE/signs_lib/tree/2021-03-04-2
[ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/3630fe9
[ver.slingshot]: https://github.com/AntumMT/mod-slingshot/tree/bb77525
[ver.slingshot]: https://github.com/AntumMT/mod-slingshot/releases/tag/v0.3
[ver.sneeker]: https://github.com/AntumMT/mod-sneeker/releases/tag/v1.0
[ver.snowdrift]: https://github.com/paramat/snowdrift/tree/3342939
[ver.stone_monster]: https://github.com/AntumMT/mod-mob_stone_monster/tree/fa52f6f

View File

@ -2527,10 +2527,15 @@ spawneggs.enable_node_spawn = false
# *** slingshot ***
## Require rubber band as additional ingredient in slingshot craft recipes.
# type: bool
# default: true
#slingshot.require_rubber_band = true
## Use old 16x16 textures.
# type: bool
# default: false
#slingshot.old_textures = false
## Value of these items will be added to slingshot attack when thrown.
# type: string (comma-separated key=value list)
# default: default:mese_crystal=5
#slingshot.ammos = default:mese_crystal=5
# *** torches ***

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright © 2007 Jordan Irwin
Copyright © 2007-2021 Jordan Irwin (AntumDeluge)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
@ -19,3 +19,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original code licensed under CC0 by AiTechEye

View File

@ -1,38 +1,39 @@
# Slingshot Mod for Minetest
## Slingshot for Minetest
### Description:
Adds a slingshot that can throw inventory items as ammunition.
The original code was extracted from [hook][] mod by [AiTechEye][].
The original code was extracted from [hook](https://forum.minetest.net/viewtopic.php?t=13634) mod by [AiTechEye](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=16172).
![Screenshot](screenshot.png)
Depends:
- default
Optional depends (soft):
- technic
### Licensing:
- Code
- Original code by AiTechEye: [CC0][lic.cc0]
- Code by Jordan Irwin (AntumDeluge): [MIT][lic.mit]
- Original code by AiTechEye: [CC0][lic.cc0]
- Code by Jordan Irwin (AntumDeluge): [MIT][lic.mit]
- Textures: [CC0][lic.cc0]
- Textures:
- slingshots: [CC0][lic.cc0]
- rubber band: [CC0][lic.cc0]
### Requirements:
- Minimum Minetest version: 5.0.0
- Depends: none
- Optional depends:
- [default](https://github.com/minetest/minetest_game/tree/master/mods/default) (required for craft recipe)
- [technic](https://content.minetest.net/packages/RealBadAngel/technic/) (changes craft recipes to use rubber band)
- [xdecor](https://content.minetest.net/packages/jp/xdecor/) (workbench can be used to repair slingshots)
- [workbench](https://github.com/AntumMT/mod-xdecor/tree/workbench) (can be used to repair slingshots)
### Functions:
### Usage:
- *Right-click*: Changes ammo slot between left & right of slingshot
- *Left-click*: Throws items from selected ammo slot
- *Left-click*: Throws items from slot right of slingshot.
#### Crafting:
### Crafting:
<details><summary>Spoiler</summary>
**Legend:**
* `SI` = default:steel_ingot
* `ST` = default:stick
@ -40,29 +41,19 @@ Optional depends (soft):
* `TR` = technic:rubber
* `TL` = technic:raw_latex
##### Craft recipes:
**Recipes:**
slingshot:
wooden slingshot:
╔════╦════╦════╗
║ SI ║ ║ SI
║ ST ║ ║ ST
╠════╬════╬════╣
║ ║ SI ║ ║
║ ║ ST ║ ║
╠════╬════╬════╣
║ ║ SI ║ ║
║ ║ ST ║ ║
╚════╩════╩════╝
slingshot (with technic):
╔════╦════╦════╗
║ SI ║ ║ SI ║
╠════╬════╬════╣
║ ║ SI ║ ║
╠════╬════╬════╣
║ ║ SI ║ ║
╚════╩════╩════╝
wood slingshot:
wooden slingshot (rubber band required with technic):
╔════╦════╦════╗
║ ST ║ RB ║ ST ║
@ -72,14 +63,24 @@ wood slingshot:
║ ║ ST ║ ║
╚════╩════╩════╝
wood slingshot (with technic):
iron slingshot:
╔════╦════╦════╗
║ ST ║ RB ║ ST
║ SI ║ ║ SI
╠════╬════╬════╣
║ ║ ST ║ ║
║ ║ SI ║ ║
╠════╬════╬════╣
║ ║ ST ║ ║
║ ║ SI ║ ║
╚════╩════╩════╝
iron slingshot (rubber band required with technic):
╔════╦════╦════╗
║ SI ║ RB ║ SI ║
╠════╬════╬════╣
║ ║ SI ║ ║
╠════╬════╬════╣
║ ║ SI ║ ║
╚════╩════╩════╝
rubber band:
@ -98,11 +99,31 @@ rubber band (shapeless):
║ TR ║
╚════╝
</details>
#### Settings:
```
slingshot.old_textures
- Use old 16x16 textures.
- type: bool
- default: false
slingshot.ammos
- Value of these items will be added to slingshot attack when thrown.
- type: string (comma-separated key=value list)
- default: default:mese_crystal=5
```
[AiTechEye]: https://forum.minetest.net/memberlist.php?mode=viewprofile&u=16172
### Links:
- [Forum](https://forum.minetest.net/viewtopic.php?t=18315)
- [Git repo](https://github.com/AntumMT/mod-slingshot)
- [API](https://antummt.github.io/mod-slingshot/docs/api.html)
- [Changelog](changelog.txt)
- [TODO](TODO.txt)
[hook]: https://forum.minetest.net/viewtopic.php?t=13634
[lic.cc0]: LICENSE-cc0.txt
[lic.mit]: LICENSE.txt

View File

@ -0,0 +1,5 @@
TODO:
- possibly convert to use a throwing API
- fix setting default entity duration value (item_entity_ttl) to 900, same as minetest.conf.example
- don't use "on_globalstep" to ensure hit

View File

@ -1,66 +1,63 @@
-- Functions for slingshot mod
-- Displays mod name in square brackets at beginning of log messages
local log_header = '[' .. slingshot.modname .. '] '
--- Info log message
--- Slingshot mod API.
--
-- Logs 'info' message if 'log_message' setting set to 'true'.
--
-- @function slingshot.log
-- @tparam string message Message to be logged.
function slingshot.log(message)
if core.settings:get_bool('log_mods') then
core.log('info', log_header .. message)
end
end
-- @module api
local debug = core.settings:get_bool('enable_debug_mods') == true
--- Debug log message.
--
-- Logs 'info' message if 'debug_log_level' setting set to 'verbose'.
--
-- @function slingshot.logDebug
-- @tparam string message Message to be logged.
function slingshot.logDebug(message)
if debug then
core.log(log_header .. 'DEBUG: ' .. message)
end
end
-- Enables/Disables wear/break of slingshots when used for attacking
local weapon_wear = core.settings:get_bool('enable_weapon_wear') ~= false
local tmp_throw = {}
local tmp_throw_timer = 0
local tmp_time = tonumber(core.settings:get('item_entity_ttl')) or 890
local registered_ammos = {}
--- Register an item as ammunition for slingshot.
--
-- Any item can be thrown, but registering as ammo
-- allows custom attack value to be set.
--
-- @function slingshot.register_ammo
-- @tparam string name Item technical name.
-- @tparam int damage Damage value addon.
function slingshot.register_ammo(name, damage)
registered_ammos[name] = damage
end
if slingshot.ammos and slingshot.ammos:trim() ~= "" then
local ammos = string.split(slingshot.ammos:trim(), ",")
for _, a in ipairs(ammos) do
if a:find("=") then
a = string.split(a, "=")
local aname = a[1]:trim()
local aval = tonumber(a[2]:trim()) or 0
slingshot.register_ammo(aname, aval)
end
end
end
-- Registers 'cooldown' time for repeat throws
--
-- FIXME: using on_globalstep causes attack to miss when in sync
core.register_globalstep(function(dtime)
tmp_throw_timer = tmp_throw_timer + dtime
if tmp_throw_timer < 0.2 then return end
-- Reset cooldown
tmp_throw_timer = 0
for i, t in pairs(tmp_throw) do
local puncher = core.get_player_by_name(t.user)
t.timer = t.timer-0.25
if t.timer <= 0 or t.ob == nil or t.ob:getpos() == nil then table.remove(tmp_throw, i) return end
for ii, ob in pairs(core.get_objects_inside_radius(t.ob:getpos(), 1.5)) do
if (not ob:get_luaentity()) or (ob:get_luaentity() and (ob:get_luaentity().name ~= '__builtin:item')) then
if t.timer <= 0 or t.ob == nil or t.ob:get_pos() == nil then table.remove(tmp_throw, i) return end
for ii, ob in pairs(core.get_objects_inside_radius(t.ob:get_pos(), 1.5)) do
if (not ob:get_luaentity()) or (ob:get_luaentity() and (ob:get_luaentity().name ~= "__builtin:item")) then
-- Which entities can be attacked (mobs & other players unless PVP is enabled)
if (not ob:is_player()) or (ob:is_player() and ob:get_player_name(ob) ~= t.user and core.settings:get_bool('enable_pvp') == true) then
-- FIXME: Don't use 'ob' for puncher
ob:punch(puncher, 1.0, {damage_groups={fleshy=4}}, nil)
t.ob:setvelocity({x=0, y=0, z=0})
t.ob:setacceleration({x=0, y=-10, z=0})
t.ob:setvelocity({x=0, y=-10, z=0})
if (not ob:is_player()) or (ob:is_player() and ob:get_player_name(ob) ~= t.user and slingshot.enable_pvp) then
ob:punch(puncher, 1.0, {damage_groups=t.damage_groups}, nil)
t.ob:set_velocity({x=0, y=0, z=0})
t.ob:set_acceleration({x=0, y=-10, z=0})
t.ob:set_velocity({x=0, y=-10, z=0})
table.remove(tmp_throw, i)
core.sound_play('slingshot_hard_punch', {pos=ob:getpos(), gain=1.0, max_hear_distance=5,})
core.sound_play("slingshot_hard_punch", {pos=ob:get_pos(), gain=1.0, max_hear_distance=5,})
break
end
end
@ -71,110 +68,145 @@ end)
--- Action to take when slingshot is used.
--
-- @function slingshot.on_use
-- @param itemstack
-- @param user
-- @param veloc
function slingshot.on_use(itemstack, user, veloc, wear_rate)
local pos = user:getpos()
-- @local
-- @function on_throw
-- @param itemstack
-- @param user
-- @param veloc
local function on_throw(itemstack, user, veloc, wear_rate, damage_groups)
local pos = user:get_pos()
local upos = {x=pos.x, y=pos.y+2, z=pos.z}
local dir = user:get_look_dir()
local item = itemstack:to_table()
-- Throw items in slot to right
local item = user:get_inventory():get_stack('main', user:get_wield_index()+1):get_name()
if item == '' then return itemstack end
local item = user:get_inventory():get_stack("main", user:get_wield_index()+1):get_name()
if item == "" then return itemstack end
local e = core.add_item({x=pos.x, y=pos.y+2, z=pos.z}, item)
if e then
e:setvelocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc})
e:setacceleration({x=dir.x*-3, y=-5, z=dir.z*-3})
e:get_luaentity().age = tmp_time
table.insert(tmp_throw, {ob=e, timer=2, user=user:get_player_name()})
if weapon_wear then
if wear_rate == nil then
wear_rate = 100
end
slingshot.logDebug('Wear rate: ' .. tostring(wear_rate))
itemstack:add_wear(wear_rate)
e:set_velocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc})
e:set_acceleration({x=dir.x*-3, y=-5, z=dir.z*-3})
e:get_luaentity().age = slingshot.thrown_duration
local dg = table.copy(damage_groups)
if dg == nil then
dg = {fleshy=1}
end
user:get_inventory():remove_item('main', item)
core.sound_play('slingshot_throw', {pos=pos, gain=1.0, max_hear_distance=5,})
local addon = registered_ammos[item]
if addon then
for k, v in pairs(dg) do
dg[k] = v + addon
end
end
table.insert(tmp_throw, {ob=e, timer=2, user=user:get_player_name(), damage_groups=dg})
if not slingshot.creative then
if slingshot.enable_wear then
if wear_rate == nil then
wear_rate = 100
end
slingshot.log("debug", "Wear rate: " .. tostring(wear_rate))
itemstack:add_wear(wear_rate)
end
user:get_inventory():remove_item("main", item)
end
core.sound_play("slingshot_throw", {pos=pos, gain=1.0, max_hear_distance=5,})
return itemstack
end
end
local register_repairable
if core.global_exists("xdecor") and xdecor.register_repairable then
register_repairable = xdecor.register_repairable
elseif core.global_exists("workbench") and workbench.register_repairable then
register_repairable = workbench.register_repairable
elseif core.global_exists("WB") and WB.register_repairable then
register_repairable = WB.register_repairable
end
--- Registers a new slingshot.
--
-- 'def' should include 'description', 'damage_groups', & 'velocity'.
-- 'def' should include 'description', 'damage_groups', & 'velocity'.
--
-- @function slingshot.register
-- @param name
-- @param def
-- @function slingshot.register
-- @tparam string name Name of the slingshot (e.g. ***"iron"***).
-- @tparam table def Slingshot definition table (see [slingshot.register.def](#slingshot.register.def)).
function slingshot.register(name, def)
local image = {}
-- The default slingshot
if name == 'slingshot' then
image = 'slingshot.png'
else
image = 'slingshot_' .. name .. '.png'
if def.inventory_image then
-- Inventory image will override image if set
def.image = def.inventory_image
end
core.register_tool('slingshot:' .. name, {
if not def.image then
-- The default slingshot
if name == "slingshot" then
def.image = "slingshot.png"
else
def.image = "slingshot_" .. name .. ".png"
end
end
if not def.wield_image then
-- Use inventory image
def.wield_image = def.image
end
local sname = "slingshot:" .. name
core.register_tool(sname, {
description = def.description,
range = 4,
inventory_image = image,
wield_image = image,
inventory_image = def.image,
wield_image = def.wield_image,
on_use = function(itemstack, user, pointed_thing)
--[[
if pointed_thing.ref and pointed_thing.ref:is_player() == false and pointed_thing.ref:get_luaentity().name == '__builtin:item' then
pointed_thing.ref:punch(user, {full_punch_interval=1.0, damage_groups=def.damage_groups}, '', nil)
--[[ Disabled picking up items with slingshot in hand
if pointed_thing.ref and pointed_thing.ref:is_player() == false and pointed_thing.ref:get_luaentity().name == "__builtin:item" then
pointed_thing.ref:punch(user, {full_punch_interval=1.0, damage_groups=def.damage_groups}, "", nil)
return itemstack
end
]]
slingshot.on_use(itemstack, user, def.velocity, def.wear_rate)
on_throw(itemstack, user, def.velocity, def.wear_rate, def.damage_groups)
return itemstack
end,
})
-- def.ingredient overrides def.recipe
if def.ingredient ~= nil then
if slingshot.require_rubber_band and core.global_exists('technic') then
-- More complicated recipe for technic
def.recipe = {
{def.ingredient, 'slingshot:rubber_band', def.ingredient},
{'', def.ingredient, ''},
{'', def.ingredient, ''},
}
else
def.recipe = {
{def.ingredient, '', def.ingredient},
{'', def.ingredient, ''},
{'', def.ingredient, ''},
}
end
if register_repairable then register_repairable(nil, sname) end
if def.recipe then
slingshot.log("warning", "\"recipe\" attribute no longer supported in registration")
end
-- Optional register a craft recipe
if def.recipe ~= nil then
core.register_craft({
output = 'slingshot:' .. name,
recipe = def.recipe,
})
if def.ingredient then
slingshot.log("warning", "\"ingredient\" attribute no longer supported in registration")
end
-- Optionally register aliases
if def.aliases ~= nil then
for index, alias in ipairs(def.aliases) do
core.register_alias(alias, 'slingshot:' .. name)
end
if def.aliases then
slingshot.log("warning", "\"aliases\" attribute no longer supported in registration")
end
end
--- Function Definition Tables.
--
-- @section fdtables
--- Slingshot definition table.
--
-- @table slingshot.register.def
-- @tfield string description Human-readable description of slingshot (e.g. ***"Wooden Slinghot"***).
-- @tfield table damage_groups
-- - Same as [minetest.register_tool.tool_capabilities.damage_groups](https://github.com/minetest/minetest/blob/71b02d6/doc/lua_api.txt#L1551)
-- - Default: {fleshy=1}
-- @tfield int velocity Speed & distance at which items will be thrown.
-- @tfield int wear_rate Rate at which the slingshot will wear & break.
-- @see slingshot.register

View File

@ -1,44 +0,0 @@
# Slingshot API
---
## -- Functions --
### ***slingshot.log(message)***
- Info log message
- Logs 'info' message if 'log_message' setting set to 'true'.
- **param:** *message*
- Message to be logged
- **type:** *string*
### ***slingshot.logDebug(message)***
- Debug log message
- Logs 'info' message if 'debug_log_level' setting set to 'verbose'.
- **param:** *message*
- Message to be logged
- **type:** *string*
### ***slingshot.on_use(itemstack, user, veloc)***
- Action to take when slingshot is used
- **param:** *itemstack*
- **param:** *user*
- **param:** *veloc*
### ***slingshot.register(name, def)***
- Registers a new slingshot
- **param:** *name*
- Name/Type of new slingshot (e.g., 'wood')
- **type:** *string*
- **param:** *def*
- Tool definition
- **type:** *table*
- Required attributes
- *description*
- Tool description
- **type:** *string*
- *damage_groups*
- Damage dealt to entities
- **type:** *table*
- *velocity*
- Speed/Distance of thrown object
- **type:** int

View File

@ -0,0 +1,38 @@
v0.3
----
- added new textures
- rubber band item is registered even if technic not available
- items can be registered as ammos with custom attack values
- slingshots can be repaired with workbench if "xdecor.register_repairable" method available
- craft recipes & aliases no longer registered with slingshot registration
- technic:rubber outputs 6 rubber bands instead of 10
- detect automatically if rubber band can be used instead of setting slingshot.require_rubber_band
- added localization support
- "default" changed to optional dependency required for craft recipe only
v0.2
----
- custom images can be used for registering new slingshot
- use damage groups from slingshot registration to do damage
- changed slingshot damage groups:
- wood: fleshy=1
- iron: fleshy=3
- wear is disabled in creative mode
- ammo does not depelete in creative mode
v0.1
----
- forked from AiTechEye's hook mod v10 ( https://forum.minetest.net/viewtopic.php?t=13634 ) (2017-04-09) CC0
- removed hook code
- changed license to MIT
- created rubber band item for craft recipes (requires technic)
- added wooden slingshot
- fixed entities not dropping items when killed with slingshot
- cannot pickup items while holding slingshot
- set wear rate for slingshots
- added setting to enable/disable wear
- items are only thrown from slot to right
- replaced deprecated "setting_get" methods
- set "wield_image" value
- added API method for registering custom slingshots

View File

@ -1,2 +0,0 @@
default
technic?

View File

@ -1 +0,0 @@
Adds a slingshot that can throw inventory items as ammunition.

View File

@ -3,18 +3,39 @@ slingshot = {}
slingshot.modname = core.get_current_modname()
slingshot.modpath = core.get_modpath(slingshot.modname)
function slingshot.log(lvl, msg)
if not msg then
msg = lvl
lvl = nil
end
if core.settings:get_bool('log_mods') then
core.log('action', '[slingshot] Require rubber band: ' .. tostring(slingshot.require_rubber_band))
if not msg and not lvl then
lvl = "error"
msg = "no log arguments supplied"
end
msg = "[" .. slingshot.modname .. "] " .. msg
if lvl == "debug" then
if not slingshot.debug then return end
msg = "[DEBUG] " .. msg
lvl = nil
end
if not lvl then
core.log(msg)
else
core.log(lvl, msg)
end
end
local scripts = {
'settings',
'api',
'weapons',
"settings",
"api",
"weapons",
}
for index, script in ipairs(scripts) do
dofile(slingshot.modpath .. '/' .. script .. '.lua')
dofile(slingshot.modpath .. "/" .. script .. ".lua")
end

View File

@ -0,0 +1,6 @@
Translated by:
Rubber Band=
Wooden Slingshot=
Iron Slingshot=

View File

@ -1,2 +1,5 @@
name = slingshot
version = 0.1
version = 0.3
description = A slingshot that can throw inventory items as ammunition.
author = AiTechEye, Jordan Irwin (AntumDeluge)
optional_depends = default, technic, xdecor, workbench

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 KiB

After

Width:  |  Height:  |  Size: 216 KiB

View File

@ -1,7 +1,79 @@
-- Slingshot settings
--- Requires rubber band for slingshot craft recipe.
--- Slingshot mod settings.
--
-- @setting slingshot.require_rubber_band
slingshot.require_rubber_band = core.settings:get_bool('slingshot.require_rubber_band') ~= false
-- @module settings
--- Slingshot specific settings.
--
-- Settings unique to this mod.
--
-- @section settings_specific
--- Use old 16x16 textures.
--
-- @setting slingshot.old_textures
-- @settype bool
-- @default false
slingshot.old_textures = core.settings:get_bool("slingshot.old_textures", false)
--- Value of these items will be added to slingshot attack when thrown.
--
-- @setting slingshot.ammos
-- @settype string
-- @default default:mese_crystal=5
slingshot.ammos = core.settings:get("slingshot.ammos") or "default:mese_crystal=5"
--- General settings.
--
-- Settings commom to core & other mods.
--
-- @section settings_general
--- Enables/Disables wear when used.
--
-- @setting enable_weapon_wear
-- @settype bool
-- @default true
slingshot.enable_wear = core.settings:get_bool("enable_weapon_wear", true)
--- Log extra messages.
--
-- @setting log_mods
-- @settype bool
-- @default false
slingshot.log_mods = core.settings:get_bool("log_mods", false)
--- Log extra debug messages.
--
-- @setting enable_debug_mods
-- @settype bool
-- @default false
slingshot.debug = core.settings:get_bool("enable_debug_mods", false)
--- Determines if game is being run in creative mode.
--
-- @setting creative_mode
-- @settype bool
-- @default false
slingshot.creative = core.settings:get_bool("creative_mode", false)
--- Time in seconds for item entity (dropped items) to live.
--
-- Setting it to -1 disables the feature.
--
-- @setting item_entity_ttl
-- @settype int
-- @default 890
slingshot.thrown_duration = tonumber(core.settings:get("item_entity_ttl")) or 890
--- Determines if PVP is enabled.
--
-- @setting enable_pvp
-- @settype bool
-- @default true
slingshot.enable_pvp = core.settings:get_bool("enable_pvp", true)

View File

@ -1,2 +1,25 @@
# Require rubber band as additional ingredient in slingshot craft recipes.
slingshot.require_rubber_band (Require rubber band in craft recipe) bool true
# Use old 16x16 textures.
slingshot.old_textures (Old slingshot textures) bool false
# Value of these items will be added to slingshot attack when thrown.
slingshot.ammos (Registered ammos) string default:mese_crystal=5
# Enables/Disables wear when used.
enable_weapon_wear (Weapon wear) bool true
# Log extra messages.
log_mods (Log mods) bool false
# Log extra debug messages.
enable_debug_mods (Debug mods) bool false
# Determines if game is being run in creative mode.
creative_mode (Creative) bool false
# Time in seconds for item entity (dropped items) to live.
# Setting it to -1 disables the feature.
item_entity_ttl (Thrown item duration) int 890 -1
# Determines if PVP is enabled.
enable_pvp (Enable PVP) bool true

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 382 B

View File

@ -1,54 +1,99 @@
-- Registrations for slinghot mod
if core.global_exists('technic') then
core.register_craftitem('slingshot:rubber_band', {
description = 'Rubber band',
inventory_image = 'slingshot_rubber_band.png',
local S = core.get_translator(slingshot.modname)
local textures = {
rubber_band = "rubber_band",
wood = "wood",
iron = "iron",
}
if slingshot.old_textures then
for k, v in pairs(textures) do
textures[k] = v .. "-old"
end
end
local rubber_available = core.registered_items["technic:rubber"] ~= nil
local latex_available = core.registered_items["technic:raw_latex"] ~= nil
if rubber_available or latex_available then
core.register_craftitem("slingshot:rubber_band", {
description = S("Rubber Band"),
inventory_image = "slingshot_" .. textures.rubber_band .. ".png",
})
end
if rubber_available then
core.register_craft({
output = 'slingshot:rubber_band 20',
type = 'shapeless',
recipe = {'technic:rubber'},
output = "slingshot:rubber_band 6",
type = "shapeless",
recipe = {"technic:rubber"},
})
end
if latex_available then
core.register_craft({
output = 'slingshot:rubber_band 2',
output = "slingshot:rubber_band 2",
recipe = {
{'technic:raw_latex', 'technic:raw_latex', ''},
{'technic:raw_latex', '', 'technic:raw_latex'},
{'', 'technic:raw_latex', 'technic:raw_latex'},
{"technic:raw_latex", "technic:raw_latex", ""},
{"technic:raw_latex", "", "technic:raw_latex"},
{"", "technic:raw_latex", "technic:raw_latex"},
}
})
end
-- A wooden slingshot
slingshot.register('wood', {
description = 'Wooden slingshot',
damage_groups = {fleshy=2},
slingshot.register("wood", {
description = S("Wooden Slingshot"),
image = "slingshot_" .. textures.wood .. ".png",
damage_groups = {fleshy=1},
velocity = 10,
wear_rate = 500,
ingredient = 'group:stick',
aliases = {
slingshot.modname .. ':wooden',
'wood_slingshot',
'wooden_slingshot',
})
for _, a in ipairs({slingshot.modname .. ":wooden", "wood_slingshot", "wooden_slingshot"}) do
core.register_alias(a, slingshot.modname .. ":wood")
end
local ing_1 = "group:stick"
local ing_2 = ""
if core.registered_items["slingshot:rubber_band"] then
ing_2 = "slingshot:rubber_band"
end
core.register_craft({
output = slingshot.modname .. ":wood",
recipe = {
{ing_1, ing_2, ing_1},
{"", ing_1, ""},
{"", ing_1, ""},
}
})
-- A stronger iron slingshot
slingshot.register('iron', {
description = 'Iron Slingshot',
damage_groups = {fleshy=4},
slingshot.register("iron", {
description = S("Iron Slingshot"),
image = "slingshot_" .. textures.iron .. ".png",
damage_groups = {fleshy=3},
velocity = 15,
wear_rate = 250,
ingredient = 'default:steel_ingot',
aliases = {
slingshot.modname,
slingshot.modname .. ':slingshot',
'iron_slingshot',
},
})
for _, a in ipairs({slingshot.modname .. ":slingshot", "iron_slingshot"}) do
core.register_alias(a, slingshot.modname .. ":iron")
end
if core.registered_items["default:steel_ingot"] then
ing_1 = "default:steel_ingot"
core.register_craft({
output = slingshot.modname .. ":iron",
recipe = {
{ing_1, ing_2, ing_1},
{"", ing_1, ""},
{"", ing_1, ""},
}
})
end

View File

@ -905,8 +905,11 @@ server_shop.use_currency_defaults (Use currency mod defaults) bool true
[*slingshot]
# Require rubber band as additional ingredient in slingshot craft recipes.
slingshot.require_rubber_band (Require rubber band in craft recipe) bool true
# Use old 16x16 textures.
slingshot.old_textures (Old slingshot textures) bool false
# Value of these items will be added to slingshot attack when thrown.
slingshot.ammos (Registered ammos) string default:mese_crystal=5
[*trampoline]