Sending Ident into manialink?

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
BigBang1112
Posts: 389
Joined: 20 Jul 2015, 12:44
Location: Czech Republic
Contact:

Sending Ident into manialink?

Post by BigBang1112 »

I'm trying to send

Code: Select all

UserMgr.MainUser.Id
into manialink but

Code: Select all

declare Ident MyUserID for LocalUser;
MyUserID = UserMgr.MainUser.Id;
in CManiaAppTitle and then

Code: Select all

declare Ident MyUserID for LocalUser;
in manialink does not work for me.

What is a proper solution on this?
Creator and competent racer. YouTube Discord
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
User avatar
Dommy
Translator
Translator
Posts: 1901
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: Sending Ident into manialink?

Post by Dommy »

Title menu manialink layer runs in context of CManiaAppTitleLayer, extending CMlScript. You should be able to access user directly in the manialink this way:

Code: Select all

ParentApp.UserMgr.MainUser.Id
If that doesn't work, easiest way to share data in both ways between manialink and the app (menu, editor plugins) is to declare variables for the page. In your app:

Code: Select all

declare Text Variable for MyLayer.LocalPage;
...followed by the manialink part:

Code: Select all

declare Text Variable for Page;
Not sure if Ident can be passed this way, but I suppose it should. You can't however pass objects and Idents as traits (netwrite/netread, persistent, metadata).
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
BigBang1112
Posts: 389
Joined: 20 Jul 2015, 12:44
Location: Czech Republic
Contact:

Re: Sending Ident into manialink?

Post by BigBang1112 »

Thanks for this^^
Creator and competent racer. YouTube Discord
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
User avatar
adamkooo2
Posts: 1371
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: Sending Ident into manialink?

Post by adamkooo2 »

I've tried to send a UserRecord integer to a layer, code:

Code: Select all

Void ShowMedals(CTmMode _Rules)	{
	declare CUILayer UIMedals;
	UIMedals = _Rules.UIManager.UILayerCreate();
	UIMedals.ManialinkPage = "file://media/manialinks/uimedals.xml";
	
	declare Integer UserRecord for UIMedals.LocalPage;

	UserRecord = ScoreMgr.Map_GetRecord(NullId, Map.MapInfo.MapUid, "Race");
	log(UserRecord);
	
	_Rules.UIManager.UIAll.UILayers.add(UIMedals);
}
Manialink code:

Code: Select all

declare Integer UserRecord for Page;

if (UserRecord !=-1)	(Page.GetFirstChild("RecordTime") as CMlLabel).SetText(TextLib::TimeToText(UserRecord));
But the game says that it's not possible to send null values, even if the UserRecord is not null when I log it. Error:

Code: Select all

ERR [Libs/TrackMania/TMRace.Script.txt: 265, 41] Null object does not support declaration of attribute UserRecord.
	TMRace::ShowMedals() [265, 41]
	RaceSolo::Main() [71, 10]
Thanks for any type of help :thx: :thumbsup:
/\rkady
Image
User avatar
Dommy
Translator
Translator
Posts: 1901
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: Sending Ident into manialink?

Post by Dommy »

You're trying to define UserRecord for a Null LocalPage, meaning your layer wasn't initialized yet. Either try using manialink code directly in the ManialinkPage or try yielding the script before setting the user record.

Code: Select all

wait(UIMedals.LocalPage != Null);
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
adamkooo2
Posts: 1371
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: Sending Ident into manialink?

Post by adamkooo2 »

Dommy wrote: 30 Jun 2018, 12:03 You're trying to define UserRecord for a Null LocalPage, meaning your layer wasn't initialized yet. Either try using manialink code directly in the ManialinkPage or try yielding the script before setting the user record.

Code: Select all

wait(UIMedals.LocalPage != Null);
Doesn't work. It sticks loading. Even if I use the code in the manialink, it shows an error with UserId:

Code: Select all

Invalid access to parameter (Null object or elem not found in array) : ScoreMgr>.Map_GetRecord
And I forgot to say that the problem is not in menu but only in gamemode.
/\rkady
Image
User avatar
Dommy
Translator
Translator
Posts: 1901
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: Sending Ident into manialink?

Post by Dommy »

Seems like wherever you run your script in, the ScoreMgr is Null. What context exactly is your script running in? If it's CTmMode, there should be no problems.
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
adamkooo2
Posts: 1371
Joined: 13 Jun 2014, 08:43
Location: Slovakia
Contact:

Re: Sending Ident into manialink?

Post by adamkooo2 »

I am running the code inside library in a gamemode (CTmMode works). I've tested logging the variables and it was working (only in gamemode/library, not in layer (not possible due to UerId)).
But when I tried to send the variable to the layer it gave me the error:

Code: Select all

ERR [Libs/TrackMania/TMRace.Script.txt: 265, 41] Null object does not support declaration of attribute UserRecord.
	TMRace::ShowMedals() [265, 41]
	RaceSolo::Main() [71, 10]
/\rkady
Image
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 0 guests