Jump to content
Sejemus

How do I make mod items spawn in map?

Recommended Posts

Hello fellow survivors, I'm seeking some assistance on how to spawn items in world from a mod.

So far I've read that it's the SuburbsDistribution module which spawn stuff. So I made a script in my mods/media/scripts folder with the module below.

module Extra_SuburbsDistribution{	imports	{		SuburbsDistribution, ModItemsModule	}		containeritemdistribution	{		Room			= 			shed,		Containers		= 			counter,		ModItem	                =			2,	}}

The problem I am facing is that the item does not seem to spawn. I have not yet found any of if. So I have a few questions.

First: What does the number to the right of the item mean?

Second: Is this the correct way to add items to the spawning of items in world?

 

Thanks in advance.

-Sejemus

Share this post


Link to post
Share on other sites

Hey, you'll have to make your own YourModsHoweverNamedDistribution.lua file for that.

 

It should look something like this:

require "Items/SuburbsDistributions";MoreFoods = {} -- Name this whatever your module name for the items is. Base is the most used in game.table.insert(SuburbsDistributions["conveniencestore"]["fridge"].items, "MoreFoods.GroundBeef"); -- your item nametable.insert(SuburbsDistributions["conveniencestore"]["fridge"].items, 3); -- spawn chance. don't ask the numbers, don't knowtable.insert(SuburbsDistributions["conveniencestore"]["shelves"].items, "MoreFoods.Rice");table.insert(SuburbsDistributions["conveniencestore"]["shelves"].items, 2);table.insert(SuburbsDistributions["conveniencestore"]["shelves"].items, "MoreFoods.Spaghetti");table.insert(SuburbsDistributions["conveniencestore"]["shelves"].items, 2);

You can find the reference for the locations and containers in the suburbsdistribution.lua which you've apparently already found. :)

 

Hope it helps

Share this post


Link to post
Share on other sites

Oh, Alright, I'll check it out. Thanks!

Do you know where I should place the file when moding for build 25+?

Should I have the file in client and server, or should it be in shared?

 

Again, thanks :)

 

EDIT:

I can't get it to work. When I add

require "Items/SuburbsDistributions";Items = {} -- Items is the name of the module that have the items.table.insert(SuburbsDistributions["shed"]["counter"].items, "Items.Item1");table.insert(SuburbsDistributions["shed"]["counter"].items, 10);table.insert(SuburbsDistributions["shed"]["counter"].items, "Items.Item2");table.insert(SuburbsDistributions["shed"]["counter"].items, 1);table.insert(SuburbsDistributions["shed"]["counter"].items, "Items.Item3");table.insert(SuburbsDistributions["shed"]["counter"].items, 3);

I get a error saying "Attempted index: shed of non-table: null"

 

What am I doing wrong?

Share this post


Link to post
Share on other sites

Hmm... I've never had that problem myself and also I haven't used this system for a while. :???: The only thing that comes to my mind is the folder location which has now changed. Try changing the first line to this:

require "server/Items/SuburbsDistributions";

I'm no pro at this so if it doesn't cut it, we'll have to wait on someone smarter. :D

Share this post


Link to post
Share on other sites

Alright, the problem has been solved! :D

Here's how it works:

This piece of code is working for build 25:

require "server/Items/SuburbsDistributions";NameofItemModule = {}table.insert(SuburbsDistributions["all"]["fridge"].items, "ItemModule.ItemName");table.insert(SuburbsDistributions["all"]["fridge"].items, 10); -- I think the higher the number, the higher chance of a spawn.

It has to be in: "yourmodhere/media/lua/server/yourdistributionsfilehere.lua"

 

Thanks to Suomiboi for helping me figure it out! :)

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...