The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Possible Unit Comparison bug?
01-09-2014, 02:12 AM
Post: #1
Possible Unit Comparison bug?
Hey, I was trying to figure out how to program a key to behave differently with a short press and a long press, and came across something that I suspect is a bug.

Code:
KEY K_7()
BEGIN
LOCAL time;
time:=TIME(KeyTimer(32));
IF time<0.5_s THEN
  RETURN "7";
ELSE
  RETURN "It worked!";  
END;
END;

EXPORT KeyTimer(key)
BEGIN
WHILE ISKEYDOWN(key) DO
END;
END;

Simple as that is, it simply would not work until I did this:

Code:
time:=TIME(KeyTimer(32))/1_s;
IF time<0.5 THEN

This despite the fact that comparatives seem to work just fine on units in the Home screen. Is this a bug, or do I need to do something to prep the unit object in the first bit of code?

Also, not a bug but something worth knowing: I originally tried to use GETKEY in place of the key number of 32, but it didn't work. The KEY function must use GETKEY to return the key number, so when you do it again you get -1.

P.S. I eventually redid the whole thing using TICKS rather than TIME, but I still think the potential bug is worth mentioning.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Possible Unit Comparison bug? - The Shadow - 01-09-2014 02:12 AM



User(s) browsing this thread: 1 Guest(s)