Project Zomboid

Project Zomboid

Bow and Arrow
Gluten the Sensitive  [developer] Jan 1, 2024 @ 12:48pm
How to add thing to mod with mod
For example, a glass arrowhead, a graphite arrow shaft, and a bow.

\scripts
module SomeModule { recipe Make Glass Arrowhead Example { Moveables.brokenglass_1_0/Moveables.brokenglass_1_1/Moveables.brokenglass_1_2/Moveables.brokenglass_1_3, Result:SomeModule.ArrowheadGlass, Time:80.0, Category:Survivalist, } item ArrowheadGlass { Weight = 0.07, Type = Normal, DisplayName = Arrowhead of Glass, Icon = SomeIcon, } item ArrowheadGlassAttachment { Weight = 0, Type = WeaponPart, DisplayName = Arrowhead of Glass (You should not see this), Icon = SomeIcon, PartType = Canon, MountOn = MandelaArrowBlank, } item GraphiteArrowShaftAttachment { Weight = 0, Type = WeaponPart, DisplayName = Arrow Shaft of Graphite (You should not see this), Icon = SomeIcon, PartType = Canon, MountOn = MandelaArrowBlank, } model ArrowShaftGraphite { mesh = Weapons/Archery/MandelaArrowShaftWood, texture = SomeTexture, } }

Lua
local BaseShared = MandelaBowAndArrow.Shared; --Adding a bow local newBow = = { speed = 0.25, aimingAngle = 30, aimingDistance = 17, weaponOffset = 0.9, deviationMultiplier = 1.5, model = "SomeModule.SomeBow", soundVolume = 1, soundRadius = 4}; table.insert(BaseShared.Bows, newBow); --Adding arrow parts BaseShared.AttachmentModels["SomeModule.ArrowheadGlassAttachment"] = "MandelaBowAndArrow.MandelaArrowHeadIron"; --This tells the mod to use a pre-existing arrowhead model for glass, but you could change the model. BaseShared.AttachmentModels["SomeModule.GraphiteArrowShaftAttachment"] = "MandelaBowAndArrow.ArrowShaftGraphite"; --SomeModule.ArrowShaftGraphite doesn't exist by the way, it's just an example. --Attachment models are assigned in the base mod's OnGameBoot() function. BaseShared.ArrowPartData["SomeModule.ArrowheadGlass"] = {sort = "Head"}; --Tells the mod it's an arrowhead BaseShared.AttachmentConversion["SomeModule.ArrowheadGlass"] = "SomeModule.ArrowheadGlassAttachment"; --Tells the mod what attachment item to use. The mod uses pairs of items for arrow parts. One is the one you see in the inventory. The other is the one used as an "attachment" on the arrow item and the bow. BaseShared.AttachmentConversion["SomeModule.ArrowheadGlassAttachment"] = "SomeModule.ArrowheadGlass"; --Tells the mod what item to use for the attachment item. So if you remove the arrowhead attachment, the game knows which item to put in the inventory. BaseShared.AttachmentWeight["SomeModule.ArrowheadGlassAttachment"] = 0.07; --Says how much the arrowhead should increase the arrow's weight by. --This for the shaft's name MandelaBowAndArrow.Shared.ArrowShaftNames["SomeModule.ArrowShaftGraphite"] = getText("IGUI_some_name_for_it";

The code looks better in something like notepad++ or vs code
Last edited by Gluten the Sensitive; Mar 26, 2024 @ 11:59am