Page 1 of 1
Sending Ident into manialink?
Posted: 24 Jun 2018, 01:41
by BigBang1112
I'm trying to send
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?
Re: Sending Ident into manialink?
Posted: 24 Jun 2018, 23:59
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:
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:
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).
Re: Sending Ident into manialink?
Posted: 25 Jun 2018, 09:01
by BigBang1112
Thanks for this^^
Re: Sending Ident into manialink?
Posted: 30 Jun 2018, 09:17
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

Re: Sending Ident into manialink?
Posted: 30 Jun 2018, 12:03
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.
Re: Sending Ident into manialink?
Posted: 01 Jul 2018, 08:48
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.
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.
Re: Sending Ident into manialink?
Posted: 02 Jul 2018, 14:24
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.
Re: Sending Ident into manialink?
Posted: 02 Jul 2018, 19:56
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]