Jump to content
Anathema

Spawning a pistol fully loaded, spawning an item multiple times

Recommended Posts

So here's the deal, I made some basic starter kits based on the occupation, but I'd like to be able to do things like spawning the pistol fully loaded as opposed to giving the player a handful of rounds to load manually (unsuccessful attempt below). Something else I've been wondering, is there a more elegant way of spawning an item multiple times? (see burgerflipper)

 

Spoiler

function GiveOccupationItems(player,square)
	local profession = player:getDescriptor():getProfession();
	
	if profession == "fireofficer" then
	player:getInventory():AddItem("Base.Axe");	
	
	elseif profession == "policeofficer" then
		local firearm = player:getInventory():AddItem("Base.Pistol");
		firearm.setClipSize(15);
		player:getInventory():AddItem("Base.Torch");

	--snip

	elseif profession == "burgerflipper" then
		player:getInventory():AddItem("Base.Pan");	
		player:getInventory():AddItem("Base.Pop");	
		player:getInventory():AddItem("Base.Pop");	
		player:getInventory():AddItem("Base.Pop");	

	--snip

	end

end

Events.OnNewGame.Add(GiveOccupationItems)

 

I've already tried my best in finding a solution for both, but I've come up with nothing. Most people just seem to resort to the more simple and crude solutions. Thank you in advance.

Share this post


Link to post
Share on other sites

So far I've figured out spawning an item multiple times:

Spoiler

	elseif profession == "burgerflipper" then
		player:getInventory():AddItem("Base.Pan");	
		player:getInventory():AddItems("Base.Pop", 2);		

 

I'd still like to know how to spawn a pistol with a full magazine inside it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...