Jump to content

How does the "First Aid Kit" work? (I Need Help)


paologerochi

Recommended Posts

I'm having problems with giving myself a First Aid Kit.

I was wondering how does the First Aid Kit really work? By default if you pick up First Aid Kits in containers, you would get items inside it, but after I tried giving it to myself via

getPlayer():getInventory():AddItem('Base.FirstAidKit');

it was empty, so my question is how to get a specific container in your inventory and add items inside it?
 

Sorry, please help, I'm currently new to modding PZ..

Link to comment
Share on other sites

That's because the first aid kit is just a single item. It isn't possible to simply spawn it with a command and have it contain stuff. The reason why it has stuff in it if you find one is determined by the loot tables.

 

How to do it is another matter... You'd have to look for a command from the javadocs (maybe something in the ItemContainerFiller) to spawn items for the container separately. If you're not experienced in lua at all I'd suggest starting with Robomat's tutorials.

Link to comment
Share on other sites

Yes, you can create yourself a fully loaded first aid kit that spawns with your character.  I've done something similar with a "go-bag" containing some basic disaster preparedness items I think a person should have.

 

I'm going to assume you've already read Robomat's tutorials and know how to create a mod.  If not, go do that first or this won't make any sense.

 

In your LUA file, you need the following code so that you get your first aid kit when you start a new game.  Custom in the files I've reviewed seems to be to put event registration as the last thing in the LUA file.

Events.OnNewGame.Add(addMyItems);

Next, you are going to need an actual function to be called.  That function gets the player's inventory, spawns an empty first aid kit, loads that container into the player's inventory, gets the inventory for the first aid kit itself, and then loads items into the first aid kit's inventory.  I have only added one item below, but you should be able to figure out the rest yourself.  I believe all of the first aid items are in "newitems.txt", though some may be in "items.txt".

 

Weight seems to get updated automatically by AddItem().  I have not tested to see if AddItem() will let you put in more than a container can hold.

local function addMyItems(player, square)	local _inventory = player:getInventory();	_inventory:AddItem("Base.FirstAidKit");	_bag = _inventory:FindAndReturn("FirstAidKit"):getInventory();	_bag:AddItem("Bandaid");end
Link to comment
Share on other sites

  • 4 weeks later...

 

Yes, you can create yourself a fully loaded first aid kit that spawns with your character.  I've done something similar with a "go-bag" containing some basic disaster preparedness items I think a person should have.

 

I'm going to assume you've already read Robomat's tutorials and know how to create a mod.  If not, go do that first or this won't make any sense.

Dude thanks!  :)

This really helped alot, love u dude (no homo).  :D  :lol:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...