[ML] <include> not working for maptype scripts

Moderators: w1lla, NADEO

Post Reply
kastun
Posts: 18
Joined: 28 Oct 2012, 10:05

[ML] <include> not working for maptype scripts

Post by kastun »

I discovered that the include tag does not work in manialinks used for a maptype script (tested only for shootmania), probably also for trackmania.

\Documents\ManiaPlanet\Scripts\MapTypes\ShootMania\Test.Script.txt

Code: Select all

#RequireContext CSmMapType

main() {
	ManialinkText = """
		<manialink version="1">
			<timeout>0</timeout>
			<include url="file://Media/Manialinks/include/include.xml" />
			<label posn="0 0 3" sizen="100 10" halign="center" valign="center" text="this is file://Media/Manialinks/include/index.xml" />
		</manialink>
	""";
}
\Documents\ManiaPlanet\Media\Manialinks\include\index.xml

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
	<timeout>0</timeout>
	<include url="file://Media/Manialinks/include/include.xml" />
	<label posn="0 0 3" sizen="100 10" halign="center" valign="center" text="this is file://Media/Manialinks/include/index.xml" />
</manialink>
\Documents\ManiaPlanet\Media\Manialinks\include\include.xml

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<label posn="0 -10 3" sizen="100 10" halign="center" valign="center" text="this is file://Media/Manialinks/include/include.xml" />
When I access the index file (file://Media/Manialinks/include/index.xml) with the manialink browser both lines will be shown.
If editing a map selecting the Test maptype only the first line shows up, the Content of the included file is not shown.
User avatar
noyranea
Nadeo
Nadeo
Posts: 187
Joined: 29 Apr 2014, 14:50
Location: Paris, France

Re: [ML] <include> not working for maptype scripts

Post by noyranea »

Hello katsun,

this behavior is normal : the <include> manialink tag is resolved too early to work with plugin layers (layers are the manialink components of your plugin).
That's why your include works in a manialink, but not in a layer / plugin / maniaapp.

But there is a very simple way to do what you want : you can define a new layer, and set and URL for it.

Have a look at the following code :

Code: Select all

#RequireContext CSmMapType

main() {
   ManialinkText = """
      <manialink version="1">
         <timeout>0</timeout>
         <!-- // This won't work 
               <include url="file://Media/Manialinks/include/include.xml" /> 
          -->
         <label posn="0 0 3" sizen="100 10" halign="center" valign="center" text="this is some manialink I want to display !" />
      </manialink>
   """;

   declare MyIncludeLayer = UILayerCreate(); //initialise my new layer
   //set the layer's content. I can put either a Url or Manialink Code
   MyIncludeLayer.ManialinkPage = "file://Media/Manialinks/include/include.xml"; 
   

   while(True) //my update loop. I can do things here such as setting MyIncludeLayer.IsVisible
      yield;
}
Do not hesitate to ask any questions & have a nice day,

-- noyranea
kastun
Posts: 18
Joined: 28 Oct 2012, 10:05

Re: [ML] <include> not working for maptype scripts

Post by kastun »

Thanks, this is working.

Just as reminder: The layer file has to contain the manialink tag (it is not working with the posted include.xml)
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [ML] <include> not working for maptype scripts

Post by adamkooo2 »

I had problem with original TM Platform script ,when I test the solo I saw thisImage
here is script SoloPlatform:

Code: Select all

// *********************** ** ** *   *
// *    TM Platform (solo)
// ******************* ** ** *   *

#RequireContext CTmMode

#Const CompatibleMapTypes "Platform"
#Const Version 			  "2012-07-18"

#Include "TextLib" as TextLib
#Include "Libs/Nadeo/Mode.Script.txt"
#Include "Libs/Nadeo/TrackMania/TM.Script.txt" as TM
#Include "Libs/TrackMania/TMPlatform.Script.txt" as PlatformLib

// === Main ===

}
	UIManager.ResetAll();

	PlatformLib::SetupUi(This);
	
	CutOffTimeLimit = 0; 
	TM::Players_UnspawnAll();

	while( !ServerShutdownRequested ) {
		LoadMap();

		// intro & setup
		UIManager.UIAll.UISequence = CUIConfig::EUISequence::Intro;
		Scores_Clear();
		
		sleep(200);
		TM::Players_SpawnAll(Now + 100000);		// put the car on the startline for nicer intro.

		wait(UIManager.UIAll.UISequenceIsCompleted);
		
		// start the race
		Synchro_DoBarrier();
		declare persistent BestScore_NbRespawns for Map = -1;
		foreach(Player in Players) {
			Player.Score.BestRace.NbRespawns = BestScore_NbRespawns;
		}

		UIManager.UIAll.UISequence = CUIConfig::EUISequence::Playing;
		CutOffTimeLimit = 0; 			// never ends.
		TM::Players_SpawnAll(0);		// start asap.

		declare ExitLoopBarrier = 0;
		while( !Synchro_BarrierReached(ExitLoopBarrier) ) {
			yield; // TM::RunGame();
			TM::EndRaceSequence_Update();
			
			if (MatchEndRequested) {
				if (ExitLoopBarrier == 0) {	// if not yet processed
					TM::Players_UnspawnAll();
					ExitLoopBarrier = Synchro_AddBarrier();
				}
			} else {
				// show medal gain
				foreach(Player, Players) {
					declare Boolean HasNewRecord for Player;
					if (!HasNewRecord) 
						continue;
					if (Player.RaceStartTime != 0)
						continue;	// wait until the race is finished and he has been unspawned.
					Solo_SetNewRecord(Player.Score, PlatformLib::GetMedalForScore(Player.Score.BestRace));
					HasNewRecord = False;
				}
				
				TM::Players_SpawnWaiting(0);
			}

			foreach(Event, PendingEvents) {	
				PassOn(Event);
	
				if (Event.Type == CTmModeEvent::EType::WayPoint && Event.IsEndRace) {
					declare Player <=> Event.Player;
					assert(Player.CurRace.Time == Event.RaceTime);
					assert(Player.CurRace.NbRespawns == Event.NbRespawns);
					Player.Score.PrevRace = Player.CurRace;
					if (PlatformLib::IsRaceBetter(Player.CurRace, Player.Score.BestRace)) {
						Player.Score.BestRace = Player.CurRace;
						BestScore_NbRespawns = Player.CurRace.NbRespawns;		// Save to profile!

						TM::EndRaceSequence_Add(Player, _("New record!"));
					} else {
						TM::EndRaceSequence_Add(Player, "");
					}

					declare Boolean HasNewRecord for Player;
					HasNewRecord = True;
				}
			}
		}
		
		MatchEndRequested = False;
		
		TM::Players_UnspawnAll();
		UIManager.UIAll.UISequence = CUIConfig::EUISequence::Outro;
		wait(UIManager.UIAll.UISequenceIsCompleted);
		
		UIManager.UIAll.UISequence = CUIConfig::EUISequence::None;
		Scores_Clear();
		UnloadMap();
	}
	
	PlatformLib::CleanupUi(This);
}
/\rkady
Image
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: [ML] <include> not working for maptype scripts

Post by Eole »

I can't reproduce your problem. I tried to launch a solo game from the Platform title pack and had no issue. What do you call the "original" platform script?
The script in the screenshot and the one you pasted in your post are not the same. They have a different version, first one is "2012-07-25" and the second one "2012-07-18". The problem seems to be inside the /Libs/TrackMania/TMPlatform.Script.txt file. Did you paste an old version of this script in your local script folder by chance?
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
adamkooo2
Posts: 1318
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: [ML] <include> not working for maptype scripts

Post by adamkooo2 »

Eole wrote:I can't reproduce your problem. I tried to launch a solo game from the Platform title pack and had no issue. What do you call the "original" platform script?
The script in the screenshot and the one you pasted in your post are not the same. They have a different version, first one is "2012-07-25" and the second one "2012-07-18". The problem seems to be inside the /Libs/TrackMania/TMPlatform.Script.txt file. Did you paste an old version of this script in your local script folder by chance?
I'm testing game scripts for TM 2 United Forever (my title)
/\rkady
Image
Post Reply

Return to “Maniaplanet Reports”

Who is online

Users browsing this forum: No registered users and 2 guests