Difference between revisions of "A beginner's guide, lesson 7 - Using Scripts in Quests"
Jump to navigation
Jump to search
A beginner's guide, lesson 7 - Using Scripts in Quests (edit)
Revision as of 20:58, 16 August 2010
, 20:58, 16 August 2010→Imperial City Phase Two: Fixing example script
imported>Pyrocow2 (→Imperial City Phase Two: Editing some English) |
imported>Pyrocow2 (→Imperial City Phase Two: Fixing example script) |
||
Line 995: | Line 995: | ||
''I have met with Vilanus Villa again. He has taken the deed to Top View and will complete the registration. I should come back in 24 hours to complete the transfer.'' | ''I have met with Vilanus Villa again. He has taken the deed to Top View and will complete the registration. I should come back in 24 hours to complete the transfer.'' | ||
We want to set up a delay of one day before we can collect the finished documents. This gives us an excellent opportunity to look at and practice timers | We want to set up a delay of one day before we can collect the finished documents. This gives us an excellent opportunity to look at and practice timers. | ||
===Timers=== | ===Timers=== | ||
Line 1,001: | Line 1,001: | ||
Timers are another bit of scripting that gets used again and again. The game uses a number of global variables to report the progress of time. | Timers are another bit of scripting that gets used again and again. The game uses a number of global variables to report the progress of time. | ||
The two most used are | The two most used are: | ||
*[[GetSecondsPassed]] | |||
*[[GameDaysPassed]] | |||
We can use the seconds passed to establish timed events. | We can use the seconds passed to establish timed events. GetSecondsPassed returns a float value, so we must set up a float type variable to save it in. | ||
Here is an example script that takes 10 Septims from the player and then gives them back 25 seconds later. | |||
<pre> | |||
Scriptname ExampleTimerScript | |||
<pre>Scriptname ExampleTimerScript | |||
float Timer | float Timer | ||
short | short State | ||
Begin GameMode | Begin GameMode | ||
If | If State == 0 | ||
Set Timer to 25 | Set Timer to 25.0 | ||
Set | Set State to 1 | ||
Player.RemoveItem | Player.RemoveItem "gold001" 10 | ||
ElseIf State == 1 | |||
If Timer > 0 | If Timer > 0 | ||
Set Timer to Timer - GetSecondsPassed | Set Timer to Timer - GetSecondsPassed | ||
Else | Else | ||
Player.AddItem | Player.AddItem "gold001" 10 | ||
Set State to 2 | |||
EndIf | EndIf | ||
EndIf | EndIf | ||
End</pre> | End | ||
</pre> | |||
If you're writing a script where you're only interested in the number of in-game days that have passed, you can use GameDaysPassed instead. | |||
In the quest script we add some variables called StartDay, Timer, and DeedDone. | In the quest script we add some variables called StartDay, Timer, and DeedDone. |