Difference between revisions of "Talk:Enable - ObjectReference"
Jump to navigation
Jump to search
→Parentheses Must Be Left Blank
imported>Cipscis |
imported>HawkFest |
||
Line 39: | Line 39: | ||
:: Would you mind elaborating on exactly how you tested this? I'm curious as to how you could have achieved that result. Unfortunately, although I usually have access to the Papyrus compiler and assembler, I don't often have the opportunity to actually test things in Skyrim. | :: Would you mind elaborating on exactly how you tested this? I'm curious as to how you could have achieved that result. Unfortunately, although I usually have access to the Papyrus compiler and assembler, I don't often have the opportunity to actually test things in Skyrim. | ||
:: -- [[User:Cipscis|Cipscis]] ([[User talk:Cipscis|talk]]) 21:34, 21 November 2012 (EST) | :: -- [[User:Cipscis|Cipscis]] ([[User talk:Cipscis|talk]]) 21:34, 21 November 2012 (EST) | ||
Sorry for the delay I don't verify these threads often... To answer your questions : | |||
:<LI> Lines 6 and 8 show the same "results" because providing no parameter will initialize ''abFadeIn'' to its default value which is "False", e.g. the compiler "understands" enable() and enable(False) identically. Why then do they behave differently in-game even though the compiler "throws out" the same result? Who knows, maybe some left-over from a previous fading mechanism related to the fact that the engine cannot fade light sources real time (it can only be done in the CK it seems)? Your guess... The bottom line is that we cannot fade-in fade-out light sources. | |||
:<LI>Note : enabling an already enabled light bulb will disable it (a bug?). | |||
'''Example''' - The following script toggles on or off a light bulb object, and is triggered when the player hits an object to which the script is attached (either a trigger object, or any static having a collision mesh - some target) : | |||
:1- Put a bubl object in the render window and force its persistence by giving it a Reference Editor ID. | |||
:2- Choose a static object with collision that can get hit by the player with any weapons (or hand-to-hand) : a dummy target, a box, a wall, whatever. Then attach the following script to it (an alternative would be to use an activator such as a button or a lever, and code the OnActivate event, instead of the OnHit event as is the case below - which would also allow you to add controls to their gamebryo animations within the same code structure if need be): | |||
<source lang="papyrus"> | |||
Scriptname SimpleLightBulbSwitchScript extends ObjectReference | |||
ObjectReference Property LightBulbRef Auto | |||
Bool UseLightBulbRef = true | |||
Event OnHit(ObjectReference Aggressor, Form Source, Projectile AkProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) | |||
If Aggressor == Game.GetPlayer() | |||
If UseLightBulbRef && LightBulbRef.IsDisabled() ;enabling an already enabled light disables it | |||
LightBulbRef.Enable() | |||
Else | |||
LightBulbRef.Disable() | |||
EndIf | |||
UseLightBulbRef = !UseLightBulbRef | |||
EndIf | |||
EndEvent | |||
</source> | |||
In the above code, if you provide a parameter to the Enable function ''LightBulbRef.Enable(True|False)'', the light will not render at all, even with ''False'' as a parameter although it's the default value.<br> | |||
--[[User:HawkFest|HawkFest]] ([[User talk:HawkFest|talk]]) 01:12, 3 December 2012 (EST) |