Jump to content

[LE] What is wrong with my script ? :) [2]


Recommended Posts

Hello once again, is there anything i can do better or is there anything bad?

 

Script:

 

 

Scriptname QLG_Script_SwitchLight extends ObjectReference  
{ Usage: ( you can turn On / Off many objects in same time )
	1) Place 2x XMarkers
	2) Use "Activate Parents" for ( Object Edit option )
		a) Connect to one XMarker Light and Static to be fired
		b) Connect to other XMarker Static to be fired off
	3) add this script to Activator object
	4) Select XMarkers for script to Enable / Disable }
;===- Base Info. -===;
 ;Created: 2019-03-17
 ;Author: TobiPL
 ;Unit: M.PC<3>
;===- Var. setup -============================================

	
	ObjectReference property QMarkerOff auto
	{ XMarker Ref. to turn light Off }
	
	ObjectReference property QMarkerOn auto
	{ XMarker Ref. to turn light On }
	
	Int property QTimedTurnOff auto
	{ Time ( in hour ) to turn off lights 
		:0: for No Time Limit
		:1: for Random Time
	}


;===- Script -Main- -================================================
Event OnActivate(ObjectReference QAkRef)
	If ( QMarkerOff.IsDisabled() )
		
		QMarkerOff.Enable()
		Utility.Wait(0.6)
		QMarkerOn.Disable()
		
	Else
		
		QMarkerOff.Disable()
		Utility.Wait(0.6)
		QMarkerOn.Enable()
		
		If ( QTimedTurnOff > 1 )
		
			RegisterForSingleUpdateGameTime( QTimedTurnOff )
		
		ElseIf ( QTimedTurnOff == 1 )
		
			RegisterForSingleUpdateGameTime( Utility.RandomInt( 4, 96 ) )
		
		EndIf
	EndIf
EndEvent

Event OnUpdate()
{
	;???
}

 

 

 

Script have to Enable / Disable lights

 

there will be version for TriggerBoxes and "normal" activators

also i know Event OnUpdate is empty for now cause im not 100% sure how to do it

but now im trying to make it work :D lol

 

#Best_English :D

 

what i want to Script do?

1) Turn ON/OFF lights if player activated Leaver / Button or Entered TriggerBox

2) Turn Off lights after selected time ( in game h )

3) Turn lights off randomly ( one by one not all in same time )

4) Turn lights off if hitted by Ice Magic ( its gonna be my first time doing something like this xD )

5) Turn lights on if hitted by Fire Magic

 

if any1 have any idea what i can do more just say :D ! lel xD

 

//Edit:

O_o Nexus... idk what happen but my post was fuc**k and mixed

Top of post was duplicated on bottom lel... and spoiler was copied only half

Edited by TobiaszPL
Link to comment
Share on other sites

This is one of my simple script for switching on/off lights :

(this script will auto detect the enable/disable state of Ref and do the opposite, if the Ref is in a disable state it'll enable it, if the Ref is in a enable state then it'll disable it)

 

 

{To work with "defaultDweButtonScript" & "TrapTriggerBase" & "Lever" & "PullChain"}
 
Scriptname aXMDLightSwitchOnOff extends ObjectReference  
{Light Switch on/off XMarker or lights}
 
ObjectReference Property MainLight Auto
 
Event OnActivate(ObjectReference akActionRef)
   If (MainLight.IsEnabled())
       MainLight.disable()
  Else
      MainLight.enable()
EndIf
EndEvent

 

 

 

For Triggers change "OnActivate" to "OnTriggerEnter".

 

For Light game time enable use this link :

https://www.creationkit.com/index.php?title=Light_Switch

 

For magic enable (if i'm not wrong) will be best to have a different script, i'll post it when i find it (my files are in a complete mess !!)

 

For random... i don't know, i also try to do something like that but failed. But i'm gonna try again...

Edited by maxarturo
Link to comment
Share on other sites

This all looks easy enough but you are sure asking a lot of one script. If your lights are keying off an X marker being enabled or disabled from enable parent on the light itself,

you can use a few scripts that just work with each part of your request aimed at the X marker(s) by enabling or disabling it(them).

This is one of my X Marker on off switch scripts.

Scriptname _MarkerSwitch extends ObjectReference
;* Marker Enable/Disable * By: NexusComa * ; nexusmods.com
ObjectReference Property Marker Auto
;
Event OnInit()
If(Marker.IsDisabled())
GoToState("Disable")
Else
GoToState("Enable")
EndIf
EndEvent
;-----------------------
State Disable
Event OnBeginState()
Marker.Disable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
If(Marker.IsDisabled())
GoToState("Enable")
Else
GoToState("Disable")
EndIf
EndEvent
EndState
;-----------------------
State Enable
Event OnBeginState()
Marker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
If(Marker.IsDisabled())
GoToState("Enable")
Else
GoToState("Disable")
EndIf
EndEvent
EndState
;

This is a double fault script, as it don't matter the state of the X Marker vs the script state.
No matter what state the script is in it will adjust itself to line up with the marker state.

This also let's you make multiple on off switches to the same lights that will not effect each other.
This is the type of scripting you may want to try as you create a few scripts that need to work together.


Edited by NexusComa
Link to comment
Share on other sites

I key everything of X Markers myself ... then use the Enable Parent on the object to link to the X Marker.
Here is 3 lights randomly turning on or off keyed off 3 X Markers. I know there are many ways to do this.
This one is a straight forward so you can understand how it works ...

Scriptname _Randomlights extends ObjectReference
ObjectReference Property Marker01 Auto
ObjectReference Property Marker02 Auto
ObjectReference Property Marker03 Auto
;
Event OnInit()
GoToState("RandomLights")
EndEvent
-------------------------
State RandomLights
Event OnActivate(ObjectReference akActionRef)
If(Utility.RandomInt(0,1))==(1)
If(Marker01.IsDisabled())
Marker01.Enable()
Else
Marker01.Disable()
EndIf
EndIf
If(Utility.RandomInt(0,1))==(1)
If(Marker02.IsDisabled())
Marker02.Enable()
Else
Marker02.Disable()
EndIf
EndIf
If(Utility.RandomInt(0,1))==(1)
If(Marker03.IsDisabled())
Marker03.Enable()
Else
Marker03.Disable()
EndIf
EndIf
EndEvent
EndState
Link to comment
Share on other sites

As you see once again I used the double fault technique. This way I also could add a new script like the 1st script I posted

and both scripts would do there job perfectly. No matter what state the scrips or X Marker(s) are in, Have fun!


Edit: As in a different script from a different switch

 

 

Now to get all the light to turn off or on together even if some are on and some are off. Use a variable to key the switch off.

 

Scriptname _MarkerSwitchMaster extends ObjectReference

ObjectReference Property Marker01 Auto
ObjectReference Property Marker02 Auto
ObjectReference Property Marker03 Auto
Bool Master = false ; or true if you want them on at first.
;
Event OnInit()
GoToState("MasterSwitch")
EndEvent
;-----------------------
State MasterSwitch
Event OnActivate(ObjectReference akActionRef)
If(Master==(true)
Master = false
Marker01.Disable()
Marker02.Disable()
Marker03.Disable()
Else
Master = true
Marker01.Enable()
Marker02.Enable()
Marker03.Enable()
EndIf
EndIf
EndEvent
EndState

Once again this will work with the other scripts as long as you are using different switches whatever way you wish to set up switches.
Like maybe Event OnTriggerEnter(ObjectReference akTriggerRef) ; set to a trigger box.

That should be enough for you to figure this out have fun!
Edited by NexusComa
Link to comment
Share on other sites

 

I key everything of X Markers myself ... then use the Enable Parent on the object to link to the X Marker.

Here is 3 lights randomly turning on or off keyed off 3 X Markers. I know there are many ways to do this.

This one is a straight forward so you can understand how it works ...

 

Scriptname _Randomlights extends ObjectReference

ObjectReference Property Marker01 Auto
ObjectReference Property Marker02 Auto
ObjectReference Property Marker03 Auto
;
Event OnInit()
GoToState("RandomLights")
EndEvent
-------------------------
State RandomLights
Event OnActivate(ObjectReference akActionRef)
If(Utility.RandomInt(0,1))==(1)
If(Marker01.IsDisabled())
Marker01.Enable()
Else
Marker01.Disable()
EndIf
EndIf
If(Utility.RandomInt(0,1))==(1)
If(Marker02.IsDisabled())
Marker02.Enable()
Else
Marker02.Disable()
EndIf
EndIf
If(Utility.RandomInt(0,1))==(1)
If(Marker03.IsDisabled())
Marker03.Enable()
Else
Marker03.Disable()
EndIf
EndIf
EndEvent
EndState

 

Hi NexusComa.
I was wondering how can your script be modified to do this (i try to do it but fail, the closer i got is just randomly enable/disable them something like your script does).
What i was trying to do is : the effect of a damaged neon tube lamp, you know that random fast flickering. (but i didn't get near where close to it).
* The pulse and flicker option from CK lights does not works because the period is renegade and always the same - not random.
Edited by maxarturo
Link to comment
Share on other sites

its not what i need but k...

i dont have mouse - and cause of this im fkin*g angry on me

but cause i dont have mouse i can't draw it for you :c

 

but w8 2h and ill probably Edit this post with better explain of my problem :tongue:

 

 

i hate this fkin*g touchpad =_=

and i were thinking "bfff 4 what i need mouse, not gonna even use it today"

 

and today i was mostly need mouse =_= omfg

 

//Edit:

here is what i want:

 

You are not allowed to use that image extension on this community.

 

ok...

Edited by TobiaszPL
Link to comment
Share on other sites

  • Recently Browsing   0 members

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