ManiaScript Compile WARNING

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
niarfman
Posts: 306
Joined: 07 Dec 2012, 10:46

ManiaScript Compile WARNING

Post by niarfman »

Hi All,

I am trying to understand and debug a ManiaScript Code written by Mewin for having a CTF server working properly.

I was able to update some Manialinks from version 1 to 4 and to launch a remote server (Linux) and connect on it.

Now I am trying to use the "Compile" button in the inGame Editor. it stop directly on the 1st warning indicating "Overriding SpawnPlayer" from the read-only Nadeo File "SM.Script.txt". I know this is not an error.

My question is : How to ignore Warning with Compile button and / or how to check the next Warning or Error ... ?

Many thanks for your answer, I am discovering this language and the tools ^^
Image
Ľѷҳ Choupa Oups! ツ
User avatar
Dommy
Translator
Translator
Posts: 1901
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: ManiaScript Compile WARNING

Post by Dommy »

To ignore compilation warnings, just press the Save button, the game mode will be compiled and should start, unless there are fatal errors. You can also use a normal workspace outside your game and reload the files by pressing Shift + Scroll Lock, just for the sake of your own comfort of work. :)

Nadeo should take care of this compilation warning though, simply because SM library is compiled before any custom library, making it nearly impossible to see potential optimizations available for your code.

By the way, the newest manialink feature version is 3, not 4.
Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT

Contact me via GALAXY & PURSUIT DISCORD
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: ManiaScript Compile WARNING

Post by Eole »

SM.Script.txt is an old library that is still available for backward compatibility reason. The latest version of the library (Libs/Nadeo/ShootMania/SM3.Script.txt) fixes this problem. The SpawnPlayer() function was renamed Spawn() to avoid the warning.
It doesn't look like the CTF script extends from the Nadeo ModeBase, so you should be able to get rid of the warning by replacing SM.Script.txt by SM3.Script.txt and adjusting the code a bit to call the new function.
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
niarfman
Posts: 306
Joined: 07 Dec 2012, 10:46

Re: ManiaScript Compile WARNING

Post by niarfman »

Many Thanks Dommy and Eole,

I tried to replace SM Script by SM3 Script.

I am facing an issue with the following line :

Code: Select all

SM::SpawnPlayer(Player, Player.RequestedClan, BlockSpawns[SpawnId],Now);
I tried to replace it with :

Code: Select all

SM3::Spawn(Player, Player.RequestedClan, BlockSpawns[SpawnId],Now);
But I get an error : "Incorrect Arguements to call the function Spawn"

But in SM3.Script.txt The function with same arguments exists ... :

Code: Select all

// ---------------------------------- //
/** Spawn a player
 *
 *	@param	_Player				The player to spawn
 *	@param	_ClanNum			The clan in which the player will be spawned
 *	@param	_Landmark			The landmark where the player will be spawned
 *	@param	_ActivationDate		When the player will be spawned
 */
Void Spawn(CSmPlayer _Player, Integer _ClanNum, CSmMapPlayerSpawn _Spawn, Integer _ActivationDate) {
	This.SpawnPlayer(_Player, _ClanNum, -1, _Spawn, _ActivationDate);
	if(_Player.Score != Null) Ladder::AddPlayer(_Player.Score);
}
+ CTF script is using GetPole function which no longer exists in SM3.

Sorry : I am a very newbie with ManiaScript. Usually I can debug with other langages by displaying variables values for understanding by myself, but ther is no "echo" or "print_r" possibilities in ManiaScript as far as I know (or maybe I didn't find...)

I hope I will be able to understand and help to update this Script. Mewin said he cannot help me as he didn't use ManiaScript for years :?
Image
Ľѷҳ Choupa Oups! ツ
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: ManiaScript Compile WARNING

Post by Eole »

niarfman wrote: 24 May 2018, 21:58 ther is no "echo" or "print_r" possibilities in ManiaScript as far as I know (or maybe I didn't find...)
You can use the log() function to do that.

Code: Select all

declare Variable = 15;
log(Variable);
declare Variable2 = 4.5;
log("Value of Variable2 : "^Variable2);
Then you can press ctrl+g while playing to display the log window and see the values.
niarfman wrote: 24 May 2018, 21:58 But I get an error : "Incorrect Arguements to call the function Spawn"
[...]
+ CTF script is using GetPole function which no longer exists in SM3.
Indeed, the old SpawnPlayer() function requires a CSmBlockSpawn while the new Spawn() function needs a CSmMapLandmark. The old block api is deprecated and is replaced by the landmark api. In the script of the mode you have access to the MapLandmarks array that contains every landmark (spawn, pole, gate, ...) of the map.
You can get the landmarks you need to spawn the players from this array. If your needs are simple, you can try to include the library "Libs/Nadeo/ShootMania/Map.Script.txt". It contains a GetLandmarkPlayerSpawn() function that can help you get the spawn CSmMapLandmark. Same thing to replace GetPole(), you can use GetLandmarkGauge().
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
niarfman
Posts: 306
Joined: 07 Dec 2012, 10:46

Re: ManiaScript Compile WARNING

Post by niarfman »

Great !

Many thanks for yout time for answering.

It's now working using :

Code: Select all

SM3::Spawn(Player, Player.RequestedClan, MapLandmarks_PlayerSpawn[SpawnId].PlayerSpawn, Now);
I will need to review the script by using more Lanmarks now :thumbsup:
Image
Ľѷҳ Choupa Oups! ツ
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 2 guests