Jump to content

Pann

Recommended Posts

I am definitely new to modding, but have been working on a custom professions mod. My mod currently makes custom professions and then adds items to them based on the selected job. My question comes down to adding in items from a different mod? I can get it to load with base game objects, but I am not able to get it to load Hydrocraft items. Is there a resource that might point me in the right direction? I'm sure its something simple.

Link to comment
Share on other sites

3 hours ago, Fenris_Wolf said:

Sounds like your probably missing the module prefix when trying to add items.  ie "Hydrocraft.HCArmorkevlar" instead of just "HCArmorkevlar".

Module prefix's aren't required for base items. But code samples would be helpful.

I did try that. My best guess is that that I need to "require" it, but that is just a guess rather than actual knowledge. 

Link to comment
Share on other sites

2 hours ago, Pann said:

I did try that. My best guess is that that I need to "require" it, but that is just a guess rather than actual knowledge.

Defiantly not. If your trying to add existing items to a inventory using lua, then you don't need to require anything. Tested on v38.30, created a new mod, and the entire mod's code:

 

Events.OnNewGame.Add(function(player, square)
    local prof = player:getDescriptor():getProfession()
    if prof == "policeofficer" then
        player:getInventory():AddItem("ORGM.Ber92")
        player:getInventory():AddItem("ORGM.Ber92Mag")
        player:getInventory():AddItem("ORGM.Ammo_9x19mm_FMJ_Box")
    end
end)

Started me off with one Beretta 92FS, 1 spare mag and 1 box of 9x19mm Full Metal Jacket bullets from ORGM.

Link to comment
Share on other sites

I responded on steam but it seems you have been away since then. Easiest way is to hit me up on discord honestly. Legion#1790

 

I have discord tied to my phone as well while steam I only have access to on a computer. I am sure with a sample of code will shed some light on what the issue might be. 

 

To be honest, I would love to see a mod like this finished and working properly because it sounds like something that we might actually use as well. Would cut back on item spawning for sure. 

 

Worst case if it doesn't fit this lore, there is always the option of next lore as well. Plus its just the kind of mod I think would really add to the game itself. 

Edited by FinestHops
Link to comment
Share on other sites

6 minutes ago, jianmingyong said:

Maybe your mod load earlier than hydrocraft by folder naming conventions. If your mod load earlier than anything else, you can't really spawn anything custom.

 

I could be wrong but in the configs, the further left in the mods line, the sooner it loads in order isn't it? Like I found for example with OTR, having the mod listed at the end on the right caused it to bug but marking it to the left make it work flawlessly. Might not be the case and could just be that I only THINK it does better that way. 

Edited by FinestHops
Link to comment
Share on other sites

9 hours ago, Fenris_Wolf said:

Defiantly not. If your trying to add existing items to a inventory using lua, then you don't need to require anything. Tested on v38.30, created a new mod, and the entire mod's code:

 


Events.OnNewGame.Add(function(player, square)
    local prof = player:getDescriptor():getProfession()
    if prof == "policeofficer" then
        player:getInventory():AddItem("ORGM.Ber92")
        player:getInventory():AddItem("ORGM.Ber92Mag")
        player:getInventory():AddItem("ORGM.Ammo_9x19mm_FMJ_Box")
    end
end)

Started me off with one Beretta 92FS, 1 spare mag and 1 box of 9x19mm Full Metal Jacket bullets from ORGM.

I used your exact code, and it worked. When I substituted the kevlar  vest code from hydrocraft, it didn't show up, but the other three items did. 

Link to comment
Share on other sites

1 hour ago, jianmingyong said:

Maybe your mod load earlier than hydrocraft by folder naming conventions. If your mod load earlier than anything else, you can't really spawn anything custom.

Order is actually irreverent here.  PZ queues all mods for loading, loads all script items from all mods, then loads all lua.  So even if technically the new mod is loaded first, Hydrocraft's items are already registered by the time it hits the lua. The spawn code is even further delayed by being on a event anyways.

Link to comment
Share on other sites

(sorry for the double post)

42 minutes ago, Pann said:

I used your exact code, and it worked. When I substituted the kevlar  vest code from hydrocraft, it didn't show up, but the other three items did. 

I just loaded up HC and added the following line under the 3 ORGM item from the example above:

 

inventory:AddItem("Hydrocraft.HCArmorkevlar")
 

Worked fine for me started with the kevlar vest in addition to the gun and ammo. And just to confirm this is not a load order issue:

MOD: loading ORGM
MOD: loading ProfessionItems <<<<<<<< loaded in the middle
MOD: loading Hydrocraft
 

Is HC actually getting loaded on your end ok? Because there must be something screwy going on.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...