Best way to stop a character from being able to move (tied to a chair)

  • #1, by andiliddellSunday, 09. February 2014, 01:32 11 years ago
    Hi

    I was hoping someone can help me.

    My character starts a scene tied to a chair, complete with an outfit which is the sitting animation, and the talking animations whilst sat down. I even have some custom animations for reaching other objects close to the character, like leaning on the chair

    I need to make sure the player can't move the character anywhere until they have managed to escape the ropes. I've tried setting no way system, setting a tiny way system in the corner with the character start outside it, but every time I get the same issue. the player can click anywhere in the scene and the seated character just slides across the scene to the place clicked. Ive tried character speed zero, and even creating a "click catching" object across the whole scene with a stop character action on it. This kinda worked but left my cursor constantly active.

    I'm sure there must be a "disable all movements" but i thought that's what a blank way system was for?

    I've contemplated hiding the character and setting all of the animations as object animations instead whilst you try to escape then swap back out to character once you're free, but this seems like overkill for what i imagine is very simple problem to solve.

    Any help is much appreciated.

    Cheers smile

    Forum Fan

    178 Posts


  • #2, by afrlmeSunday, 09. February 2014, 02:35 11 years ago
    blank way system just means the scene has no defined borders.

    what you could do is set a very tiny way border where the character will be placed; taking into consideration that the character position is based on the characters animation center. if you created a 1x1px border then the character shouldn't be able to move.

    also in the Game tab is a setting which allows you to prevent the player from interacting with the scene during certain parameters, such as: during manually started character animations or all character animations in general. also you could set the animations inside of cutscene begin/end action parts or hide the mouse cursor until the currently playing animation has finished.

    personally I don't see how the animations as objects would be any more work than trying to get the character to stay still as there is no way to turn off "standard execution" of the left mouse button via the editor or via Lua script. having said that it is possible to have stop character with action parts or via the mouseEvent handler, but stop character essentially kills character animations/walking & resets character back to idle/standing animation state - I think.

    I will ask David about whether it would be possible to add an action part for preventing character from moving into the next release or a future release or whether there is a simple workaround method that could be employed. Or maybe someone else on here has some ideas?

    Imperator

    7285 Posts

  • #3, by andiliddellSunday, 09. February 2014, 02:48 11 years ago
    Hey thanks AFRLme, much appreciated. I might give the 1x1 pixel walk area a try.

    I wanted to try and keep the character as a character instead of an object as i wasn't sure how to get the display text to appear in the right place if it was an object. but i'm sure there's a way round that too.

    I seem to remember reading about "speaker text" which can be positioned wherever you like which might be a neat solution.

    thanks for the response, Ill let you know how i get on smile

    Forum Fan

    178 Posts

  • #4, by afrlmeSunday, 09. February 2014, 03:28 11 years ago
    yeah speaker text (should really be called narration text) under miscellaneous allows absolute positioning so it would be simple enough to place the text where you need it. you would have to add the speaking animation to the "character animation" section & trigger it manually.

    Imperator

    7285 Posts

  • #5, by andiliddellSunday, 09. February 2014, 03:35 11 years ago
    the 1x1 walkable area worked well,Thanks for that tip..... however i now have a further problem the characters display text is getting pushed right up on the top of the screen and over to the left instead of just above my character?. (not sure why? chracter centre is fine?)

    I've read another post about using a script to hook the display function and reposition it, but the code below wont work? any ideas would be gratefully received?

    function setTextPosHook(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      if text:getLink(VTextOwner):getName() == "chicken" and game:getLink(VGameCurrentScene):getName() == "03_inside_hut" then
       text:setValue(VTextPosition, {x=500, y=300})
      end if
     end if
    end
    
    registerHookFunction("setTextPosition", "setTextPosHook")
    
    

    Forum Fan

    178 Posts

  • #6, by afrlmeSunday, 09. February 2014, 03:50 11 years ago
    did you set the script as a definition script via its properties tab?

    if the script is set as an execution script then it won't work until the script is called, whereas definition scripts are run on game launch.

    also: there is no if on the end of end in Lua script. did you write it or copy/paste & edit it & did it have the if on the end of the end parts? if it did & I wrote it, then I must have been on some funny juice!
    function setTextPosHook(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      if text:getLink(VTextOwner):getName() == "chicken" and game:getLink(VGameCurrentScene):getName() == "03_inside_hut" then
       text:setValue(VTextPosition, {x=500, y=300})
      end
     end
    end
    
    registerHookFunction("setTextPosition", "setTextPosHook")
    


    P.S: does it give any errors in the log in regards to the text being pushed away from the character or in regards to the script?

    Imperator

    7285 Posts

  • #7, by andiliddellSunday, 09. February 2014, 04:02 11 years ago
    whoops I added the ifs to a script you wrote, in a vain attempt to get it working, dont worry you haven't been on the juice smile

    I've set is as definition script, but it does nothing unfortunately. Is the x,y relative to the character or the main game screen? the text doesn't move at all from its original position

    The issue is the custom animation of my character tied up is close to the edge of the screen, and taller than a standard character sprite, so his display text is off centre and too high. I really want to take advantage of having his talking animations automate for the length of the dialogue too.

    Is there any other reason the text might not re-position?

    Forum Fan

    178 Posts

  • #8, by afrlmeSunday, 09. February 2014, 04:47 11 years ago
    characters too close to the edge of the scene/screen can sometimes offset the text. the x, y position of the script is based on the scene as a whole. I think the text position you set is where the center of the text will be. I believe it would technically be possible to have it offset from the default character text position by storing the initial value first & then offsetting it in the setValue part.
    -- untested example...
    local pos = text:getPoint(VTextPosition)
    text:setValue(VTextPosition, {x = pos.x - 100, y = pos.y + 200})
    

    technically you could still use narration text & manually start the talking animation via an action part just before the display speaker text action part & then another action part afterwards to change the animation back to another one. one of the nice things about VS is that there are always plenty of different ways to achieve or workaround things.

    could you check the messages.txt log file for errors please?

    Imperator

    7285 Posts

  • #9, by andiliddellSunday, 09. February 2014, 11:58 11 years ago
    Thanks for the fast reply, unfortunately sleep got the better of me just after 3am smile

    This morning with a fresh head, and the new knowledge of the messages.txt log you pointed out, I've managed to very quickly pinpoint the problem.

    It appears the hook function 'setTextPosHook' must return a boolean value. I added a simple "return true" within the function and it worked a charm.

    I can't find the lua documentation for the original setTextPosition function anywhere so i'm not actually sure what the returned boolean value is doing but If i set it to false nothing happens, so it must be pretty important smile

    Is there a good reference anywhere to all of the inbuilt lua functions, I'm originally from an AS3 background and was so reliant on the ASdocs when i first learnt many moons ago.

    
    function setTextPosHook(text)
    
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      if text:getLink(VTextOwner):getName() == "chicken" and game:getLink(VGameCurrentScene):getName() == "03_inside hut" then
       text:setValue(VTextPosition, {x= game:getPoint(VGameWindowResolution).x/2, y=500})
      end
     end
    return true
    end
    
    registerHookFunction("setTextPosition", "setTextPosHook")
    
    

    Forum Fan

    178 Posts

  • #10, by afrlmeSunday, 09. February 2014, 12:26 11 years ago
    I forgot about the return true bit, not sure why it needs it.

    here's the official documentation page for it: http://wiki.visionaire-tracker.net/wiki/RegisterHookFunction - I haven't added an example to it yet.

    so you are centering the text to the center of the screen now? smile

    the pages for the exclusive vs lua functions are:
    http://wiki.visionaire-tracker.net/wiki/Player_Commands
    http://wiki.visionaire-tracker.net/wiki/Common_Commands

    & this is a list of scriptable & read-only actions/options for the editor:
    http://wiki.visionaire-tracker.net/wiki/Data_Structure

    & finally: this page gives a quick introduction to scripting in vs: http://wiki.visionaire-tracker.net/wiki/Scripting

    should be of some use to you. I've provided multiple examples for most of the player command functions.

    Imperator

    7285 Posts

  • #11, by andiliddellSunday, 09. February 2014, 12:52 11 years ago
    Excellent thanks so much for the help.

    Yep I've got the text nicely centred now, and feel in control of all my dialogue now.

    Typically, now I've cleared this hurdle I've been able to continue development for a few hours and I've come across another gap in my knowledge.

    Ill start a new thread for it as its unrelated. (custom command property names for certain objects)

    Thanks for the help with this one smile

    Forum Fan

    178 Posts