Page 1 of 1

[Help] Make it Validable

Posted: 01 Aug 2012, 17:21
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)

Re: [Help] Make it Validable

Posted: 01 Aug 2012, 19:31
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).

Re: [Help] Make it Validable

Posted: 01 Aug 2012, 19:32
by Akbalder
You forgot a ';' after "declare CheckpointFound = False".

Re: [Help] Make it Validable

Posted: 01 Aug 2012, 20:13
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.

Re: [Help] Make it Validable

Posted: 01 Aug 2012, 20:48
by TMarc
Add additional curly braces at the lowest if?

Re: [Help] Make it Validable

Posted: 01 Aug 2012, 23:18
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.