[Help] Make it Validable

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
LBF
Posts: 101
Joined: 22 Sep 2011, 20:32
Location: Brasil!!!

[Help] Make it Validable

Post by LBF »

I am working in a map type script (writing in the platform script :mrgreen: ) , and appears I am having a syntax error:
Image
This is what I modified in the original script:

Code: Select all

//////////////////
//   Time attack maps: You need to go to the finish with the highest time score 
//////////////////

#RequireContext CTmMapType

#Include "TextLib" as TextLib
#Include "Libs/Nadeo/MapType.Script.txt"
#Include "Libs/TrackMania/TMPlatform.Script.txt" as TimeAttachLib

#Const SupportedTasks "Validation"

/////////////////////////////////////
// Validate

Void SetObjectives(Integer _Author, Integer _Gold, Integer _Silver, Integer _Bronze, Integer _NbCheckpoints)
{
	declare metadata Integer ObjectiveAuthor 	for Map;
	declare metadata Integer ObjectiveGold 		for Map;
	declare metadata Integer ObjectiveSilver 	for Map;
	declare metadata Integer ObjectiveBronze 	for Map;
	declare metadata Integer RaceCheckpoints 	for Map;
	
	ObjectiveAuthor 	= _Author;
	ObjectiveGold 		= _Gold;
	ObjectiveSilver 	= _Silver;
	ObjectiveBronze 	= _Bronze;
	RaceCheckpoints		= _NbCheckpoints;

	Map.ObjectiveTextAuthor = """{{{ObjectiveAuthor}}} 100%""";
	Map.ObjectiveTextGold 	= """{{{ObjectiveGold}}}   90%""";
	Map.ObjectiveTextSilver = """{{{ObjectiveSilver}}} 65%""";
	Map.ObjectiveTextBronze = """{{{ObjectiveBronze}}} 38%""";
}

Void SetDefaultObjectives(Integer _AuthorRespawns, Integer _NbCheckpoints)
{
	/*
	ObjectiveAuthor 	= _AuthorTime;
	ObjectiveGold 		= _AuthorTime - 10%;
	ObjectiveSilver 	= _AuthorTime - 35%;
	ObjectiveBronze 	= _AuthorTime - 62%;
	*/

	SetObjectives(0, 0, 0, 0, _NbAuthorTime);
}
	
declare CBlock 		BlockStart;
declare CBlock[] 	BlockFinishs;
declare Integer[CBlock]	BlockCheckpoints;	// ordered

Void UpdateValidability()
{
	BlockStart <=> Null;
	BlockFinishs = CBlock[];
	BlockCheckpoints = Integer[CBlock];

	// analyse the blocks of the map
	declare StartFound = 0;
	declare IsMultiLap = False;
	foreach(Block in Blocks) {
	    declare Type = Block.BlockModel.WayPointType;
		if (Type == CBlockModel::EWayPointType::Start)			{ BlockStart <=> Block; StartFound += 1; }
		if (Type == CBlockModel::EWayPointType::StartFinish)	{ BlockStart <=> Block; BlockFinishs.add(Block); StartFound += 1; IsMultiLap = True; }
		if (Type == CBlockModel::EWayPointType::Finish)	 		{ BlockFinishs.add(Block); }
		if (Type == CBlockModel::EWayPointType::Checkpoint)		{ BlockCheckpoints[Block] = 0; }
		
	}

	// Is there a start and finish
	if(StartFound != 1) {
		ValidationStatus = CMapType::ValidationStatus::NotValidable;
		ValidabilityRequirementsMessage = _("This map requires exactly one start.");
		return;
	}
	
	if (BlockCheckpoints.count == 0) {
		ValidationStatus = CMapType::ValidationStatus::NotValidable;
		ValidabilityRequirementsMessage = _("This map requires at least one checkpoint.");
		return;
	}
	
	if (BlockFinishs.count == 0) {
		ValidationStatus = CMapType::ValidationStatus::NotValidable;
		ValidabilityRequirementsMessage = _("This map requires at least one finish.");
		return;
	}
	
	// all the conditions are met to start the validation (or it is already validated)
	if (ValidationStatus == CMapType::ValidationStatus::NotValidable)
		ValidationStatus = CMapType::ValidationStatus::Validable;	
}
And probably that's why the maps with this script can't be validable...
(this is the same code in both scripts)
Where is the error in my code?
(Please, be patient with me, I do not have experience with programing)
Last edited by LBF on 01 Aug 2012, 23:19, edited 2 times in total.
User avatar
Keras
Posts: 171
Joined: 10 Aug 2011, 09:40

Re: [Help] Make it Validable

Post by Keras »

Those 2 are not the same code. In the first one there is 1 additional line before the foreach loop and that is missing a semikolon at the end (declare CheckpointFound = False).
Akbalder
Posts: 1059
Joined: 15 Jun 2010, 11:00
Contact:

Re: [Help] Make it Validable

Post by Akbalder »

You forgot a ';' after "declare CheckpointFound = False".
User avatar
LBF
Posts: 101
Joined: 22 Sep 2011, 20:32
Location: Brasil!!!

Re: [Help] Make it Validable

Post by LBF »

Keras wrote:Those 2 are not the same code. In the first one there is 1 additional line before the foreach loop and that is missing a semikolon at the end (declare CheckpointFound = False).
:shock:
I was thinking it was removed from the code, because Nadeo made an other way to Identify If the map has chackpoints and I decided to remove my code.
I think it is a Ctrl z & Ctrl y issue...

But the map can't be validable yet. And It is not saying what is here too:

Code: Select all

// Is there a start and finish
   if(StartFound != 1) {
      ValidationStatus = CMapType::ValidationStatus::NotValidable;
      ValidabilityRequirementsMessage = _("This map requires exactly one start.");
      return;
   }
   
   if (BlockCheckpoints.count == 0) {
      ValidationStatus = CMapType::ValidationStatus::NotValidable;
      ValidabilityRequirementsMessage = _("This map requires at least one checkpoint.");
      return;
   }
   
   if (BlockFinishs.count == 0) {
      ValidationStatus = CMapType::ValidationStatus::NotValidable;
      ValidabilityRequirementsMessage = _("This map requires at least one finish.");
      return;
   }
   
   // all the conditions are met to start the validation (or it is already validated)
   if (ValidationStatus == CMapType::ValidationStatus::NotValidable)
      ValidationStatus = CMapType::ValidationStatus::Validable;   
}
Anyway I didn't finish the script.
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: [Help] Make it Validable

Post by TMarc »

Add additional curly braces at the lowest if?
User avatar
LBF
Posts: 101
Joined: 22 Sep 2011, 20:32
Location: Brasil!!!

Re: [Help] Make it Validable

Post by LBF »

I think it is happening because this file:

Code: Select all

#Include "Libs/TrackMania/TMPlatform.Script.txt" as PlatformLib
This platform script is loaded as a dll I think, And I rewrote my original script now, and it is not working yet because they are not compatible.
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 3 guests