Difference between revisions of "Useful Scripts"
Jump to navigation
Jump to search
Optimised most of the scripts and made them a little more consistent.
imported>Qazaaq (→Autoclosing door: shouldn't -> should (or change the script, this is how it works)) |
imported>Cipscis (Optimised most of the scripts and made them a little more consistent.) |
||
Line 1: | Line 1: | ||
==Karma Effects on Items== | ==Karma Effects on Items== | ||
Script Type: Object | Script Type: Effect<br /> | ||
<small>For armour, you can use a scripted Object Effect. This allows the armour to safely be equipped and unequipped via [[EquipItem]] and [[UnequipItem]]</small> | |||
<pre> | <pre> | ||
ScriptName KarmaEffect | |||
ref rWearer | |||
Begin | Begin ScriptEffectStart | ||
set rWearer to GetSelf | |||
if rWearer.GetIsReference player | |||
RewardKarma -650 | |||
endif | |||
End | End | ||
Begin OnUnequip | Begin ScriptEffectFinish | ||
if rWearer.GetIsReference player | |||
player.RewardKarma 650 | |||
endif | |||
End | |||
</pre> | |||
Script Type: Object<br /> | |||
<small>For weapons, you'll have to use an Object Script. "Weapon" type Object Effects are applied to that weapon's target, and are therefore unsuitable for applying effects to the wielder</small> | |||
<pre>ScriptName KarmaEffect | |||
Begin OnEquip player | |||
RewardKarma -650 | |||
End | |||
Begin OnUnequip player | |||
player.RewardKarma 650 | |||
End | End | ||
</pre> | </pre> | ||
Line 24: | Line 46: | ||
Begin GameMode | Begin GameMode | ||
if closeDoor == 1 | |||
if doorTimer > 0 | |||
set doorTimer to doorTimer - getSecondsPassed | |||
elseif GetOpenState == 1 ; if the door is still open | |||
SetOpenState 0 ; close the door | |||
set closeDoor to 0 | |||
endif | |||
endif | |||
End | End | ||
Begin OnActivate | Begin OnActivate | ||
if GetOpenState == 3 ; if the door is closed | |||
if IsActionRef Player == 0 ; if it should work for the player remove this... | |||
set doorTimer to 5 | |||
set closeDoor to 1 | |||
endif ; ...and this | |||
endif | |||
Activate | |||
End | End | ||
</pre> | </pre> | ||
Line 103: | Line 125: | ||
Script Type:Object | Script Type:Object | ||
<small>To be placed on an [[activator]], and [[Reference#Linked_Ref|linked]] to a light source or | <small>To be placed on an [[activator]], and [[Reference#Linked_Ref|linked]] to a light source or x-marker [[Reference#Enable_Parent|Enable Parent]].</small> | ||
<pre> | <pre> | ||
ScriptName LightSwitchScript | |||
ref light | ref light | ||
Begin OnActivate | |||
if light == 0 | |||
set light to GetLinkedRef | |||
endif | |||
if light.GetDisabled | |||
light.Enable | |||
else | |||
light.Disable | |||
endif | |||
Activate | |||
End | |||
</pre> | </pre> |