Talk:OnLoad

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Regarding Rez's note, I think it's even less predictable than when the player has just left that cell. I can hop multiple cells before coming back, still without triggering an OnLoad sometimes. Just a matter of what the engine chooses to keep cached, I guess. So on that note, does anyone have an effective, efficient solution for the problem of: how do I reliably determine when the player has just entered my cell? -- Nezroy 11:08, 8 May 2006 (EDT)

How about "GetInSameCell player" on an object in the cell? You'd have to call it every second or so but it would work. --JustTim 15:00, 8 May 2006 (EDT)
Two issues with that approach:
  • First, once you leave the cell, the gamemode script for the object stops running, so in effect, any time the object script is running, GetInSameCell player will be true by definition. However, if you stick that in a quest script instead that is constantly running, it will work. Perhaps that's what you meant anyhow :)
  • Second, reports on the forums indicate that GetInSameCell appears to be pretty chaotic with the values it returns, making it more or less useless, even in a quest script. I haven't verified that myself though, so I will have to look into it further. Regardless, we can accomplish the same thing through a xref'd counter, but the basic issue still remains that we have to call this repeatedly in an always-running quest script, which just seems like way too much overhead for such a simple task.
I do think it's a viable, working solution, I just find it unsatisfactory :) This general idea has also been under discussion in this thread. -- Nezroy 16:04, 8 May 2006 (EDT)
Argh, why is this so complicated? I want CellChanged back! Anyway, is there any information anywhere on how GetInSameCell works (or doesn't)? --DragoonWraith 11:27, 23 May 2006 (EDT)

Using OnLoad with Dynamic References[edit source]

Is there any way to use an OnLoad block for a dynamic reference? In my specific instance I am spawning a statue (which is in fact an NPC) and wish to play the stone effect shader on it. Gamemode does work but if you should enter the console, inventory, wait screens the effectshader doesn't play. OnLoad should hypothetically cover all scenario's as the Objects 3D is always loaded in real time. If there is a solution that doesnt involve having the statue spawning activator in a different cell I would like to hear it.
--Antares 23:49, 7 September 2008 (EDT)

The OnLoad block does work on Dynamic objects, including NPCs, but be aware that this block does not run on all ‘3D loads’(see above). If you are creating the NPC with PlaceAtMe, you can get a ref to it with GetSelf. I am not familiar with effect shaders, so this is all I can help you with. QQuix 00:38, 8 September 2008 (EDT)
My object is wholly dynamic, I cannot go into the CS and assign it a persistant reference in the object window. Basically what I am trying to accomplish is a more robust version of the Saviour of Bruma Statue. My statue can be updated and removed at will. If you run an effectshader inside a gamemode block it will not run in any menu's, I am using OnLoad for other objects in my mod and they work fine because they aren't dynamic and are given persistant variables in the CS.
Can you do this:
 Begin OnLoad ''MyDynamicReference'''
 ;Do stuff
 End
I didnt think that would be acceptable syntax for an OnLoad block. 'spose I should check it out, thanks for the help guys.
--Antares 07:54, 8 September 2008 (EDT)

Theory -- Why it doesn't always work[edit source]

Was looking at the discussion from 2006 and I'm guessing the reason that it doesn't trigger when you exit a cell and re-enter is due to the cell buffer -- recently loaded cells are kept in memory, therefore they are not 'reloaded' when the player returns. If this is true, then it should be possible to call PurgeCellBuffers before a cell change (or probably more conveniently after a cell change) which will then ensure that OnLoad blocks re-trigger properly. The downside of course is that the cell will have to re load each time, defeating the purpose of the Cell Buffer in the first place. May not be an issue on systems with fast hard drives (RAI or /SSD for example).
I don't have a computer capable of oblivion at the moment so if someone wants to test my theory that would be great, and then it could get added to the main article page.
--quetzilla 02:45, 8 September 2008 (EDT)

You guess right. I thought this was common knowledge but it is not on the OnLoad page. Scruggs 18:40, 8 September 2008 (EDT)