Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow throwing tomatoes with the slingshot
- Loading branch information
1 parent
fe6061c
commit 07033be
Showing
11 changed files
with
127 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
local f = string.format | ||
|
||
local S = y_bows.S | ||
|
||
function y_bows.register_ammo(name, ammo_group, def) | ||
local parameters = table.copy(def.parameters or {}) | ||
parameters.pickup_item = { item = name } | ||
|
||
local damage = 0 | ||
for _, value in pairs(((parameters.punch or {}).tool_capabilities or {}).damage_groups or {}) do | ||
damage = damage + value | ||
end | ||
local drag = (parameters.drag or {}).coefficient or 0 | ||
|
||
minetest.register_craftitem(name, { | ||
description = f( | ||
"%s\n%s\n%s", | ||
def.description, | ||
minetest.colorize("green", S("damage: @1", damage)), | ||
minetest.colorize("cyan", S("drag: @1", drag)) | ||
), | ||
short_description = def.description, | ||
inventory_image = def.inventory_image, | ||
groups = { [ammo_group] = 1 }, | ||
light_source = def.light_source, | ||
_y_bows_parameters = parameters, | ||
_y_bows_properties = def.properties, | ||
}) | ||
|
||
y_bows.util.register_craft_if_valid(name, def.recipe) | ||
end | ||
|
||
function y_bows.register_item_as_ammo(name, ammo_group, def) | ||
local existing_def = assert(minetest.registered_items[name], f("item %s doesn't exist", name)) | ||
|
||
local parameters = table.copy(def.parameters or {}) | ||
parameters.pickup_item = { item = name } | ||
|
||
local damage = 0 | ||
for _, value in pairs(((parameters.punch or {}).tool_capabilities or {}).damage_groups or {}) do | ||
damage = damage + value | ||
end | ||
local drag = (parameters.drag or {}).coefficient or 0 | ||
local groups = table.copy(existing_def.groups) | ||
groups[ammo_group] = 1 | ||
|
||
minetest.override_item(name, { | ||
description = f( | ||
"%s\n%s\n%s", | ||
existing_def.description, | ||
minetest.colorize("green", S("damage: @1", damage)), | ||
minetest.colorize("cyan", S("drag: @1", drag)) | ||
), | ||
short_description = futil.get_safe_short_description(name), | ||
groups = groups, | ||
_y_bows_parameters = parameters, | ||
_y_bows_properties = def.properties, | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
if not y_bows.has.cucina_vegana then | ||
return | ||
end | ||
|
||
local def = minetest.registered_items["cucina_vegana:tomato"] | ||
if not def then | ||
return | ||
end | ||
|
||
y_bows.register_item_as_ammo("cucina_vegana:tomato", "y_bows_slingshot_ammo", { | ||
parameters = { | ||
drag = { | ||
coefficient = 0.6, | ||
}, | ||
punch = { | ||
tool_capabilities = { | ||
damage_groups = { fleshy = 0 }, | ||
}, | ||
}, | ||
hit_sound = { | ||
spec = { | ||
name = "y_bows_splat", | ||
}, | ||
}, | ||
}, | ||
properties = { | ||
textures = { rawget(def, "wield_image") or def.inventory_image }, | ||
collisionbox = { -0.2, -0.2, -0.2, 0.2, 0.2, 0.2 }, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
if not y_bows.has.farming then | ||
return | ||
end | ||
|
||
local def = minetest.registered_items["farming:tomato"] | ||
if not def then | ||
return | ||
end | ||
|
||
y_bows.register_item_as_ammo("farming:tomato", "y_bows_slingshot_ammo", { | ||
parameters = { | ||
drag = { | ||
coefficient = 0.6, | ||
}, | ||
punch = { | ||
tool_capabilities = { | ||
damage_groups = { fleshy = 0 }, | ||
}, | ||
}, | ||
hit_sound = { | ||
spec = { | ||
name = "y_bows_splat", | ||
}, | ||
}, | ||
}, | ||
properties = { | ||
textures = { rawget(def, "wield_image") or def.inventory_image }, | ||
collisionbox = { -0.2, -0.2, -0.2, 0.2, 0.2, 0.2 }, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
y_bows.dofile("compat", "cucina_vegana") | ||
y_bows.dofile("compat", "farming_redo") | ||
y_bows.dofile("compat", "mesecons") | ||
y_bows.dofile("compat", "x_bows") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters