-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvent_Instruments.cs
68 lines (50 loc) · 2.29 KB
/
Event_Instruments.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function InstrumentsServer::fixEventPhrase(%this, %phrase) {
return strReplace(%phrase, "!", ";");
}
function InstrumentsServer::getInstrumentHash(%this, %name) {
%hash = $Instruments::Server::NameToHash[%name];
if (%hash $= "") {
%crc = getStringCRC(%name);
%truncateLength = %crc >= 0 ? 6 : 7; // Need to account for the minus symbol in negative numbers
%hash = getSubStr(%crc, 0, %truncateLength);
$Instruments::Server::NameToHash[%name] = %hash;
$Instruments::Server::HashToName[%hash] = %name;
}
return %hash;
}
function InstrumentsServer::validateInstrumentIndex(%this, %instrumentIndex) {
if (_strEmpty(%instrumentIndex)) {
return false;
}
%instrument = %this.getInstrumentFromIndex(%instrumentIndex);
if (!isObject(%instrument)) {
return false;
}
return true;
}
exec("./events/playNote.cs");
exec("./events/playPhrase.cs");
exec("./events/playSong.cs");
exec("./packages.cs");
function InstrumentsServer::initEvents(%this) {
%list = "list";
%count = InstrumentsServer.instrumentCount;
for (%i = %count - 1; %i >= 0; %i--) {
%instrument = InstrumentsServer.name(%i);
if (_strEmpty(%instrument)) {
continue;
}
%list = %list SPC %instrument SPC InstrumentsServer.getInstrumentHash(%instrument);
}
registerOutputEvent("fxDTSBrick", "playNote", %list TAB "string 64 120", 0);
registerOutputEvent("fxDTSBrick", "playRandomNote", %list, 0);
registerOutputEvent("fxDTSBrick", "playPhrase", %list TAB "string 200 255", 0);
registerOutputEvent("fxDTSBrick", "playSong", %list TAB "string 200 255", 0);
registerOutputEvent("fxDTSBrick", "setSongPhrase", "int 0 19 0\tstring 200 255", 0);
registerOutputEvent("fxDTSBrick", "stopPlaying");
registerInputEvent("fxDTSBrick", "onPhraseEnd", "Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");
registerInputEvent("fxDTSBrick", "onPhraseLoop", "Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");
registerInputEvent("fxDTSBrick", "onSongEnd", "Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");
registerInputEvent("fxDTSBrick", "onSongLoop", "Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");
}
InstrumentsServer.initEvents();