Difference between revisions of "Prevent Video and Cutscene Skipping (h2)"
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left;width:10%" | By |- | Prevent Skipping of Videos/Cutscenes || AFRLme |} This t...") |
m (Text replacement - "{{toc}}" to "") |
||
| (4 intermediate revisions by one other user not shown) | |||
| Line 7: | Line 7: | ||
| − | This tutorial shows you how to prevent the player from being able to skip videos &/or cutscenes. ''Visionaire Studio 4.1+'' is required for this to work. | + | This tutorial shows you how to prevent the player from being able to skip videos &/or cutscenes. ''Visionaire Studio 4.1+'' is required for this to work. (currently only works for cutscenes). |
| Line 14: | Line 14: | ||
Preventing skipping of videos &/or cutscenes is actually very simple. All you need is 1 condition & an event handler that listens out for the ESC key. So let's begin... | Preventing skipping of videos &/or cutscenes is actually very simple. All you need is 1 condition & an event handler that listens out for the ESC key. So let's begin... | ||
| − | You should start off by creating a condition somewhere & naming it '''cond_skip_cv''' & set it to <span class="red">false</span> by default if you want to prevent players from being allowed to skip videos on game start; else set condition to <span style="color:lightgreen">true</span>. | + | 1. You should start off by creating a condition somewhere & naming it '''cond_skip_cv''' & set it to <span class="red">false</span> by default if you want to prevent players from being allowed to skip videos on game start; else set condition to <span style="color:lightgreen">true</span>. |
| + | 2. Next you need to create a '''definition script''' containing a '''registerEventHandler''' for '''keyEvents''' - if you don't already have one. ''Quick note: you are only allowed one registerEventHandler type per game - the only exception to this rule is the mainLoop handler''. | ||
| − | + | Here is a quick example of the key event handler... | |
| − | |||
| − | Here is | ||
<syntaxhighlight> | <syntaxhighlight> | ||
| + | -- the function that is used to handle key events | ||
function keyboardHandler(eventType, character, keycode, modifiers) | function keyboardHandler(eventType, character, keycode, modifiers) | ||
| − | if eventType==eEvtKeyUp then | + | if eventType==eEvtKeyUp then -- on key released |
| − | + | print("key released: " .. character) -- prints released key name | |
| − | + | elseif eventType==eEvtKeyDown then -- key down/hold (will loop code below while held) | |
| − | + | print("key pressed: " .. character) -- print pressed key name | |
| − | + | elseif eventType==eEvtKeyTextInput then -- special characters (language characters, quotation marks etc - key down/pressed only) | |
| − | + | print("input: " .. character) -- print special character name | |
| − | elseif eventType==eEvtKeyDown then | ||
| − | print( | ||
| − | elseif eventType==eEvtKeyTextInput then | ||
| − | |||
| − | print( | ||
end | end | ||
| − | + | return false | |
| − | |||
| − | |||
| − | |||
| − | return false | ||
end | end | ||
| − | registerEventHandler("keyEvent", "keyboardHandler") | + | registerEventHandler("keyEvent", "keyboardHandler") -- the line that creates the keyEvent listener |
</syntaxhighlight> | </syntaxhighlight> | ||
| − | You need to add this line to your keyEvent handler... | + | 3. You need to add this line to your keyEvent handler... |
<syntaxhighlight> | <syntaxhighlight> | ||
if Conditions["cond_skip_cv"].ConditionValue == false and keycode == eKeyEscape then return true end | if Conditions["cond_skip_cv"].ConditionValue == false and keycode == eKeyEscape then return true end | ||
| Line 53: | Line 44: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
function keyboardHandler(eventType, character, keycode, modifiers) | function keyboardHandler(eventType, character, keycode, modifiers) | ||
| − | + | if Conditions["cond_skip_cv"].ConditionValue == false and keycode == eKeyEscape then return true end | |
| − | + | return false | |
end | end | ||
registerEventHandler("keyEvent", "keyboardHandler") | registerEventHandler("keyEvent", "keyboardHandler") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | 4. To turn on/off video/cutcene skipping: all you have to do is toggle the '''cond_skip_cv''' condition. Creating a setting for this in your options menu &/or adding this as a setting to the config.ini is entirely up to you. | ||
| Line 66: | Line 59: | ||
! style="text-align:left" | Name !! style="text-align:left" | Description | ! style="text-align:left" | Name !! style="text-align:left" | Description | ||
|- | |- | ||
| − | | - || There are no resources available, sorry. | + | | class="cent" | - || There are no resources available, sorry. |
|} | |} | ||
| − | {{ | + | {{i18n|Prevent_Video_and_Cutscene_Skipping_(h2)}} |
Latest revision as of 00:52, 4 November 2014
| Name | By |
|---|---|
| Prevent Skipping of Videos/Cutscenes | AFRLme |
This tutorial shows you how to prevent the player from being able to skip videos &/or cutscenes. Visionaire Studio 4.1+ is required for this to work. (currently only works for cutscenes).
Tutorial
Preventing skipping of videos &/or cutscenes is actually very simple. All you need is 1 condition & an event handler that listens out for the ESC key. So let's begin...
1. You should start off by creating a condition somewhere & naming it cond_skip_cv & set it to false by default if you want to prevent players from being allowed to skip videos on game start; else set condition to true.
2. Next you need to create a definition script containing a registerEventHandler for keyEvents - if you don't already have one. Quick note: you are only allowed one registerEventHandler type per game - the only exception to this rule is the mainLoop handler.
Here is a quick example of the key event handler...
-- the function that is used to handle key events
function keyboardHandler(eventType, character, keycode, modifiers)
if eventType==eEvtKeyUp then -- on key released
print("key released: " .. character) -- prints released key name
elseif eventType==eEvtKeyDown then -- key down/hold (will loop code below while held)
print("key pressed: " .. character) -- print pressed key name
elseif eventType==eEvtKeyTextInput then -- special characters (language characters, quotation marks etc - key down/pressed only)
print("input: " .. character) -- print special character name
end
return false
end
registerEventHandler("keyEvent", "keyboardHandler") -- the line that creates the keyEvent listener3. You need to add this line to your keyEvent handler...
if Conditions["cond_skip_cv"].ConditionValue == false and keycode == eKeyEscape then return true end...It tells the keyEvent handler to ignore the escape key if condition cond_skip_cv returns false.
So what you might end up with is something like...
function keyboardHandler(eventType, character, keycode, modifiers)
if Conditions["cond_skip_cv"].ConditionValue == false and keycode == eKeyEscape then return true end
return false
end
registerEventHandler("keyEvent", "keyboardHandler")4. To turn on/off video/cutcene skipping: all you have to do is toggle the cond_skip_cv condition. Creating a setting for this in your options menu &/or adding this as a setting to the config.ini is entirely up to you.
Resources
| Name | Description |
|---|---|
| - | There are no resources available, sorry. |