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.`);
}
else {
if ((game === "bhop" || game === "surf") && !root.Name.startsWith(game + "_")) {
errors.push(`Your root model's name is \`${root.Name}\`, its name must start with \`${game}_\`.`);
const prefix = (game === "deathrun") ? "dr" : 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)) {
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?
const illegalScript = root.FindFirstChildOfClass("Script", (script) => sourceHasIllegalKeywords(script.Source));
const illegalModuleScript = root.FindFirstChildOfClass("ModuleScript", (script) => sourceHasIllegalKeywords(script.Source));
const illegalScript = root.FindFirstDescendantOfClass("Script", (script) => sourceHasIllegalKeywords(script.Source));
const illegalModuleScript = root.FindFirstDescendantOfClass("ModuleScript", (script) => sourceHasIllegalKeywords(script.Source));
if (illegalScript || illegalModuleScript) {
errors.push("Your map has a `Script` that contains the keyword `getfenv` or `require`. You must remove these.");
}