[dismiss]
This wiki is a copy of the original Oblivion CS wiki created and maintained by the UESP.net. See CSwiki:Copy Notice for more info.
Difference between revisions of "Scripting Tutorial: Spell Tome"
Jump to navigation
Jump to search
no edit summary
imported>Grosie |
imported>Grosie |
||
Line 38: | Line 38: | ||
if buttonpressed == 1 | if buttonpressed == 1 | ||
set button to GetButtonPressed | set button to GetButtonPressed | ||
if button == | if button == 1 | ||
set doonce to 0 | |||
set buttonpressed to 0 | |||
Message "Ok - Maybe you can learn later" | |||
elseif button == | elseif button == 0 | ||
set buttonpressed to 0 | set buttonpressed to 0 | ||
player.AddSpell StandardFrostDamageTarget1Novice | player.AddSpell StandardFrostDamageTarget1Novice | ||
Line 51: | Line 51: | ||
NB: The MessageBox Part should all be on one line - wiki formatting however prevents this. | NB: The MessageBox Part should all be on one line - wiki formatting however prevents this. | ||
===How the script works=== | |||
The first part names the script and declares the variables. | |||
<pre> | |||
scn aaaSpellTomeScript ;Script name, put near the top of alphabetical list | |||
short doonce ;Variable for executing the check only once | |||
short buttonpressed ;Has a button been pressed (should we check which one?) | |||
int button ;Which button has been pressed? | |||
</pre> | |||
The OnActivate block executes each time you open the book and asks you if you want the spell if you haven't already learnt it. | |||
<pre> | |||
begin onActivate | |||
if doonce == 0 ;has the player already learnt the spell? | |||
;ask the player if they would like the spell | |||
MessageBox "Would you like to learn the Spell of Frost Damage?", "Yes please", "No way, maybe later" | |||
set doonce to 1 ;Don't ask them again | |||
set buttonpressed to 1 ;tell the script to check what the player answered | |||
else | |||
;Tell the player that they have got the spell already. | |||
Message "You have already learn what you can from this Tome" | |||
endif | |||
end | |||
</pre> | |||
The GameMode Block excutes every frame, checking if a button has been pressed and responding if it has. | |||
<pre> | |||
begin GameMode | |||
if buttonpressed == 1 | |||
set button to GetButtonPressed ;find which button has been pressed | |||
if button == 1 ;has the player decided not to learn this spell? | |||
set doonce to 0 ;tell the script that we should ask the player again | |||
set buttonpressed to 0 ;tell it that we have finished checking buttons | |||
Message "Ok - Maybe you can learn later" ;confirm the player's choice to him/her | |||
elseif button == 0 ;has the player decided to learn the spell? | |||
set buttonpressed to 0 ;tell the script we have finished checking buttons | |||
player.AddSpell StandardFrostDamageTarget1Novice ;add the spell | |||
Message "Use this knowledge wisely" ; confirm the player's choice | |||
endif | |||
endif | |||
end | |||
</pre> | |||
''This article is currently being written, please do not change it yet!'' | ''This article is currently being written, please do not change it yet!'' |