EventRegisterHandler question

  • #1, by nicholas-chanSunday, 18. May, 05:15 4 days ago
    Greetings to the world of visionaire studio,

    I was wondering, is there an registerEventHandler() argument that calls the function based on whether any object area has been entered?

    Kind Regards,

    Nick

    Newbie

    22 Posts


  • #2, by afrlmeMonday, 19. May, 20:55 2 days ago
    You could listen out for if anything is below the mouse cursor inside of a mainLoop function - or mouse event handler - along with a variable to make sure it only fires off once per mouse enters/leaves or however you want it to work.
    local hState = false
    
    function hoverState()
    
    if game.CurrentObject ~= empty and not hState then
    
    hState = true -- limit to single execution of code below
    -- insert code here to execute on hover over anything
    
    elseif game.CurrentObject == empty and hState then
    
    hState = false -- limit to single execution of code below
    -- insert code here to execute on mouse out
    
    end
    
    registerEventHandler("mainLoop", "hoverState")

    You could pad that out further with additional if queries so it only works on scene objects, interface buttons, only on scenes the playable character is on, or only in non-menu type scenes, etc.

    Imperator

    7288 Posts

  • #3, by afrlmeWednesday, 21. May, 14:13 9 hours ago
    Oops, sorry. The forum decided to mess up a bit there. I tried to quote your post but my moderator perks seem to have deleted it instead. My bad.

    To answer your question, no the script you posted wouldn't have done what you expected as the syntax was incorrect. When accessing conditions you need to include .Value at the end of them to return the boolean value they contain. Simply linking to the condition itself only returns the table ID. I'm not really sure what you are trying to do with the tooltips, but VS already has a built in action text system that automatically displays text near the cursor or in a bounding box or not at all depending on what you setup in the game properties section of the VS editor. Alternatively you can also use Lua draw & 9rect to create dynamic speech bubble type texts.

    In regard to toggling between active & inactive image state of interface buttons via script, I'm not sure if you can. I think it has to be done via action parts - however you could instead add the images to the inactive image bit of the button & assign a value or condition to the properties of the button to control when it will be shown or hidden based on the state of the linked condition, or the integer value of the linked value. That's how a lot of us control when things should be hidden or visible. Alternative is to hide/show things via the Visibility data structure field, if available. Linking a condition or value is safer though as the data belonging to those get stored in save game file data.

    P.S: Again, sorry for accidentally deleting your last post. I barely use the forum these days as I'm always having random issues with it. Most of us use the official Discord server instead as it's a lot more convenient & you will get a reply much faster than on here, or you may even get to have a back & forth conversation with one of the moderators or other VS community members. It's pretty friendly & there's usually always people willing to help out fellow devs on there.

    https://discord.gg/g5zFejW

    Imperator

    7288 Posts

Write post