The Globglogabgalab Posted August 30, 2018 Share Posted August 30, 2018 Hello, and thank you for investing time. I decided as a highly intelligent entity to bless the community of Project Zomboid with a mod that adds skillbooks for each and every skill, but sadly in my library there are no such things as computers, therefore I have no background in coding. I used the PZIC to get started. Here is my first code: Spoiler module ModulName { Base item BookAiming1 { DisplayName = Archery for dummies, or how to not poke your eyes, Icon = TestImg, Weight = 0.4, Type = Literature, CanBarricade = false, UseWhileEquipped = false, SkillTrained = Aiming, LvlSkillTrained = 1, NumLevelsTrained = 2, } item BookAiming2 { DisplayName = The Gun Nut, or how to 360 noscope a squirrel, Icon = TestImg, Weight = 0.4, Type = Literature, CanBarricade = false, UseWhileEquipped = false, SkillTrained = Aiming, LvlSkillTrained = 3, NumLevelsTrained = 2, } item BookAiming3 { DisplayName = The Police Officer Hand Guide, Icon = TestImg, Weight = 0.4, Type = Literature, CanBarricade = false, UseWhileEquipped = false, SkillTrained = Aiming, LvlSkillTrained = 5, NumLevelsTrained = 2, } item BookAiming4 { DisplayName = Advanced Military Tactics, Icon = TestImg, Weight = 0.4, Type = Literature, CanBarricade = false, UseWhileEquipped = false, SkillTrained = Aiming, LvlSkillTrained = 7, NumLevelsTrained = 2, } item BookAiming5 { DisplayName = The Master Shooter Secret (not) Guide, Icon = TestImg, Weight = 0.4, Type = Literature, CanBarricade = false, UseWhileEquipped = false, SkillTrained = Aiming, LvlSkillTrained = 9, NumLevelsTrained = 2, } } All inserted down into the scripts folder from the media one. Now, after I finished making those marvelous creations, I went into the distribution section, again, without any knowledge Spoiler require 'Items/SuburbsDistributions'------------------------ Trash Items ---------------------- table.insert(SuburbsDistributions["all"]["shelves"].items, "ModulName.BookAiming1"); table.insert(SuburbsDistributions["all"]["shelves"].items, 3); table.insert(SuburbsDistributions["all"]["shelves"].items, "ModulName.BookAiming2"); table.insert(SuburbsDistributions["all"]["shelves"].items, 3); table.insert(SuburbsDistributions["all"]["shelves"].items, "ModulName.BookAiming3"); table.insert(SuburbsDistributions["all"]["shelves"].items, 3); table.insert(SuburbsDistributions["all"]["shelves"].items, "ModulName.BookAiming4"); table.insert(SuburbsDistributions["all"]["shelves"].items, 3); table.insert(SuburbsDistributions["all"]["shelves"].items, "ModulName.BookAiming5"); table.insert(SuburbsDistributions["all"]["shelves"].items, 3); But here I am into my game, mod is loaded, palms are sweaty. Harms are heavy, no spaghetti, dou, because none of my books seem to spawn. I tried loading them manually via Necroforge but no use, as they dont appear there either. Care to help a fellow member of the community? Link to comment Share on other sites More sharing options...
Bejasc Posted August 31, 2018 Share Posted August 31, 2018 Have you enabled your mod in the `Mods` section? Could you please post your mod.info file? Link to comment Share on other sites More sharing options...
The Globglogabgalab Posted August 31, 2018 Author Share Posted August 31, 2018 Yes I did enable it, as you can see in the pic. Here is the mod.info: Spoiler name=Lots of books poster= id=iwishicouldread description=Who said reading cant be fun? Link to comment Share on other sites More sharing options...
Fenris_Wolf Posted August 31, 2018 Share Posted August 31, 2018 (edited) Having done all this already for another mod, heres what you need: 1) your scripts .txt entries look mostly fine. What your missing though is "NumberOfPages" item BookAiming1 { NumberOfPages = 220, Weight = 0.8, Type = Literature, DisplayName = Aiming for Beginners, Icon = Book, SkillTrained = Aiming, LvlSkillTrained = 1, NumLevelsTrained = 2, } NumberOfPages is generally 220 for book 1, 260 for book 2, 300 for book 3, 340 for book 4, and 380 for book 5. Your distribution code seems fine, it could be just the random generator screwing with you. Make sure your lua code for the distributions are in media\lua\server. Items are not automatically added to necroforge, which is why you cant manually spawn them (i'll get to that part in a bit) One critical part you're missing for skillbooks is a bit of lua that also goes in media\lua\server, you can place it in the same file as your distribution code: SkillBook["Aiming"] = { perk = Perks.Aiming, maxMultiplier1 = 3, maxMultiplier2 = 5, maxMultiplier3 = 8, maxMultiplier4 = 12, maxMultiplier5 = 16, } The vanilla file that performs this is media\lua\server\XpSystem\XPSystem_SkillBook.lua (the code above uses a slightly different syntax then the vanilla, but the effect is the same). One thing to note is the multipliers used: for the missing skills like aiming, the default multipliers (3, 5, 8, 12 and 16) will generate experience very fast in these skills. We reduced them to 50% (1.5, 2.5, 4, 6 and 8) For adding these items to necroforge, create a new lua file in media\lua\client: Events.OnGameStart.Add(function() if NecroList then -- necroforge is loaded. local MyItems = { "BookAiming1", "BookAiming2", "BookAiming3", "BookAiming4", "BookAiming5", } local addItem = function(index, itemName) -- function to save much redundant typing of entries local scriptItem = getScriptManager():FindItem(itemName) if not scriptItem then return end NecroList.Items["ModulName"..index] = {"Mods", "ModulName", nil, "ModulName - " .. scriptItem:getDisplayName(), itemName, "media/textures/Item_" .. scriptItem:getIcon() .. ".png", nil, nil, nil} end local index = 1 for _, name in pairs(MyItems) do addItem(index, 'ModulName.'..name) index = index+1 end end end) Your books will now appear under necroforge's 'Mods' category (on the right side, not under Literature on the left). You can add any additional books or items into the MyItems table near the start of that code. It also generally helps to check the console.txt file after loading the mod, and after entering the game world to see if any errors has occurred. EDIT: just relooked at your script .txt paste, you have a error in there, the word "Base" that occurs before your first item entry. This will stop your books from being added to the game correctly, which would be why they never spawn. Edited August 31, 2018 by Fenris_Wolf Bejasc 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now