SCRMaps
/
Sign in

Taking keyboard input (MSQC)

Only one machine knows a key was pressed. MSQC turns that into a death count every machine agrees on.

8 min read

Key presses are entirely local - no other machine knows you pressed A. To act on a key you have to turn that into something every machine agrees on, and MSQC is what does it: a press raises the death count of a unit you nominate.

[MSQC]
NotTyping ; KeyDown(Q) : Cantina, 1
NotTyping ; KeyDown(W) : Cantina, 2
mouse : Mouse Loc

QCLoc : 12
QC_XY : 960, 1024
The left side is the condition and the right side is which unit's death count to raise and by how much. The mouse line makes a location follow that player's cursor.
The settings
QCUnitThe unit that carries the input. Default 58, Terran Valkyrie - leave it there, because writing or removing that unit's data stops input arriving.
QCLocThe location MSQC borrows. Never share it with one your map logic uses.
QC_XYWhere that location is parked, in pixels. The default is 128,128 - tile 4,4.
QCPlayerWho owns the input units. Default 10, which is P11.
QCDebugOn by default, and it prints debug text on screen. Turn it off with false before release.

MSQC samples the key state once per trigger execution. Without hyper triggers that is less than once a second, so most presses land between samples and vanish - which is what "I have to press it six times" is. eudTurbo is not optional here.

Enter opens the chat box, so StarCraft takes the first press. A menu opened with Enter looks like it needs two presses - that is the mechanism rather than a bug to fix, so pick another key.

Key names are Windows virtual-key names: A to Z, 0 to 9, F1 to F24, NUMPAD0 to NUMPAD9, ESC, ENTER, SPACE, TAB, BACK, DELETE, INSERT, HOME, END, PGUP, PGDN, the arrows as LEFT, UP, RIGHT and DOWN, and LSHIFT, RSHIFT, LCTRL, RCTRL, LALT, RALT. Punctuation is written literally - ` - = [ ] ' , . / - with the semicolon spelled SEMICOLON. Mouse buttons are L, R and M.

There is a second route that uses an array instead of death counts. Give an array a name with EUDRegisterObjectToNamespace and MSQC writes into it directly - taking the unshared local key state over to shared data on your behalf.

const Key_Input = PVariable();
function KeyInit() { EUDRegisterObjectToNamespace("Key", Key_Input); }

// 읽는 쪽 / reading it
if (Key_Input[cp] == 1) { /* ... */ }
The mouse works the same way: MSQC hands each player a location, P1 getting 40 and P8 getting 47.

To tell simultaneous presses apart, give each key its own bit - 1, 2, 4, 8, 16 - not 1, 2, 3. With Q=1, W=2 and E=3 you cannot tell Q+W from E.

EUDArray and death counters have the same memory layout, so there is no performance difference between them. For a plain value comparison the EUDArray takes less space, and PVariable buys nothing.

Desync, and the local player
Sign in to track your progress