LeahTheUnknown Posted March 9, 2020 Share Posted March 9, 2020 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 More sharing options...
SKKmods Posted March 9, 2020 Share Posted March 9, 2020 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 More sharing options...
LeahTheUnknown Posted March 11, 2020 Author Share Posted March 11, 2020 The simplest solution, then, would be to attach a script to the MiscObject that deletes it on reset? Link to comment Share on other sites More sharing options...
SKKmods Posted March 11, 2020 Share Posted March 11, 2020 Yes if the replacement has a script which RegisterForRemoteEvent the original object OnReset. Link to comment Share on other sites More sharing options...
Recommended Posts