// Downloaded at : http://www.akbalder.com/ManiaPlanet/GameModes/ShootMania/GoalHuntArena.Script.txt
/* -------------------------------------- */
// Name: GoalHuntArena
// Version: 201305212109
// Author: Florian "Akbalder" Guillard
// Contact: akbalder@gmail.com
/* -------------------------------------- */
#RequireContext CSmMapType
#Include "TextLib" as TextLib
#Include "Libs/Nadeo/Anchor.Script.txt" as Anchor
declare Text Rules;
/* -------------------------------------- */
// Initialize the anchors
Void InitAnchors() {
foreach (Data in AnchorData) {
if(Data.DefaultTag=="Checkpoint"){ //replace "Checkpoint" by "Goal"
Data.Tag = "Goal";
}else{
Data.Tag = Data.DefaultTag;
}
Data.Order = Data.DefaultOrder;
}
}
/* -------------------------------------- */
// Check if the map is valid
Void UpdateValidability() {
InitAnchors();
Anchor::UpdateAnchorCounts();
if (!Anchor::HasExactlyOneAnchor("Spawn", 0, _("You must place exactly one Spawn."))) return;
if (!Anchor::HasAtLeastXAnchor("Goal", 0, 3, _("You must place at least 3 Goals."))) return;
}
/* -------------------------------------- */
// Manialink for non editable anchor
Text NoEditManialink() {
return """
""";
}
/* -------------------------------------- */
// Show the anchor edition manialink
Void EditAnchorData(Ident _EditedAnchorDataId)
{
declare Integer AnchorOrder for ManialinkPage;
declare Boolean Finish for ManialinkPage;
ManialinkText = NoEditManialink();
Finish = False;
while(!Finish) {
yield;
}
UpdateValidability();
}
/* -------------------------------------- */
// Main
/* -------------------------------------- */
main() {
UpdateValidability();
CustomEditAnchorData = True;
Rules = _("You must place exactly one Spawn and at least three Goals.");
while (True) {
yield;
ManialinkText = "";
foreach(Event in PendingEvents) {
if(Event.Type == CPluginEvent::Type::MapModified) {
UpdateValidability();
} else if (Event.Type == CPluginEvent::Type::EditAnchor) {
EditAnchorData(Event.EditedAnchorDataId);
}
}
}
}