[Solved] Maintain Action text until action is performed

  • #10, by sebastianTuesday, 13. June 2017, 22:37 4 years ago
    i guess as long as something is inside this field:

    GameDestinationCommand 

    the user walks to a destination object and will execute the containing command. Maybe you cqn do something with this... 


    Thread Captain

    2343 Posts


  • #11, by marco-roncoTuesday, 13. June 2017, 22:46 4 years ago
    @sebastian

    Yep, I'm trying something with that right now smile


    function Myaction(mousePos) 
     local obj = game:getLink(VGameCurrentObject)
     local verb = game:getLink(VGameActiveCommand):getTextStr(VButtonName)
     local obj_name = obj:getTextStr(VObjectName)
     local targetObjPoint = game:getObject("Characters[Akio]"):getPoint(VCharacterDestinationObject)

    if (verb ~= null and game.SavedObject:isEmpty()) then
     return verb .. ' ' .. obj_name
    else 
    -- check if character destination object and current position are the same
    return 'my custom phrase'
    end

    end

    registerHookFunction("getActionText", "Myaction")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    Don't know if I'm in the right way, still trying smile

    Newbie

    21 Posts

  • #12, by sebastianTuesday, 13. June 2017, 23:53 4 years ago
    got it (nearly), without a single line of Lua. 

    You have to save the object and execute the command on the object if object under cursor is scene object or character. This will "freeze" your action text.

    The downside is there is no good way to reset it. You have to call the clear saved object action part every time it needs to go to the normal state again. Manually you could add this as a last action part of each action you have on each object/character and also add an action for the goto/walk command... Would work but it is definitely weird like that.

    there is surely a better way in lua to reset it (maybe even with the mentioned GameDestinationCommand ...) razz


    Thread Captain

    2343 Posts

  • #13, by marco-roncoWednesday, 14. June 2017, 00:06 4 years ago
    @sebastian

    Really? °_°

    Please could you explain me the process? Because I'm already doing that!

    Save Object
    if object below cursor exist
    Execute command on saved object
    end if
    1
    2
    3
    4
    5

    ...but if i move the mouse outside the object while character is moving, the action text removes the object name.

    A workaround would be:

    Save Object
    if object below cursor exist
    Wait for character to stop
    Execute command on saved object
    end if
    1
    2
    3
    4
    5

    But this way, if someone left-click while character is moving, weird things happens (the command is executed on another object and so on)

    Newbie

    21 Posts

  • #14, by sebastianWednesday, 14. June 2017, 00:31 4 years ago
    Thats my global left click action:

    Thread Captain

    2343 Posts

  • #15, by marco-roncoWednesday, 14. June 2017, 00:56 4 years ago
    Thanks @sebastian smile

    My previous solution was somehow like yours.
    This solutions does weird behaviours when you click on Items
    (eg. Use X with Y or Give X to Y)

    To fix that, my Solution was the one in attached image.

    With that solution the object will be cleared after execution,
    and the action text will remain.

    ..but... (yeah yeah, there is a bug).
    If you clik on an object/character while your character is moving,
    the action will be perfomed on the second-click target.

    But it is late right now ^-^ I'll try my best tomorrow.
    Many thanks for your help! smile

    Newbie

    21 Posts

  • #16, by gabartsWednesday, 14. June 2017, 13:15 4 years ago
    First, why a player should click to another hotspot when is doing a certain action? smile
    For example I've just used under mouse left click the action for resetting to walk to when clicking on an empty spot in the scene. Reading this I think the easiest solution is not using LUA and instead setting something more other than save object, like for example send character to object?!

    Because wait until character stops is not working and I've seen even using right click at destination I've manually added send character to object (the only way to save the action).
    @Marco (I've left my phone at home, i'm in office)
    Have you tried in my template to perform action with right click on object and then clicking to another hotspot with right mouse?

    Forum Fan

    136 Posts

  • #17, by afrlmeWednesday, 14. June 2017, 13:27 4 years ago
    ..but... (yeah yeah, there is a bug).
    If you clik on an object/character while your character is moving,
    the action will be perfomed on the second-click target.
    Not a bug. Unless you use execute immediate commands & begin/end cutscene or hide/show cursor wrappers then the player reserves the right to cancel their current order by left or right clicking anywhere else on the scene.

    Imperator

    6932 Posts

  • #18, by sebastianWednesday, 14. June 2017, 13:32 4 years ago
    @gabarts

    Its an indicator what the playable character is going to do when he/she reaches the destination. And that seems to be more relevant than knowing whats currently under the cursor... 
    Its used un the LucasArts games... so it must be good smile 

    But in reality it doesn't have any practical advantage. Its just a small little detail... 

    Thread Captain

    2343 Posts

  • #19, by marco-roncoWednesday, 14. June 2017, 18:24 4 years ago
    First of all, thanks to @gabarts @sebastian and @AFRLme for the feedbacks smile

    I managed to have something very like SCUMM action text, so I would like to share how it works, if someone needs it too.

    SCUMM-Like action text

    1) As Sebastian suggests, you will need to have an action on your "Left Click" action, located in the "Cog" menu of Visionaire.

    2) The script should look like this:

    if object below cursor exists
     Save Object
     Execute command on saved object
     Wait until character 'Current character' stops
     Clear saved object
     Set standard command
    Else
     Clear saved object
     Set standard command
    End if
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    This way you can have the action text "freezed" until the action is performed.
    If you click on a non-existant object, the command will be set to "Walk to" (or your default command).

    Optional: highlight text during action

    1) Create 2 fonts: call the first one "Font_Action_Diag" and make it grey.
         Create the second font: call il "Font_Action_Diag_Highlight" and make it white.

    2) Go to "Interface" button in Visionaire.
    2a) Create a new interface, call it "Action_Text_Area"
    2b) Create a button inside this interface,
    2c) choose the Button Type "Action Area".

    2d) Draw the text with the [T] icon. Make sure you have "Do not draw action text" as choiche in your Game proprieties tab (Cog icon).

    3) Create two execution scripts (you have to go in the { } menu in Visionaire, and uncheck "definition script".

    First script: call it "blink"
    local activateFont = getObject("Fonts[Font_Action_Diag_Highlight]")
    local action_interface = getObject("Interfaces[Action_Text_Area]")
    action_interface:setValue(VInterfaceActionTextFont, activateFont)
    1
    2
    3

    Second script: call il "blonk"
    local activateFont = getObject("Fonts[Font_Action_Diag]")
    local action_interface = getObject("Interfaces[Action_Text_Area]")
    action_interface:setValue(VInterfaceActionTextFont, activateFont)
    1
    2
    3
    4

    4) Modify the script you created before (SCUMM-Like action text, that is inside your mouse left click action) like this:

    Call script 'blink'
    if object below cursor exists
     Save Object
     Execute command on saved object
     Wait until character 'Current character' stops
     Clear saved object
     Set standard command
    Else
     Clear saved object
     Set standard command
    End if
    Call script 'blonk'
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    That's it smile Hope it helps!

    PS: I'm not a script Ninja™ like AFRLme, there is a better way to do it for sure smile

    Newbie

    21 Posts

  • #20, by sebastianWednesday, 14. June 2017, 18:37 4 years ago
    great news you managed it smile 

    I also got it working with a similar method a few hours ago but still had struggle to clean it up a little. 

    You could move your 

    •  Clear saved object
    •  Set standard command

    under the if/else and remove the else branch completely by the way because of redundancy smile

    Will do also a video about it in a few weeks (after i did a lua crash course for the viewers). 

    Thread Captain

    2343 Posts

Write post