Page 1 of 1

How to Make a Custom User Interface in a game Mode

Posted: 27 Jan 2018, 22:28
by Sheiken
Hello, good afternoon, I would like to know if someone from that forum knows how to make user interfaces for a custom game mode. I'll explain why I've decided to ask for help.

I'm not a programmer (wow that older excuse) but it's a disadvantage when you have no idea how things work.

I know that now the UI of the game modes use something called Hud. Module. GBX and from there they call modules with preset styles but not editable.

Delete the path of the game mode and also its modules, so I stay the HUD old (MP3 HUD).

Now that I do not have the HUD of MP4 I want to add quads and labels to the UI, but I can not find any file that allows me to do, except the library Layers2. Script. txt

I discovered how to use a function called Create ();

So I wrote in TimeAttack. Script. txt on the plug Match_LoadHud the following:

Layers:: Create (NewQuad, "< Label pos = " 0 0 "z-index = " 0 "text = " This is an example "/> ");

But when compile tells me syntax error, unexpected MANIASCRIPT_NATURAL, expecting MANISCRIPT_SEMICOLON

Until there comes no matter what someone can ahcer me see what I do wrong or I need to do?

Re: How to Make a Custom User Interface in a game Mode

Posted: 28 Jan 2018, 10:00
by adamkooo2
This is list of errors, it might help you:
http://konte.org/trackmania/maniascript/syntax.txt

Re: How to Make a Custom User Interface in a game Mode

Posted: 28 Jan 2018, 12:48
by Dommy
Don't bother with modules - they aren't as useful as preferable solution. For beginners, I would recommmend using Layers2 library. It should be included in all game modes by default.
Sheiken wrote: 27 Jan 2018, 22:28 I discovered how to use a function called Create ();

So I wrote in TimeAttack. Script. txt on the plug Match_LoadHud the following:

Layers:: Create (NewQuad, "< Label pos = " 0 0 "z-index = " 0 "text = " This is an example "/> ");

But when compile tells me syntax error, unexpected MANIASCRIPT_NATURAL, expecting MANISCRIPT_SEMICOLON
That's because Text contains unescaped (forbidden) characters, like ". Instead seeing Text, compiler (program that turns your code into working thing) sees a lot of different data types, since the line is formatted incorrectly.

You either want to write \" instead " in side your single-line Text string, like:

Code: Select all

"<label pos=\"0 0\" z-index=\"0\" text=\"This is an example\" />"
...or use a different XML character for your label attributes (attributes are things, like pos="0 0"):

Code: Select all

"<label pos='0 0' z-index='0' text='This is an example' />"
...or (preferably) you probably want to use multiline Text, which doesn't require escaping characters and can, as stated, be multiline, unlike previous declarations:

Code: Select all

"""
<label pos="0 0" z-index="0" text="This is an example" />
"""
Another thing you need to do is use functions Create() and Attach() properly. Create() will create an interface layer (one manialink), while Attach() will show it to the players. The way I wrote it below will show your UI to all players, if you put this at the beginning of your game mode, inside ***Match_StartServer*** block.

Code: Select all

Layers::Create("MyOwnUI", """
<manialink version="3">
<label pos="0 0" z-index="0" text="This is an example" />
</manialink>
""");
Layers::Attach("MyOwnUI");
Note, I also added <manialink> tag, which will indicate your manialink is using most recent features of the manialinks. 3x "MANIALINK" COMBO

Hope that helps!

Re: How to Make a Custom User Interface in a game Mode

Posted: 28 Jan 2018, 17:48
by Sheiken
adamkooo2 wrote: 28 Jan 2018, 10:00 This is list of errors, it might help you:
http://konte.org/trackmania/maniascript/syntax.txt
Thanks adamkoo2, no have idea about that list, very useful. :yes:

Dommy wrote: 28 Jan 2018, 12:48 Don't bother with modules - they aren't as useful as preferable solution. For beginners, I would recommmend using Layers2 library. It should be included in all game modes by default.
Sheiken wrote: 27 Jan 2018, 22:28 I discovered how to use a function called Create ();

So I wrote in TimeAttack. Script. txt on the plug Match_LoadHud the following:

Layers:: Create (NewQuad, "< Label pos = " 0 0 "z-index = " 0 "text = " This is an example "/> ");

But when compile tells me syntax error, unexpected MANIASCRIPT_NATURAL, expecting MANISCRIPT_SEMICOLON
That's because Text contains unescaped (forbidden) characters, like ". Instead seeing Text, compiler (program that turns your code into working thing) sees a lot of different data types, since the line is formatted incorrectly.

You either want to write \" instead " in side your single-line Text string, like:

Code: Select all

"<label pos=\"0 0\" z-index=\"0\" text=\"This is an example\" />"
...or use a different XML character for your label attributes (attributes are things, like pos="0 0"):

Code: Select all

"<label pos='0 0' z-index='0' text='This is an example' />"
...or (preferably) you probably want to use multiline Text, which doesn't require escaping characters and can, as stated, be multiline, unlike previous declarations:

Code: Select all

"""
<label pos="0 0" z-index="0" text="This is an example" />
"""
Another thing you need to do is use functions Create() and Attach() properly. Create() will create an interface layer (one manialink), while Attach() will show it to the players. The way I wrote it below will show your UI to all players, if you put this at the beginning of your game mode, inside ***Match_StartServer*** block.

Code: Select all

Layers::Create("MyOwnUI", """
<manialink version="3">
<label pos="0 0" z-index="0" text="This is an example" />
</manialink>
""");
Layers::Attach("MyOwnUI");
Note, I also added <manialink> tag, which will indicate your manialink is using most recent features of the manialinks. 3x "MANIALINK" COMBO

Hope that helps!
Thanks Again Dommy, :1010, yeah the modules are like other planet for me. It works