Jump to content

My plantation script is not working. Help please.


Polyfemus

Recommended Posts

Basically what the script is all about is when the "seed" objects are dropped from the player's inventory after 60 seconds a plant is placed there. Then the seed object is disabled leaving only the newly placed plant there. Here's the script:

scn aaSeedBrocSCRIPT

Begin onDrop player

float timer
ref self

   if timer < 60
      set timer to timer + GetSecondsPassed
   else
      ;60 seconds have passed, do something special
	set self to getself
	self.placeatme brocflowerplant 1
	self.disable
   endif

end

The script compiles alright but when I try it out in game it simply doesn't work. The plant is not placed and the seed doesn't get disabled. I wonder if the problem has something to do with the way I'm using the GetSecondsPassed function or something, like my timer variable doesn't ever get a chance to reach 60 or something. Any input appreciated cause I'm lost. If this doesn't work out I'll have to figure another way to make plantation work.

Link to comment
Share on other sites

Here's a revised script:

scn	aaSeedBrocSCRIPT

float	fTimer

begin OnAdd			; If the seed was picked up before it could sprout - reset.

	set fTimer to 0

end

begin OnDrop player

	if (GetContainer == 0) && (player.IsInInterior == 0)	; Making sure the seed was dropped on the ground, outside.
		set fTimer to 60
	endif

end

begin GameMode

	if fTimer
		if fTimer > 0
			set fTimer to fTimer - GetSecondsPassed
		else
			PlaceAtMe BrocFlowerPlant 1
			Disable
			MarkForDelete
		endif
	endif

end

Notes:
The OnDrop block type only runs once, therefore it is not suitable when using timers; GameMode should be used, instead.
Variables should always be declared outside a Begin block, otherwise they are reset on every iteration.

Link to comment
Share on other sites

Hey thanks dude it works. I noticed the timer really does use real time and doesn't account for wait time. At the moment however the placeatme function puts the flower in odd spots on the ground I'll have to adjust the function's parameters to put the flower in proper spots but that'll be for me to figure out. Thanks again jazzisparis.

Link to comment
Share on other sites

At the moment however the placeatme function puts the flower in odd spots on the ground

 

Yeah, that was expected. Instead of:

PlaceAtMe BrocFlowerPlant 1

Try:

ref	rPlant	; Put this with the rest of the variables.

set rPlant to PlaceAtMe BrocFlowerPlant 1
rPlant.SetAngle X 0
rPlant.SetAngle Y 0
Link to comment
Share on other sites

I tried the adjustments you added. I think they actually helped a bit the plants end up a bit more stable than before some of them not quite though. The plants still end up looking bent even if I placed the seeds on flat ground.

 

But regardless I don't think I can do the plantation this way. Because if I drop more than 1 seed from my inventory in one go the seeds don't work. The plants don't appear at all. So to successfully plant using this script the only way would be to go one by one in the inventory screen, exiting the inventory screen after each seed dropped.

 

Anyways jazzisparis thank you so much for your help.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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