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...") |
|||
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 an example (taken from the registerEventHandler examples) of the key event handler... | |
− | |||
− | Here is an example of the key event handler... | ||
<syntaxhighlight> | <syntaxhighlight> | ||
function keyboardHandler(eventType, character, keycode, modifiers) | function keyboardHandler(eventType, character, keycode, modifiers) | ||
Line 44: | Line 43: | ||
</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 |
Revision as of 13:41, 2 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.
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 an example (taken from the registerEventHandler examples) of the key event handler...
function keyboardHandler(eventType, character, keycode, modifiers)
if eventType==eEvtKeyUp then
print('key up: ' .. keycode)
-- test for '0' with character parameter
if character == '0' then print('0 released') end
-- another option to test '0' key
if keycode == 48 then print('0 released') end
elseif eventType==eEvtKeyDown then
print('key down: ' .. keycode)
elseif eventType==eEvtKeyTextInput then
-- this will also show more 'complex' unicode characters when multiple keys are used to generate a single character (e.g. Chinese characters)
print('input: ' .. character)
end
if keycode == eKeyEscape then
-- event will not be handled by engine. this means that also cutscenes can't be skipped with Escape key
return true
end
return false -- key event will also be handled by engine
end
registerEventHandler("keyEvent", "keyboardHandler")
3. 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")
Resources
Name | Description |
---|---|
- | There are no resources available, sorry. |
Template:I18nPrevent Video and Cutscene Skipping (h2)