Difference between revisions of "Complete Example Scripts"
Jump to navigation
Jump to search
m
Removed '> 0' from a few While loops as iIndex will be 'False' when counted down to 0, ending the loop/Added a few spaces around operators for greater legibility/floatified an int to avoid unnecessary auto-cast
imported>Scrivener07 m (→Summon Spell: Shortened line length. Messes up page on smaller displays.) |
imported>JustinOther m (Removed '> 0' from a few While loops as iIndex will be 'False' when counted down to 0, ending the loop/Added a few spaces around operators for greater legibility/floatified an int to avoid unnecessary auto-cast) |
||
Line 135: | Line 135: | ||
If akActionRef == PlayerREF | If akActionRef == PlayerREF | ||
Int iIndex = ListOfObjectsFLST.GetSize() ; Indices are offset by 1 relative to size | Int iIndex = ListOfObjectsFLST.GetSize() ; Indices are offset by 1 relative to size | ||
While iIndex | While iIndex | ||
iIndex -= 1 | iIndex -= 1 | ||
ObjectReference kReference = ListOfObjectsFLST.GetAt(iIndex) As ObjectReference ; Note that you must typecast the entry from the formlist using 'As'. | ObjectReference kReference = ListOfObjectsFLST.GetAt(iIndex) As ObjectReference ; Note that you must typecast the entry from the formlist using 'As'. | ||
Line 283: | Line 283: | ||
If akActionRef == PlayerREF | If akActionRef == PlayerREF | ||
Int iIndex = DraugrArray.Length ; Will return 30 | Int iIndex = DraugrArray.Length ; Will return 30 | ||
While iIndex | While iIndex | ||
iIndex -= 1 ; 29'th element is 30'th Draugr | iIndex -= 1 ; 29'th element is 30'th Draugr | ||
Actor kDraugr = DraugrArray[iIndex] | Actor kDraugr = DraugrArray[iIndex] | ||
Line 516: | Line 516: | ||
Event OnInit() | Event OnInit() | ||
if (TGRDays.GetValue()>0) | if (TGRDays.GetValue() > 0) | ||
;Debug.Notification("Starting countdown") | ;Debug.Notification("Starting countdown") | ||
GlobalTime.SetValue(GlobalDays.GetValue()*24) | GlobalTime.SetValue(GlobalDays.GetValue() * 24) | ||
endTime = Utility.GetCurrentGameTime()+GlobalDays.GetValue() | endTime = Utility.GetCurrentGameTime()+GlobalDays.GetValue() | ||
TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime) | TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime) | ||
Line 529: | Line 529: | ||
UnregisterForUpdateGameTime() | UnregisterForUpdateGameTime() | ||
EndIf | EndIf | ||
float step = Math.Ceiling((endTime - Utility.GetCurrentGameTime())*24) - GlobalTime.GetValue() | float step = Math.Ceiling((endTime - Utility.GetCurrentGameTime()) * 24) - GlobalTime.GetValue() | ||
if (step != 0) | if (step != 0) | ||
if (0-step > GlobalTime.GetValue()) ;avoid displaying less then 0 | if (0-step > GlobalTime.GetValue()) ;avoid displaying less then 0 | ||
Line 535: | Line 535: | ||
EndIf | EndIf | ||
if TimedQuest.ModObjectiveGlobal(step, GlobalTime, FailObjective, 0, false, false) | if TimedQuest.ModObjectiveGlobal(step, GlobalTime, FailObjective, 0, false, false) | ||
GlobalTime.SetValue(0) | GlobalTime.SetValue(0.0) | ||
TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime) | TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime) | ||
TimedQuest.SetStage(FailStage) | TimedQuest.SetStage(FailStage) |