rezecib

[Guide] Getting started with modding DST (and some general tips for DS as well)

77 posts in this topic

Hello.

I can't find any info about how to set variable amount of items.

My mod (only own use) base on  Auto Planting

In contradistinction to "Auto planting" my mod don't planting items at offset algorithm, but return so much new items as much as I put to container.

And there is in "Auto planting"-mod such code:

if inst.components.container:Has("dug_sapling", 1) then
	inst.components.container:ConsumeByName("dug_sapling", 1)
	inst.plants = "sapling"
	GLOBAL.ThePlayer.components.inventory:ConsumeByName("nightmarefuel", amount)
end

Instead number (there it is 1), I want use variable amount "n", which I will set as "local n = I don't know what code to use here".

I tried to use "local n = self.obj.components.stackable:StackSize()", but it don't work.

And so here is my question: how to set variable amount of items, that based on  the amount of items that I'm going to put in the container. I don't want to set a fixed amount of items, because with each use, amount of items will be different, depending on how many I want use.  

Sorry for my bad english. It's not my native language.

Share this post


Link to post
Share on other sites
16 hours ago, Kajshi said:

 

I can't find any info about how to set variable amount of items.

For specific problems it's better to have specific topics.

Share this post


Link to post
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