Jump to content

Trying to make a container that auto replenish itself


yian

Recommended Posts

Hello! I am in the process of creating a device that will provide you salt and flour automatically everyday. It needs to:

 

1) Give you 3 portions of salt and 3 portions of flour everyday.

2) Will not give you additional salt or flour if they are already present in the machine.

 

I think that if the container is set to respawn, whatever content was in the container will be rest so that is not a problem. However, I'm not quite sure how to set the respawn timer to a specific container. If it is not an easy task, I think I will just use the default respawn rate of a cell and triple the amount of the items.

 

Please help, thank you!

Edited by yian
Link to comment
Share on other sites

  • 1 month later...

Then a simple script will work.

 

Here's a script I had written for someone else who wanted an activator to give the player a reward item periodically but it puts the items directly in the player's inventory and has multiple options.

 

  Reveal hidden contents

 

 

Here's the stripped down version that will put the items into the container and then open it. It still doesn't do quite what you wanted because if the player clicks on it or chooses to put other items in the container a full set of new items will still be added each day the player activates it. But the items only get added if the player actually opens the container each day. If the player skips a few days the container doesn't just keep accumulating more and more.

 

  Reveal hidden contents

 

 

And finally here's one specific to your need for 3 salt and 3 flour per day. It won't take away extras if the player stashes extra salt, flour, or other items in the container but it only adds enough salt and flour to bring the total up to 3 if there is less. (I haven't actually tried to compile it so there might be small errors, but it should work.)

ScriptName DailySaltAndFlourScript extends ObjectReference
{Keep the container stocked with a minimum of 3 salt and 3 flour each day.}

Ingredient Property SaltPile Auto

Potion Property BYOHFoodFlour Auto


Event OnInit()
	BlockActivation()
EndEvent

Event OnActivate(ObjectReference akActionRef)
	if akActionRef == Game.GetPlayer() ; do not allow other characters to get the reward!
		GoToState("TimeoutActive")
		RegisterForSingleUpdateGameTime(24.0)
		int n = 3 - GetItemCount(SaltPile)
		if n > 0
			AddItem(SaltPile, n)
		endif
		n = 3 - GetItemCount(BYOHFoodFlour)
		if n > 0
			AddItem(BYOHFoodFlour, n)
		endif
		Activate(akActionRef, true)
	endif
EndEvent

Event OnUpdateGameTime()
	GoToState("")
EndEvent

State TimeoutActive
	Event OnActivate(ObjectReference akActionRef)
		Activate(akActionRef, true)
	EndEvent
EndState
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...