Project Zomboid

Project Zomboid

49 ratings
Magazine API
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
163.264 KB
Mar 1 @ 5:07am
Mar 14 @ 11:19pm
4 Change Notes ( view )

Subscribe to download
Magazine API

Description
If you want buy me a coffee? then hit the UP & Favorite button instead giving me some dollars. I can buy coffee myself :D
(or some steam points.. I want to buy new profile wallpapers..)




Description
This mod does not add any weapons or magazines.

This mod allows other modders to use multiple magazine types on the same firearm.
For example, an AK with a 30-round mag AND 95-round RPK drum mag.

>>Example Mod (Vanilla Firearm Magazine Expansion)<<

Main Feature
  • For modder: Single line per a weapon. simple.

  • Tooltip will be automatically generated by API. You can see that in the screenshot. will be fancy in the future tho.

  • Best Magazine will always be "magazine that has highest ammo count" no matter magazine types.

  • Also, when you are inserting bullets in your spare magazine, mod try to insert bullet into where the Best Magazine is.

  • When you are inserting bullets, If you don't have any bullets for Best Magazine, mod will try to find next magazine type.

  • Regarding above, you can use multiple type of ammo for single firearm. (for now, single type per single magazine however will be changed.)

  • When there's no ammo in all of your magazines, magazine which has highest Max Capacity will be the best magazine.

  • If you want to change your magazine manually, not automatically selected magazine, right-click your weapon and find "select magazine" menu



How To Use
  • MagAPI.defineParam(weapon, mag1, mag2, ... mag99, mag100) -- This is all you have to do.
Example
require = "MagAPI" MagAPI.defineParam("Base.AssaultRifle", "Base.9mmClip", "Base.556Clip", "Base.M14Clip", "Base.44Clip")

If you need more detailed description, check the pinned discussion.




Stability & Compatibility & Performance
It's pretty stable as I believe, but I'm not sure about performance when there are many magazine types.
I believe it will be okay too, but anyway, this is why I'm saying this is in testing.

About Compatibility, since weapon mods does not allow to use more than one weapon mod, it will be okay.
Also, you can fix & edit my code freely unless you are gonna set this mod as required of your mod.

About MP
I will try when B42 MP is out, but honestly, I have not played MP in the last 11 years of PZ.
So I'm not sure.



Future?





Known Issue
Tooltip will show correct maxAmmo and currentAmmo, However, name of magazine will not be changed.


This is my first API mod and also my first medium-sized mod, so anything bad can happen.
I wrote this code in 6 hours, but the idea came 1-2 months ago.

If you are a developer, You CAN DO ANYTHING you want to implemented by copy&paste my files. You can include files into your mod directly to overwrite API, any actions, any codes. however, you should set this API as requirement.
Popular Discussions View All (2)
0
Mar 6 @ 4:09pm
PINNED: Planned Next Update/ Planned Future Features
N0wh3re
0
Mar 3 @ 9:54pm
PINNED: How to use // For anybody want to simply make a own mod
N0wh3re
3 Comments
N0wh3re  [author] Mar 24 @ 6:56am 
@+_:_KingGodder_:_+
Assumeyou are whom in TIS discord, I left a reply in mod_develop channel.
Don't have hard time alone. you can share your issue in there. :)
+_:_KingGodder_:_+ Mar 24 @ 3:26am 
Hey man, dont know if you'll see this... can you rewrite this in B41? I want to make it work with CJ, I don't know anything about coding and am having some hard times.
Sir Doggy Jvla Mar 9 @ 7:25am 
Hello, I'm the lead of Project Modding for the official wiki and I documented your framework on it for other modders to more easily find. Don't hesitate to modify, adjust or add informations
https://pzwiki.net/wiki/Magazine_API


I would also like to give some tips with your framework which would improve it, notably the use of modules:
https://pzwiki.net/wiki/Lua_(language)#Modules

Overall everything looks clean however ! I noticed you used some deprecated functions (empty functions now) from your API in your example mod but you probably already know about that haha