Using wait or wait-like commands that don't interrupt mouse

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Using wait or wait-like commands that don't interrupt mouse

Post by Foxley »

So using any sort of wait command pauses the mouse movement. I'd like to be able to do things like text disappearing or fading out after so many ticks. Is this even possible? Maybe using a for loop in the main mouse cursor loop that adds ticks to a global variable? I can't quite wrap my head around it.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Timers
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

The easiest thing to do is to run the script that updates the mouse cursor position using a timer, rather than to modify the other script containing the waits.

Code: Select all

plotscript, newgame, begin
  set timer (0, 0, 1, @update mouse pos)    # timer id 0
  # create the mouse slice, and run your main loop...
end

script, update mouse pos, begin
  put slice (mouse cursor, mouse pixel x, mouse pixel y
  set timer (0, 0, 1, @update mouse pos)    # timer id 0
end
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

I finally remembered to get around trying this, and it causes an infinite loop and a black screen on load. I used the example timer in the autorun script to replace the old 'put slice/wait(1)' part. So I'm not sure at all what's up with that.

Perhaps I should use timers for everything that isn't the mouse cursor update loop? I actually tried implementing a timer for displayed text so I can pass a number of seconds as an argument to my "print text" script, and cause the text to be cleared after the declared number of seconds. That works like a charm, so I might just establish different timer ID #'s for different things and go from there.

Unfortunately this means I can't have stuff like being able to move the mouse cursor as an hourglass while things like room transitions and animations are happening.

EDIT:
NE. VER. MIND. I'm totally dumb, I forgot to take the 'wait (1)' out of the while loop for checking mouse clicks. It works!

EDIT2:
I also can't grammar. I meant that I accidentally took the 'wait (1)' out of the while loop for checking mouse clicks when I moved 'put slice (mousecursor, etc..)' out of it and into its own script. The lack of any wait command in the while loop caused the black screen and infinite loop.
Last edited by Foxley on Mon Jul 13, 2015 2:52 am, edited 2 times in total.
Post Reply