Script for sending Player to Cursor?

  • #1, by george-stobbartSaturday, 06. June, 16:12 3 months ago
    Hi everyone,

    maybe someone can help me out! At the beginning of my scene, I want the character to be stuck on a seat not able to walk around the scene.

    As you know, a left mouse click by default is sending the character to the position of the cursor. I had the idea, to just deactivate this and at the moment the character has freed himself to activate the script, that allows the character to be send to the cursor just like by default.

    Makes that sense? Any ideas?
    Thanks in advance,
    Tom

    Newbie

    15 Posts


  • #2, by afrlmeSaturday, 06. June, 18:17 3 months ago
    You have multiple methods/solutions that you can use here.

    1. hide your playable character & use an npc version.

    2. you can enable/disable left click from setting destination with a line of Lua script.

    game.LeftClickBehaviour = eMouseActionBehaviourDoNotSendCharacter
    1

    These are the available options...

    '0' (eMouseActionBehaviourDoNotSendCharacter): The character will not be send to the current position.

    '1' (eMouseActionBehaviourSendCharacterToCursor): Character will be send to current position.

    '2' (eMouseActionBehaviourSendCharacterToObjects): Character will be send to current position if it is a scene object.
    Quick note: if you use the scripting method, it will prevent left click from setting a new destination, however if you click on a scene object that contains an immediate execution type action & that contains action parts that update the destination position/object, then the character will move.

    3. you could change to an outfit that has a walk speed of 0, but that method is probably more hassle than it's worth as the character will be trying to change to the walk animation & won't actually be able to move anywhere.

    Imperator

    6842 Posts

  • #3, by george-stobbartSaturday, 06. June, 18:56 3 months ago
    Great, thanks!

    I found the field "GameLeftHoldBehavior" in the data structure to script it. I was wondering, that you used the line "game.LeftClickBehaviour".

    So my approuch was something like this:

    game:getLink(VGameLeftHoldBehavior) = eMouseActionBehaviourDoNotSendCharacter 

    But I'm sure it's wrong?


    game.LeftClickBehaviour = eMouseActionBehaviourDoNotSendCharacter
    If you are using it like this, what are the numbers "0", "1" and "2" for?


    Thanks,
    Tom


    Newbie

    15 Posts

  • #4, by afrlmeSaturday, 06. June, 19:32 3 months ago
    LeftClickBehaviour is for left click. & LeftHoldBehaviour is for when the mouse is held down for x amount of time & the state switches to held instead.

    eMouseActionBehaviourDoNotSendCharacter is a variable that returns the number 0, which means you can either use the variable name or the number, however for readability it's best to use the variable instead, because you will likely forget what the number is for.

    P.S: the wiki data structure is not up to date. Simon setup a Luadocs page where he has slowly been documenting the changes & new features. You can find it via the reference link on the menu at the top of the forum.

    Imperator

    6842 Posts

  • #5, by george-stobbartSaturday, 06. June, 21:41 3 months ago
    Thank you so much afrlme for those detailed information!

    You're doing a great job here in this forum, helping many people. Thumbs up!

    Kind regards,
    Tom

    Newbie

    15 Posts

  • #6, by afrlmeSaturday, 06. June, 22:41 3 months ago
    No problem. I recommend joining our discord server, where you will often find me, Simon, & Sebastian online - as well as a lot of the regular forum members. It's a lot more active & user friendly than here because people can actually have back & forth conversations without having to wait ages for someone to write a long reply. smile

    Imperator

    6842 Posts

Write post