Page 1 of 1

Cmap Maniascript Problem

Posted: 18 Apr 2017, 17:32
by Sheiken
Hi, I trying to get the Autor Time in my UI when I play a Local Network on Stadium, but i dont know the sintaxis in the script, so i try to modified the module Lib_UI:PrevBestTime in UI.Script.txt(i made the copy to moding) to start. Looking for groping in the documentation I found this class called Cmap http://maniascript.team-devota.com/struct_c_map.html and the atribute call TMObjective.

So i think put in the Module Lib_UI:PrevBestTime in UI.Script.txt a script that shows me the time author in a label when I start map (the label has a id="Label_AuthorTime").

The problema is:
What I've been able to learn looking at the script of the game itself sometimes have to declare certain things and when I see the documentation I have no clear when declare certain things depending on circumstances.

Then what I ask is that someone explain to me how to use the CMap class within the UI file.Script.txt or better still, to correctly read the documentation.

A image https://www.dropbox.com/s/cvvmenjsi8oobdl/Help.png?dl=0

Thx for read this! :oops: :?

Re: Cmap Maniascript Problem

Posted: 19 Apr 2017, 11:42
by Dommy
All scripts run in their own context. A context is basically an instance of class (object), which attributes are globally available in the script.

The context you are looking for is CTmMlScriptIngame - it's set of attributes available for TrackMania ingame manialinks. You can use things like Players array to loop through all player objects on the server. Please also note, this class extends CMlScriptIngame, which contains attributes common between ShootMania and TrackMania (like Map in your case). CMlScriptIngame is also extending another class, CMlScript, which is essentially set of all attributes and methods (functions) available for manialinks used anywhere (both ingame and in the browser). It also extends CNod, but it's just adding ID to the class, so don't mind that.

For the author time, you will have to use

Code: Select all

Label.Value = TextLib::TimeToText(Map.TMObjective_AuthorTime, True);
which will convert author time milliseconds to a Text and apply it to the label. You could also try using Map.ObjectiveTextAuthor to have the author time directly as Text, but I'm unsure if it's working correctly.

Hope i helped. :thumbsup:

Re: Cmap Maniascript Problem

Posted: 19 Apr 2017, 14:57
by Sheiken
domino54 wrote: 19 Apr 2017, 11:42 All scripts run in their own context. A context is basically an instance of class (object), which attributes are globally available in the script.

The context you are looking for is CTmMlScriptIngame - it's set of attributes available for TrackMania ingame manialinks. You can use things like Players array to loop through all player objects on the server. Please also note, this class extends CMlScriptIngame, which contains attributes common between ShootMania and TrackMania (like Map in your case). CMlScriptIngame is also extending another class, CMlScript, which is essentially set of all attributes and methods (functions) available for manialinks used anywhere (both ingame and in the browser). It also extends CNod, but it's just adding ID to the class, so don't mind that.

For the author time, you will have to use

Code: Select all

Label.Value = TextLib::TimeToText(Map.TMObjective_AuthorTime, True);
which will convert author time milliseconds to a Text and apply it to the label. You could also try using Map.ObjectiveTextAuthor to have the author time directly as Text, but I'm unsure if it's working correctly.

Hope i helped. :thumbsup:
Thanks Dommy, Let me see if I understand:

-It is not necessary to use#Include and #RequireContext because CMlScript, CMlScriptIngame and CTmMlScriptIngame are always available.

-The Code :

Code: Select all

Label.Value = TextLib::TimeToText(Map.TMObjective_AuthorTime, True);
When Label=Id of the label declared in the manialink.

And , it Works, Thanks for the prompt response. :1010