overpy 9.6.8 → 9.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/overpy.js +156 -35
- package/package.json +1 -1
package/overpy.js
CHANGED
|
@@ -39408,7 +39408,8 @@ function addSubroutine(content, index, fileStack7, isFromDefStatement = false) {
|
|
|
39408
39408
|
name: content,
|
|
39409
39409
|
index: index ?? subroutines.length,
|
|
39410
39410
|
fileStack: fileStack7,
|
|
39411
|
-
isFromDefStatement
|
|
39411
|
+
isFromDefStatement,
|
|
39412
|
+
callsSubroutines: []
|
|
39412
39413
|
});
|
|
39413
39414
|
}
|
|
39414
39415
|
function translateNameToAvoidKeywords(initialName, nameType) {
|
|
@@ -43906,6 +43907,23 @@ astParsingFunctions.__assignTo__ = function(content) {
|
|
|
43906
43907
|
return content;
|
|
43907
43908
|
};
|
|
43908
43909
|
|
|
43910
|
+
// src/compiler/functions/__callSubroutine__.ts
|
|
43911
|
+
astParsingFunctions.__callSubroutine__ = function(content) {
|
|
43912
|
+
let parent = content.parent;
|
|
43913
|
+
while (parent?.parent) {
|
|
43914
|
+
parent = parent.parent;
|
|
43915
|
+
}
|
|
43916
|
+
if (parent?.name === "__rule__") {
|
|
43917
|
+
if (parent.ruleAttributes?.subroutineName) {
|
|
43918
|
+
let subroutine = subroutines.find((x) => x.name === parent.ruleAttributes?.subroutineName);
|
|
43919
|
+
if (!subroutine.callsSubroutines.includes(content.args[0].name)) {
|
|
43920
|
+
subroutine.callsSubroutines.push(content.args[0].name);
|
|
43921
|
+
}
|
|
43922
|
+
}
|
|
43923
|
+
}
|
|
43924
|
+
return content;
|
|
43925
|
+
};
|
|
43926
|
+
|
|
43909
43927
|
// src/compiler/functions/__customString__.ts
|
|
43910
43928
|
astParsingFunctions.__customString__ = function(content) {
|
|
43911
43929
|
if (!content.stringTokens) {
|
|
@@ -46022,6 +46040,9 @@ astParsingFunctions.asinDeg = function(content) {
|
|
|
46022
46040
|
return content;
|
|
46023
46041
|
};
|
|
46024
46042
|
|
|
46043
|
+
// src/compiler/functions/async.ts
|
|
46044
|
+
astParsingFunctions.async = astParsingFunctions.__callSubroutine__;
|
|
46045
|
+
|
|
46025
46046
|
// src/compiler/functions/atan2.ts
|
|
46026
46047
|
astParsingFunctions.atan2 = function(content) {
|
|
46027
46048
|
if (enableOptimization) {
|
|
@@ -46042,14 +46063,6 @@ astParsingFunctions.atan2Deg = function(content) {
|
|
|
46042
46063
|
return content;
|
|
46043
46064
|
};
|
|
46044
46065
|
|
|
46045
|
-
// src/compiler/functions/attacker.ts
|
|
46046
|
-
astParsingFunctions.attacker = function(content) {
|
|
46047
|
-
if (["global", "eachPlayer", "playerDealtHealing", "playerReceivedHealing", "playerJoined", "playerLeft"].includes(currentRuleEvent)) {
|
|
46048
|
-
error("Cannot use '" + content.name + "' with rule event '" + currentRuleEvent + "'");
|
|
46049
|
-
}
|
|
46050
|
-
return content;
|
|
46051
|
-
};
|
|
46052
|
-
|
|
46053
46066
|
// src/compiler/functions/break.ts
|
|
46054
46067
|
astParsingFunctions.break = function(content) {
|
|
46055
46068
|
let innermostStructure = content.parent;
|
|
@@ -46595,12 +46608,88 @@ astParsingFunctions.dotProduct = function(content) {
|
|
|
46595
46608
|
|
|
46596
46609
|
// src/compiler/functions/eventPlayer.ts
|
|
46597
46610
|
astParsingFunctions.eventPlayer = function(content) {
|
|
46598
|
-
|
|
46599
|
-
|
|
46611
|
+
let categories = {
|
|
46612
|
+
eventPlayer: ["player"],
|
|
46613
|
+
attacker: ["damage"],
|
|
46614
|
+
victim: ["damage"],
|
|
46615
|
+
eventDamage: ["damage"],
|
|
46616
|
+
eventWasEnvironment: ["damage"],
|
|
46617
|
+
healer: ["healing"],
|
|
46618
|
+
healee: ["healing"],
|
|
46619
|
+
eventHealing: ["healing"],
|
|
46620
|
+
eventWasHealthPack: ["healing"],
|
|
46621
|
+
eventWasCriticalHit: ["damageOrHealing"],
|
|
46622
|
+
eventAbility: ["damageOrHealing"],
|
|
46623
|
+
eventDirection: ["damageOrHealing"]
|
|
46624
|
+
}[content.name];
|
|
46625
|
+
let ruleEventCategories = getRuleEventCategories(currentRuleEvent);
|
|
46626
|
+
if (currentRuleEvent === "__subroutine__") {
|
|
46627
|
+
let parent = content.parent;
|
|
46628
|
+
while (parent?.parent) {
|
|
46629
|
+
parent = parent.parent;
|
|
46630
|
+
}
|
|
46631
|
+
if (parent?.name === "__rule__") {
|
|
46632
|
+
if (parent.ruleAttributes?.subroutineName) {
|
|
46633
|
+
let subroutine = subroutines.find((x) => x.name === parent.ruleAttributes?.subroutineName);
|
|
46634
|
+
if (categories?.includes("player")) {
|
|
46635
|
+
subroutine.hasEventPlayerVars = true;
|
|
46636
|
+
}
|
|
46637
|
+
if (categories?.includes("damage")) {
|
|
46638
|
+
subroutine.hasEventDamageVars = true;
|
|
46639
|
+
}
|
|
46640
|
+
if (categories?.includes("healing")) {
|
|
46641
|
+
subroutine.hasEventHealingVars = true;
|
|
46642
|
+
}
|
|
46643
|
+
if (categories?.includes("damageOrHealing")) {
|
|
46644
|
+
subroutine.hasEventDamageOrHealingVars = true;
|
|
46645
|
+
}
|
|
46646
|
+
}
|
|
46647
|
+
}
|
|
46648
|
+
} else {
|
|
46649
|
+
if (ruleEventCategories && categories && !categories.some((c) => ruleEventCategories.includes(c))) {
|
|
46650
|
+
if (["eventPlayer", "attacker", "victim", "healer", "healee"].includes(content.name)) {
|
|
46651
|
+
error("Cannot use '" + content.name + "' with rule event '" + currentRuleEvent + "'");
|
|
46652
|
+
} else {
|
|
46653
|
+
warn("w_mismatched_event", "Cannot use '" + content.name + "' with rule event '" + currentRuleEvent + "'");
|
|
46654
|
+
}
|
|
46655
|
+
}
|
|
46600
46656
|
}
|
|
46601
46657
|
return content;
|
|
46602
46658
|
};
|
|
46603
46659
|
|
|
46660
|
+
// src/compiler/functions/attacker.ts
|
|
46661
|
+
astParsingFunctions.attacker = astParsingFunctions.eventPlayer;
|
|
46662
|
+
|
|
46663
|
+
// src/compiler/functions/eventAbility.ts
|
|
46664
|
+
astParsingFunctions.eventAbility = astParsingFunctions.eventPlayer;
|
|
46665
|
+
|
|
46666
|
+
// src/compiler/functions/eventDamage.ts
|
|
46667
|
+
astParsingFunctions.eventDamage = astParsingFunctions.eventPlayer;
|
|
46668
|
+
|
|
46669
|
+
// src/compiler/functions/eventDirection.ts
|
|
46670
|
+
astParsingFunctions.eventDirection = astParsingFunctions.eventPlayer;
|
|
46671
|
+
|
|
46672
|
+
// src/compiler/functions/eventHealing.ts
|
|
46673
|
+
astParsingFunctions.eventHealing = astParsingFunctions.eventPlayer;
|
|
46674
|
+
|
|
46675
|
+
// src/compiler/functions/eventWasCriticalHit.ts
|
|
46676
|
+
astParsingFunctions.eventWasCriticalHit = astParsingFunctions.eventPlayer;
|
|
46677
|
+
|
|
46678
|
+
// src/compiler/functions/eventWasEnvironment.ts
|
|
46679
|
+
astParsingFunctions.eventWasEnvironment = astParsingFunctions.eventPlayer;
|
|
46680
|
+
|
|
46681
|
+
// src/compiler/functions/eventWasHealthPack.ts
|
|
46682
|
+
astParsingFunctions.eventWasHealthPack = astParsingFunctions.eventPlayer;
|
|
46683
|
+
|
|
46684
|
+
// src/compiler/functions/healee.ts
|
|
46685
|
+
astParsingFunctions.healee = astParsingFunctions.eventPlayer;
|
|
46686
|
+
|
|
46687
|
+
// src/compiler/functions/healer.ts
|
|
46688
|
+
astParsingFunctions.healer = astParsingFunctions.eventPlayer;
|
|
46689
|
+
|
|
46690
|
+
// src/compiler/functions/victim.ts
|
|
46691
|
+
astParsingFunctions.victim = astParsingFunctions.eventPlayer;
|
|
46692
|
+
|
|
46604
46693
|
// src/compiler/functions/floor.ts
|
|
46605
46694
|
astParsingFunctions.floor = function(content) {
|
|
46606
46695
|
if (enableOptimization) {
|
|
@@ -46655,22 +46744,6 @@ astParsingFunctions.getOppositeTeam = function(content) {
|
|
|
46655
46744
|
return content;
|
|
46656
46745
|
};
|
|
46657
46746
|
|
|
46658
|
-
// src/compiler/functions/healee.ts
|
|
46659
|
-
astParsingFunctions.healee = function(content) {
|
|
46660
|
-
if (["global", "eachPlayer", "playerTookDamage", "playerDealtDamage", "playerDealtFinalBlow", "playerDied", "playerEarnedElimination", "playerJoined", "playerLeft", "playerDealtKnockback", "playerReceivedKnockback"].includes(currentRuleEvent)) {
|
|
46661
|
-
error("Cannot use '" + content.name + "' with rule event '" + currentRuleEvent + "'");
|
|
46662
|
-
}
|
|
46663
|
-
return content;
|
|
46664
|
-
};
|
|
46665
|
-
|
|
46666
|
-
// src/compiler/functions/healer.ts
|
|
46667
|
-
astParsingFunctions.healer = function(content) {
|
|
46668
|
-
if (["global", "eachPlayer", "playerTookDamage", "playerDealtDamage", "playerDealtFinalBlow", "playerDied", "playerEarnedElimination", "playerJoined", "playerLeft", "playerDealtKnockback", "playerReceivedKnockback"].includes(currentRuleEvent)) {
|
|
46669
|
-
error("Cannot use '" + content.name + "' with rule event '" + currentRuleEvent + "'");
|
|
46670
|
-
}
|
|
46671
|
-
return content;
|
|
46672
|
-
};
|
|
46673
|
-
|
|
46674
46747
|
// src/compiler/functions/hsl.ts
|
|
46675
46748
|
astParsingFunctions.hsl = function(content) {
|
|
46676
46749
|
let h = "$h";
|
|
@@ -47134,14 +47207,6 @@ astParsingFunctions.vectorTowards = function(content) {
|
|
|
47134
47207
|
return content;
|
|
47135
47208
|
};
|
|
47136
47209
|
|
|
47137
|
-
// src/compiler/functions/victim.ts
|
|
47138
|
-
astParsingFunctions.victim = function(content) {
|
|
47139
|
-
if (["global", "eachPlayer", "playerDealtHealing", "playerReceivedHealing", "playerJoined", "playerLeft"].includes(currentRuleEvent)) {
|
|
47140
|
-
error("Cannot use '" + content.name + "' with rule event '" + currentRuleEvent + "'");
|
|
47141
|
-
}
|
|
47142
|
-
return content;
|
|
47143
|
-
};
|
|
47144
|
-
|
|
47145
47210
|
// src/compiler/functions/wait.ts
|
|
47146
47211
|
astParsingFunctions.wait = function(content) {
|
|
47147
47212
|
if (enableOptimization && optimizeForSize2) {
|
|
@@ -47355,6 +47420,9 @@ function parseAstRules(rules) {
|
|
|
47355
47420
|
if (rule.ruleAttributes.name === void 0) {
|
|
47356
47421
|
rule.ruleAttributes.name = "Subroutine " + rule.ruleAttributes.subroutineName;
|
|
47357
47422
|
}
|
|
47423
|
+
if (defaultSubroutineNames.includes(rule.ruleAttributes.subroutineName)) {
|
|
47424
|
+
addSubroutine(rule.ruleAttributes.subroutineName, defaultSubroutineNames.indexOf(rule.ruleAttributes.subroutineName), rule.fileStack);
|
|
47425
|
+
}
|
|
47358
47426
|
rule.name = "__rule__";
|
|
47359
47427
|
rule.originalName = "__def__";
|
|
47360
47428
|
} else if (rule.name in astMacros) {
|
|
@@ -63979,6 +64047,7 @@ function astRulesToWs(rules) {
|
|
|
63979
64047
|
result += ") {\n";
|
|
63980
64048
|
result += tabLevel(1) + tows("__event__", ruleKw) + " {\n";
|
|
63981
64049
|
result += tabLevel(2) + tows(rule.ruleAttributes.event, eventKw) + ";\n";
|
|
64050
|
+
setCurrentRuleEvent(rule.ruleAttributes.event);
|
|
63982
64051
|
if (rule.ruleAttributes.eventTeam) {
|
|
63983
64052
|
result += tabLevel(2) + tows(rule.ruleAttributes.eventTeam, eventTeamKw) + ";\n";
|
|
63984
64053
|
}
|
|
@@ -64285,6 +64354,22 @@ function astToWs(content) {
|
|
|
64285
64354
|
}
|
|
64286
64355
|
}
|
|
64287
64356
|
}
|
|
64357
|
+
if (content.name === "async" || content.name === "__callSubroutine__") {
|
|
64358
|
+
let subroutineName = content.args[0].name;
|
|
64359
|
+
let subroutine = subroutines.find((s) => s.name === subroutineName);
|
|
64360
|
+
if (subroutine) {
|
|
64361
|
+
let categories = getRuleEventCategories(currentRuleEvent);
|
|
64362
|
+
if (subroutine.hasEventPlayerVars && !categories.includes("player")) {
|
|
64363
|
+
warn("w_mismatched_subroutine_event", "Calling subroutine " + subroutineName + ", which uses event player variables, from a " + currentRuleEvent + " rule", content.fileStack);
|
|
64364
|
+
} else if (subroutine.hasEventDamageOrHealingVars && !categories.includes("damageOrHealing")) {
|
|
64365
|
+
warn("w_mismatched_subroutine_event", "Calling subroutine " + subroutineName + ", which uses event damage or healing variables, from a " + currentRuleEvent + " rule", content.fileStack);
|
|
64366
|
+
} else if (subroutine.hasEventDamageVars && !categories.includes("damage")) {
|
|
64367
|
+
warn("w_mismatched_subroutine_event", "Calling subroutine " + subroutineName + ", which uses event damage variables, from a " + currentRuleEvent + " rule", content.fileStack);
|
|
64368
|
+
} else if (subroutine.hasEventHealingVars && !categories.includes("healing")) {
|
|
64369
|
+
warn("w_mismatched_subroutine_event", "Calling subroutine " + subroutineName + ", which uses event healing variables, from a " + currentRuleEvent + " rule", content.fileStack);
|
|
64370
|
+
}
|
|
64371
|
+
}
|
|
64372
|
+
}
|
|
64288
64373
|
if (content.name in equalityFuncToOpMapping) {
|
|
64289
64374
|
content.args.splice(1, 0, new Ast2(equalityFuncToOpMapping[content.name], [], [], "__Operator__"));
|
|
64290
64375
|
content.name = "__compare__";
|
|
@@ -65203,6 +65288,24 @@ function compileRules(astRules) {
|
|
|
65203
65288
|
if (DEBUG_MODE) {
|
|
65204
65289
|
console.log(parsedAstRules);
|
|
65205
65290
|
}
|
|
65291
|
+
let hasModification = false;
|
|
65292
|
+
do {
|
|
65293
|
+
hasModification = false;
|
|
65294
|
+
for (let subroutine of subroutines) {
|
|
65295
|
+
for (let calledSubroutineName of subroutine.callsSubroutines) {
|
|
65296
|
+
let calledSubroutine = subroutines.find((s) => s.name === calledSubroutineName);
|
|
65297
|
+
if (!calledSubroutine) {
|
|
65298
|
+
error("Subroutine '" + subroutine.name + "' calls unknown subroutine '" + calledSubroutineName + "'");
|
|
65299
|
+
}
|
|
65300
|
+
for (let key of ["hasEventPlayerVars", "hasEventDamageVars", "hasEventHealingVars", "hasEventDamageOrHealingVars"]) {
|
|
65301
|
+
if (calledSubroutine[key] && !subroutine[key]) {
|
|
65302
|
+
subroutine[key] = true;
|
|
65303
|
+
hasModification = true;
|
|
65304
|
+
}
|
|
65305
|
+
}
|
|
65306
|
+
}
|
|
65307
|
+
}
|
|
65308
|
+
} while (hasModification);
|
|
65206
65309
|
setOptimizationEnabled2(true);
|
|
65207
65310
|
setOptimizeStrict2(false);
|
|
65208
65311
|
setOptimizationForSize2(false);
|
|
@@ -67675,6 +67778,24 @@ function getUniqueNumber() {
|
|
|
67675
67778
|
incrementUniqueNumber();
|
|
67676
67779
|
return uniqueNumber;
|
|
67677
67780
|
}
|
|
67781
|
+
function getRuleEventCategories(ruleEvent) {
|
|
67782
|
+
return {
|
|
67783
|
+
global: [],
|
|
67784
|
+
eachPlayer: ["player"],
|
|
67785
|
+
playerDealtDamage: ["player", "damage"],
|
|
67786
|
+
playerDealtFinalBlow: ["player", "damage"],
|
|
67787
|
+
playerDealtHealing: ["player", "healing"],
|
|
67788
|
+
playerDealtKnockback: ["player", "damageOrHealing", "damage", "healing"],
|
|
67789
|
+
playerDied: ["player", "damage"],
|
|
67790
|
+
playerEarnedElimination: ["player", "damage"],
|
|
67791
|
+
playerJoined: ["player"],
|
|
67792
|
+
playerLeft: ["player"],
|
|
67793
|
+
playerTookDamage: ["player", "damage"],
|
|
67794
|
+
playerReceivedHealing: ["player", "healing"],
|
|
67795
|
+
playerReceivedKnockback: ["player", "damageOrHealing", "damage", "healing"],
|
|
67796
|
+
__subroutine__: ["player", "damageOrHealing", "damage", "healing"]
|
|
67797
|
+
}[ruleEvent] || [];
|
|
67798
|
+
}
|
|
67678
67799
|
|
|
67679
67800
|
// src/types.d.ts
|
|
67680
67801
|
var ow_languages = /* @__PURE__ */ ((ow_languages2) => {
|
package/package.json
CHANGED