How to skip intro video, with left click, not ESC key?

  • #1, by timrocketMonday, 26. March 2018, 17:21 2 years ago
    Im building an android game for a school project, can anyone think of a way to skip an intro video, or any video, with a left click? Because touchscreen has no ESC key

    thanks

    Newbie

    9 Posts


  • #2, by afrlmeMonday, 26. March 2018, 18:25 2 years ago
    Im building an android game for a school project, can anyone think of a way to skip an intro video, or any video, with a left click? Because touchscreen has no ESC key

    thanks
    You can create events with Lua script, which means it's possible to simulate pressing the escape key.

    function mouseEvt(typ, pos) 
     if typ == eEvtMouseLeftButtonUp and Conditions["cutscene"].ConditionValue then
      createEvent('eEvtKeyDown',{x=0,y=0},eKeyEscape,0) -- simulate escape key pressed
      Conditions["cutscene"].ConditionValue = false -- set cutscene condition back to false
     end
    end

    registerEventHandler("mouseEvent", "mouseEvt")

    For this to work you will need to create a condition somewhere in the editor. Call it cutscene & set the default value to false. Now what you will need to do is create a set condition action part linking to that condition just before the play video action part to set the condition to true. You could also use this for wrapping around any begin/end cutscene action parts you create too as any action parts you insert between begin & end cutscene action parts can be skipped with ESC too.

    Not sure if this will work as it's written off the top of my head, but worth a try I guess.

    P.S: add the script to the script section & make sure the script type is set as definition in the properties section.

    P.P.S: tried to add the script inside of a code block but the forum is messing up the code block for some reason & is inserting html tags into it. Strange.

    Imperator

    6842 Posts

  • #3, by SimonSMonday, 26. March 2018, 18:32 2 years ago
    Events during movie go through another loop, so you need add a function that takes movie events:

    function movieEvent(eventType, keycode)
    -- eventType: mouseDown | mouseUp | touchDown | touchUp | controllerDown | controllerUp
    -- keycode: position or keycode
      if eventType == "controllerUp" and keycode == 1000007 then
        createEvent('eEvtKeyDown', {x=0,y=0}, eKeyEscape, 0)
        createEvent('eEvtKeyUp', {x=0,y=0}, eKeyEscape, 0)
      end
      if eventType == "mouseUp" and keycode.x >;= 100 then
        createEvent('eEvtKeyDown', {x=0,y=0}, eKeyEscape, 0)
        createEvent('eEvtKeyUp', {x=0,y=0}, eKeyEscape, 0)
      end
    end 
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    Thread Captain

    1369 Posts

  • #4, by afrlmeMonday, 26. March 2018, 19:33 2 years ago
    Didn't realize we had a function for handling key/mouse input during movies. Do we not need to register the function with registerEventHandler?

    Also I'm curious as to why createEvent for keyboard input requires the x,y tables & the number at the end. Don't know if you or David ever bothered explaining the reason why.

    Imperator

    6842 Posts

  • #5, by sebastianMonday, 26. March 2018, 21:22 2 years ago
    Events during movie go through another loop, so you need add a function that takes movie events:

    function movieEvent(eventType, keycode)
    -- eventType: mouseDown | mouseUp | touchDown | touchUp | controllerDown | controllerUp
    -- keycode: position or keycode
      if eventType == "controllerUp" and keycode == 1000007 then
        createEvent('eEvtKeyDown', {x=0,y=0}, eKeyEscape, 0)
        createEvent('eEvtKeyUp', {x=0,y=0}, eKeyEscape, 0)
      end
      if eventType == "mouseUp" and keycode.x >;= 100 then
        createEvent('eEvtKeyDown', {x=0,y=0}, eKeyEscape, 0)
        createEvent('eEvtKeyUp', {x=0,y=0}, eKeyEscape, 0)
      end
    end 
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    could you add that to the lua docs? :O

    Thread Captain

    2337 Posts

  • #6, by SimonSTuesday, 27. March 2018, 00:40 2 years ago
    The function just needs to be in global scope and the engine will find it.

    David built the createEvent function like that, it always requires 4 arguments.

    Updating documentation takes a lot of my programming time away, so I don't regularly do it, most of these are things I wrote a year ago for the console port, where they needed something every day.

    Thread Captain

    1369 Posts

  • #7, by timrocketTuesday, 27. March 2018, 01:05 2 years ago
    thanks for the help all, im not quite sure how to use scripts yet. Im learning how to use visionaire via trial and error on a test game before working on my actual game. Glad this software exists, i would never be able to wrap my head around all that code..

    i am planning ot make a long-ish intro video for the game, but I dont want players to have to watch the whole thing everytime if theyve seen it

    Newbie

    9 Posts

  • #8, by timrocketWednesday, 04. April 2018, 04:47 2 years ago
    could not get the script to work. Did i need to rename any of the names in the script and am i executing the script in the write way?

    thanks

    Newbie

    9 Posts

  • #9, by afrlmeWednesday, 04. April 2018, 14:47 2 years ago
    Not sure about renaming anything, but the script Simon provided was just an example. You are supposed to create a script in the script section of the editor & add the script to that. When you create a new script it will be set as a "definition" script by default which means that it will load & be accessible as soon as the game is launched, which is the behaviour we need seeing as it's a function.

    Also the script is broken because the forum sometimes strangely add semi-colons; into the code blocks for some reason. They aren't supposed to be there.

    use this one...
    function movieEvent(eventType, keycode)
    -- eventType: mouseDown | mouseUp | touchDown | touchUp | controllerDown | controllerUp
    -- keycode: position or keycode
      if eventType == "controllerUp" and keycode == 1000007 then
        createEvent('eEvtKeyDown', {x=0,y=0}, eKeyEscape, 0)
        createEvent('eEvtKeyUp', {x=0,y=0}, eKeyEscape, 0)
      end
      if eventType == "mouseUp" and keycode.x >= 100 then
        createEvent('eEvtKeyDown', {x=0,y=0}, eKeyEscape, 0)
        createEvent('eEvtKeyUp', {x=0,y=0}, eKeyEscape, 0)
      end
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12


    I don't understand what keycode.x is in the function Simon shared.

    Imperator

    6842 Posts

Write post