Jump to content

Back at modding and having some trouble (of course) with a script


Recommended Posts

So I'm reviewing and updating (almost) all of my mods, and I'm currently working on Big Junk.

 

Rather than edit every cell in the game with replacements, I am using a script to replace the Mobile Statics with Misc Objects. The problem is, my script continues to place the Misc Object even if the player doesn't pick the item up. Here's the script

Scriptname _gkx_newbigjunk extends ObjectReference

MiscObject Property Replacement Auto Const
Bool Done = FALSE


ObjectReference Placed

Event OnReset()

	Placed.Disable()
	Placed.Delete()
	Done = FALSE

EndEvent

Event OnInit()

	SetScale( 0.0 )
	BlockActivation( True, True )
	Disable()

EndEvent

Event OnLoad()

	If Done==TRUE
		Return
	Else
		Done = TRUE
		Placed = PlaceAtMe(Replacement, 1, FALSE, FALSE)
	EndIf

EndEvent

It almost seems that the Placed variable isn't 'holding' the placed object to delete it when the OnReset event comes around. When I first enter a cell, the Replacement is there just fine. If I collect the replacement, everything is fine after a reset, a new Misc Object is placed where it should be. However, if I do not collect the item, an additional Misc Object will be placed after reset (in the exact same place, resulting in some... interesting... physics).

 

I'm probably missing something on the wiki regarding ObjectReference variables, so if someone with more experience could toss out some ideas, that'd be great!

 

Cheers!
~GKX

Link to comment
Share on other sites

When the original placed object resets, the attached script is cleared as well:

 

"OnReset: Your script's data has already been reset by the time you receive this event (and your OnInit has been run), so if you need to retain any information between Resets, you need to store the information somewhere else."

 

Your replacement PlaceAtMe object will never reset so the script will retain variables and state.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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