Creating a new light reference

Post » Tue Mar 10, 2015 10:33 pm

I am trying to write a script that creates a new light reference within an interior cell (a tiki torch light). I can get the torch to show up - but it doesn't cast any light. I am using the PlaceAtMe function. Is there something I can do to get the light to actually cast light, without exiting and reentering the cell?

User avatar
xxLindsAffec
 
Posts: 3604
Joined: Sun Jan 14, 2007 10:39 pm

Post » Wed Mar 11, 2015 7:02 am

Try disabling and enabling the torch immediatly after placing the item.

User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Tue Mar 10, 2015 7:03 pm

From what I recall, a light needs to be moved from its original coordinates before it starts generating light.

You can even see this in the CS when you drop a light in, it won't generate light sometimes until you grab it and move it.

I think hollaajith's suggestion of Enabling instead of Placing might bypass this.


User avatar
IsAiah AkA figgy
 
Posts: 3398
Joined: Tue Oct 09, 2007 7:43 am

Post » Wed Mar 11, 2015 4:07 am

I think disable/enable mainly helps refreshing collision, probably best moving a little e.g.
Spoiler

begin myLightLocalScript short doOnceif ( doOnce )  returnendif set doOnce to 1disable  ; probably useful to refresh collision if needed for lightmoveworld Z 5  ; so the engine find a (minimally) changed float position coordinate, hopefully forcing light redrawenable  ; probably useful to refresh collision if needed for light end
User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am

Post » Wed Mar 11, 2015 8:38 am

Out of curiosity, I wonder if any of these workarounds would also help to get items to be properly lit after they are placed by script.

User avatar
Adrian Morales
 
Posts: 3474
Joined: Fri Aug 10, 2007 3:19 am

Post » Tue Mar 10, 2015 8:20 pm

Thanks! The disable/enable in one frame worked.

Below are the scripts I used, do you see any problems with them?

I created a new light reference for a lit tiki torch, with sound. I applied the following script to it. I did NOT check the reference persists option, because I am not saving the data.

begin TR_lit_tiki_scriptDontSaveObjectshort doonceif ( doonce == 0 )   disable   enable   set doonce to 1   returnendifif ( MenuMode == 1 )    Returnendifif ( GetDisabled == 1 )   setdelete 1   returnendifif ( player->CellChanged == 1 )   disable   returnendifend TR_lit_tiki_script

I then created an activator using the static unlit tiki torch, and applied the following script to it. I did check the References Persist option for this.

If the player saves the game while in this cell, then reloads the game, the tiki will get scaled up to 0.5. I use this feature to reset the lit tikis. When the player leaves the cell - all the tiki torches will go out (well actually they will go out when the player reenters the cell).

begin TR_act_tiki_torchshort new_tikifloat curZshort dooncefloat tempZ;using scale value to determine if the player has come in via a game loadif ( doonce == 0 )   set curZ to ( GetPos Z )   set doonce to 1endifif ( GetScale == 0.5)   ;reactive lights   SetPos Z curZ   PlaceAtMe "TR_m3_lit_tiki2" 1 0 1   set tempZ to ( curZ - 5000 )   SetPos Z tempZ   SetScale 0.1   Returnendifif ( MenuMode == 1 )   Returnendifif ( player->CellChanged == 1 )   if ( new_tiki == 1 )      SetScale 1.0      SetPos Z curZ      Set new_tiki to 0   endif   Returnendifif ( OnActivate == 1)   if ( new_tiki == 0 )      PlaceAtMe "TR_m3_lit_tiki2" 1 0 1      set tempz to ( curZ - 5000 )      SetPos Z tempZ       SetScale 0.1      set new_tiki to 1      Return   endifendifEnd TR_act_tiki_torch
User avatar
Josh Trembly
 
Posts: 3381
Joined: Fri Nov 02, 2007 9:25 am

Post » Tue Mar 10, 2015 9:11 pm

Moving new lights up/down doesn't make them radiate here either. But they shine on My Hero or any other Crreaure / NPC right from their generation. By the time one returns to the area after a while, they shine happily as if they never did otherwise.

What's even weirder: if the light is generated after a save and one doesn't (have he chance to, because one is being killed) save once more and loads the save from before the generation within the same PLAY session, the light will still be there... Forever.

Thanks for the disable/enable idea, i'll try it !

User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm


Return to III - Morrowind