Parse map models and validate them #13

Merged
Quaternions merged 2 commits from parse-map-models into master 2024-04-24 06:28:08 +00:00
Showing only changes of commit 85c12d034a - Show all commits

View File

@ -166,8 +166,9 @@ async function validateMapAsset(assetId, game) {
errors.push(`The root part of your model is a \`${root.ClassName}\`, it needs to be a \`Model\` instead.`); errors.push(`The root part of your model is a \`${root.ClassName}\`, it needs to be a \`Model\` instead.`);
} }
else { else {
if ((game === "bhop" || game === "surf") && !root.Name.startsWith(game + "_")) { const prefix = (game === "deathrun") ? "dr" : game;
Quaternions marked this conversation as resolved Outdated

This is not modular!

This is not modular!
errors.push(`Your root model's name is \`${root.Name}\`, its name must start with \`${game}_\`.`); if (!root.Name.startsWith(prefix + "_")) {
errors.push(`Your root model's name is \`${root.Name}\`, its name must start with \`${prefix}_\`.`);
} }
if (!/^[a-z0-9_]*$/.test(root.Name)) { if (!/^[a-z0-9_]*$/.test(root.Name)) {
errors.push(`Your root model's name is \`${root.Name}\` which contains invalid characters. It must only contain lowercase alphanumeric characters separated by underscores.`); errors.push(`Your root model's name is \`${root.Name}\` which contains invalid characters. It must only contain lowercase alphanumeric characters separated by underscores.`);
@ -207,8 +208,8 @@ async function validateMapAsset(assetId, game) {
} }
// Why does ModuleScript not inherit from Script, and/or why does BaseScript not have a Source property? // Why does ModuleScript not inherit from Script, and/or why does BaseScript not have a Source property?
const illegalScript = root.FindFirstChildOfClass("Script", (script) => sourceHasIllegalKeywords(script.Source)); const illegalScript = root.FindFirstDescendantOfClass("Script", (script) => sourceHasIllegalKeywords(script.Source));
const illegalModuleScript = root.FindFirstChildOfClass("ModuleScript", (script) => sourceHasIllegalKeywords(script.Source)); const illegalModuleScript = root.FindFirstDescendantOfClass("ModuleScript", (script) => sourceHasIllegalKeywords(script.Source));
if (illegalScript || illegalModuleScript) { if (illegalScript || illegalModuleScript) {
errors.push("Your map has a `Script` that contains the keyword `getfenv` or `require`. You must remove these."); errors.push("Your map has a `Script` that contains the keyword `getfenv` or `require`. You must remove these.");
} }