Scripted Choose map help

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
adamkooo2
Posts: 1309
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

Scripted Choose map help

Post by adamkooo2 » 01 Mar 2018, 18:16

Hello all!

I want to have a scripted "select camapaign track menu" in my title pack(s). So I started to script, but I've encountered a problem that I am unable to solve. The game says that:

Code: Select all

ERROR foreach loop requires an array
I understand the error, but I am unable to solve it

Code: Select all

<frame id="M_Map" z-index="1" pos="{{M_posX}} 0">
	<quad pos="-66 44" z-index="1" size="40 32" style="BgsChallengeMedals" substyle="BgNotPlayed" scriptevents="1" id="M_Main"/>
	<frame id="M_Lock" hidden="1">
	<quad pos="-66 44" z-index="1" size="40 32" style="BgsChallengeMedals" substyle="BgPlayed" scriptevents="1"/>
	<quad pos="-46 44" z-index="3" size="25 25" style="Icons128x128_1" substyle="Padlock" scriptevents="1" halign="center"/>
	</frame>
	<label pos="-46 15.5" z-index="2" size="36 6" style="TextCardSmallScores2Rank" textcolor="000000FF" textsize="2.5" valign="center2" halign="center" id="M_Name"/>
	<quad pos="-64.5 43" z-index="" size="37 25" id="M_Icon"/>
</frame>
<script><!--
#Include "TextLib" as TextLib
main() 
{
		declare Camp_  = DataFileMgr.Campaigns[0];
		declare CampA_  = DataFileMgr.Campaigns[0].MapGroups[0];
		declare M_MapNew			<=> (Page.MainFrame.GetFirstChild("M_Map") 	as CMlFrame);

		declare CImage[Text]	MapMedals;
		declare Map_ = Camp_.MapGroups[0].MapInfos[0+0];		
		declare NbMedals = ScoreMgr.Map_GetMultiAsyncLevel(LocalUser.Id, Map_.MapUid, Camp_.ScoreContext);
		declare M_posX = 0;
		declare M_posY = 0;
		log("blabla");
		
		foreach (Map in CampA_){ //BTW shows an error on this line (with CampA_)
			
			M_posX = M_posX + 25;
			if (Map_.Unlocked == False) {
				Page.GetFirstChild("M_Lock").Show;
			}
			(Page.GetFirstChild("M_MainNew") as CMlQuad).ClipWindowRelativePosition = M_Map_.PosX, 0; //not working trying to solve it
			Page.GetFirstChild("M_MainNew").Show;
			(Page.GetFirstChild("M_Name") as CMlLabel).SetText(Map_.Name);
			//(Page.GetFirstChild("M_Main") as CMlQuad).Id = Map_.Name; //not working, trying to solve it
			
		}
}
		--></script>		
Thanks anyone for atleast reading it :thx:
/\rkady
Image

User avatar
Qlex
Nadeo
Nadeo
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: Scripted Choose map help

Post by Qlex » 01 Mar 2018, 18:20

Hi,

I think you should replace CampA_ by CampA_.MapInfos . Does this work?

User avatar
adamkooo2
Posts: 1309
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

Re: Scripted Choose map help

Post by adamkooo2 » 01 Mar 2018, 18:34

it works! :thx:
/\rkady
Image

User avatar
Qlex
Nadeo
Nadeo
Posts: 239
Joined: 03 Jun 2012, 13:17

Re: Scripted Choose map help

Post by Qlex » 01 Mar 2018, 18:42

I am glad I could help.

Best of luck! :thumbsup:

User avatar
adamkooo2
Posts: 1309
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

Re: Scripted Choose map help

Post by adamkooo2 » 02 Mar 2018, 20:58

Hi again,

I would like to ask how to create an amount of frames in script?
Here's my code:

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
	<manialink version="3">
		<quad pos="-66 44" z-index="1" size="40 32" style="BgsChallengeMedals" substyle="BgNotPlayed" id="aa" hidden="1"/>
		<frame id="M_Map" z-index="1">
			<quad pos="-66 44" z-index="1" size="40 32" style="BgsChallengeMedals" substyle="BgNotPlayed" id="M_Main" scriptevents="1"/>
			<label pos="-46 15.5" z-index="2" size="36 6" style="TextCardSmallScores2Rank" textcolor="000000FF" textsize="2.5" valign="center2" halign="center" id="M_Name" text="NAME"/>
			<quad pos="-64.5 43" z-index="0" size="37 25" id="M_Icon"/>
			<quad pos="-38.6 24.3" z-index="5" size="10 10" id="M_Medal"/>
			<frame id="M_Lock" hidden="1">
				<quad pos="-66 44" z-index="1" size="40 32" style="BgsChallengeMedals" substyle="BgPlayed" scriptevents="1"/>
				<quad pos="-46 44" z-index="3" size="25 25" style="Icons128x128_1" substyle="Padlock" scriptevents="1" halign="center"/>
			</frame>
		</frame>
		<script><!--
#Include "TextLib" as TextLib
main() 
{
        //Text[]
		declare Camp_  = DataFileMgr.Campaigns[1]; //kampaň
		declare CampA_  = DataFileMgr.Campaigns[0].MapGroups[0];
		declare M_MapNew	<=> (Page.MainFrame.GetFirstChild("M_Map") 	as CMlFrame);

		//declare CImage[Text]	MapMedals;				
		declare Real M_posX;
		declare Real M_posY;
		declare Integer i; 
		declare o = 42.; 
		declare p = -35.; 
		declare Vec2 M_posXY;
		declare Text LastOpenedMap;
		log("nejde to moc zatiaÄľ");
		
		M_posXY.X = M_posX; //pozicia x
		M_posXY.Y = M_posY; //...         y
		
		
		
		foreach (Map in CampA_.MapInfos)	{ 
			i += 1;
			
			if (i<=5)	{
				M_posX = (i-1) * o;
				M_posY = 0. * p;
				}
			if (i>5 && i<=10)	{
				M_posX = (i-6) * o;
				M_posY = 1 * p;
				}
			if (i>10 && i<=15)	{
				M_posX = (i-11) * o;
				M_posY = 2 * p;
				}
			if (i>15&& i<=20)	{
				M_posX = (i-16) * o;
				M_posY = 3. * p;
			}
			if (i>20&& i<=25)	{
				M_posX = (i-21) * o;
				M_posY = 4 * p;
			}
			if (i>25&& i<=30)	{
				M_posX = (i-26) * o;
				M_posY = 5 * p;
			}
			if (i>30&& i<=35)	{
				M_posX = (i-31) * o;
				M_posY = 0. * p;
			}
			if (i>35)	{
				log("ERROR");
			}
			
			if (Map.Unlocked == False) {
				(Page.GetFirstChild("M_Lock") as CMlFrame).Show();
				}
				else	{
				(Page.GetFirstChild("M_Lock") as CMlFrame).Hide();
			}
			
			declare NbMedals = ScoreMgr.Map_GetMultiAsyncLevel(NullId, Map.MapUid, Camp_.ScoreContext);

			
			switch (NbMedals)	{
			case 4: {
				(Page.GetFirstChild("M_Medal") as CMlQuad).ImageUrl = "file://Media/Images/Medal/NadeoMedal.dds";
			}
			case 3: {
				(Page.GetFirstChild("M_Medal") as CMlQuad).ImageUrl = "file://Media/Images/Medal/GoldMedal.dds";
			}
			case 2: {
				(Page.GetFirstChild("M_Medal") as CMlQuad).ImageUrl = "file://Media/Images/Medal/SilverMedal.dds";
			}
			case 1: {
				(Page.GetFirstChild("M_Medal") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BronzeMedal.dds";
			}
			case 0: {
				(Page.GetFirstChild("M_Medal") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
			}
			}	
			//log("medals on " ^ Map.Name ^ ": " ^ NbMedals ^ ", unlocked = " ^ Map.Unlocked);			
			M_MapNew.RelativePosition.X = M_posX;
			M_MapNew.RelativePosition.Y = M_posY;			
			(Page.GetFirstChild("M_Name") as CMlLabel).SetText(Map.Name);
			
			
			//AnimManager::Add("M_Map", "", "0", "0", "Linear ");	//want to use it here instead of this because it doesn't work 				
			
		}
		log(i^" test! "^M_posXY^" .");
		while(True){
        foreach (Event in PendingEvents) {
            if (Event.Type ==  CMlEvent::Type::MouseClick) {
                if (Event.ControlId == "M_Main") {

					(Page.GetFirstChild("M_Main") as CMlQuad).StyleSelected = True;
					if ((Page.GetFirstChild("M_Main") as CMlQuad).StyleSelected == True) 	{
						//LastOpenedMap = Map.Name;
					}
				}
			}
		}
		yield;
	}		
}
		

		--></script>
</manialink>
I want to create a new frame of frame "M_Map" in "foreach (Map in CampA_.MapInfos)" section.
Thanks :thx:
/\rkady
Image

User avatar
Miss
Posts: 1390
Joined: 05 Jan 2016, 11:34
Location: The Netherlands
Contact:

Re: Scripted Choose map help

Post by Miss » 03 Mar 2018, 11:45

As far as I know it's not possible to add new Manialink elements to existing manialinks with normal Maniascript. :/
1070 GTX, i7 4790k, 16GB RAM, Windows 10
Forum moderator, opinions are my own. :thx:
Check out Image openplanet, the alternative Maniaplanet & Turbo scripting platform! (Openplanet subforum)
I also stream on Twitch and tweet on Twitter.

User avatar
maxi031
Posts: 350
Joined: 17 Jul 2011, 00:55

Re: Scripted Choose map help

Post by maxi031 » 03 Mar 2018, 12:44

You can have pre-made but hidden elements that you can show/hide when needed.
My specs:
MOBO: MB AM3+ 970 Gigabyte GA-970A-DS3P
CPU: AM3+ AMD FX-8320E
GPU: Nvidia GeForce GTX750-Ti ASUS 2GB DDR5
RAM: DDR3 8GB 1866MHz Kingston HyperX
SSD: SATA3 120gb SanDisk
OS: Windows 7 Profesional SP1 64-bit OS
TY MICMO

User avatar
adamkooo2
Posts: 1309
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

Re: Scripted Choose map help

Post by adamkooo2 » 09 Mar 2018, 12:00

Thanks everyone for his/her help :thx:


Hello,
I am working on a map browser and I get an error anytime I load the script(seems it loads more maps than it uses, so the map id is null)

I have a question to make my script working:
Is there a way how to get count of a maps in the folder?

I have try this method, but isn't working:

Code: Select all

declare MCount = TextLib::ToInteger(DataFileMgr.Map_GetGameList(path, True));
Here's my actual code:

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
	<manialink version="3">
	
	<stylesheet>
		<style id="M_MedalA M_MedalG M_MedalB M_MedalS" pos="-38.6 24.3" z-index="25" size="11 10"/> 
		<style id="M_Name1 M_Name2 M_Name3 M_Name4 M_Name5 M_Name6 M_Name7 M_Name8 M_Name9 M_Name10 M_Name11 M_Name12" posn="-36 15.5" sizen="90 6" style="TextCardSmallScores2Rank" textcolor="000000FF" textsize="2.5" valign="center2" z-index="10" halign="left"/>
		<style id="M_Time1 M_Time2 M_Time3 M_Time4 M_Time5 M_Time6 M_Time7 M_Time8 M_Time9 M_Time10 M_Time11 M_Time12" pos="44 16" sizen="20 6" style="TextCardSmallScores2Rank" textcolor="000000FF" textsize="2.5" valign="center2" z-index="10" halign="right"/>			
		<style id="M_SP" style="TextRaceMessage" textsize="2.8" valign="center2" z-index="10"/>		
		<style id="M_Main1 M_Main2 M_Main3 M_Main4 M_Main5 M_Main6 M_Main8 M_Main7 M_Main9 M_Main10 M_Main11 M_Main12 M" pos="-50 44" size="100 9"  style="Bgs1" substyle="BgCardChallenge"/>
	</stylesheet>
	
	<frame id="MainPanel" z-index="-4">		
			<quad style="Bgs1" substyle="BgButtonOff"  posn="-161 92" sizen="78 183" z-index="-4"/>
			<quad style="Bgs1" substyle="BgTitle3_2"  posn="-161 92" sizen="78 24" modulatecolor="2265A9FF" z-index="-3"/>
			<label id="LabelWelcome" text="Play Solo" posn="-154 86" sizen="34 8" translate="1"/>
			<label id="LabelActivity" text="Choose a Map" posn="-156 78" sizen="39 10" translate="1"/>			
		</frame>
		
		<quad style="Bgs1" substyle="BgHealthBar"  posn="0 61" sizen="104 116" z-index="-4" halign="center"/>	
		<quad style="Bgs1" substyle="BgHealthBar"  posn="0 78" sizen="116 148" z-index="-4" halign="center"/>
				
		<quad style="Bgs1" substyle="BgTitleShadow"  posn="0 78" sizen="116 148" z-index="-4" halign="center"/>	
			<quad pos="-154 59" z-index="0" size="20 20" bgcolor="FFFA" id="Browse" scriptevents="1"/>
			<quad style="Icons64x64_1" substyle="Refresh"  posn="43 68" sizen="7 7" scriptevents="1" id="Reset"/>
			<quad style="Icons64x64_1" substyle="ToolUp"  posn="-50 68" sizen="7 7" scriptevents="1" id="UndoPath"/>	
			<quad posn="-15.5 -59" sizen="9 9" scriptevents="1" id="Left" image="file://Media/Images/Icon/left next.png" imagefocus="file://Media/Images/Icon/left next_1.png"/>
			<label pos="0 -61" z-index="0" size="15 5" id="Page" text="1" halign="center"/>
			<label pos="0 65" z-index="0" size="90 6" halign="center" id="M_Path" valign="center2"/>
			<quad posn="15.5 -68" sizen="9 9" scriptevents="1" id="Right" image="file://Media/Images/Icon/left next.png" imagefocus="file://Media/Images/Icon/left next_1.png" rot="180"/>
			
			<quad pos="-48 56" z-index="0" size="8 8" id="M_Col"/>
			
		<quad style="Bgs1" substyle="BgHealthBar"  posn="117 48" sizen="59 100" z-index="-6" halign="center"/>	
		<quad posn="92 38" sizen="5 5" scriptevents="1" id="M_Flag" image="file://Media/Images/BannerChallengeGreyUnknown.dds"/>
		<frame id="White" hidden="" z-index="-1">			
			<quad id="M_Main1" hidden="1" scriptevents="1"/>				
			<quad id="M_Main2" scriptevents="1" hidden="1"/>
			<quad scriptevents="1" id="M_Main3" hidden="1"/>
			<quad scriptevents="1" id="M_Main4" hidden="1"/>
			<quad scriptevents="1" id="M_Main5" hidden="1"/>								
			<quad scriptevents="1" id="M_Main6" hidden="1"/>
			<quad scriptevents="1" id="M_Main7" hidden="1"/>				
			<quad scriptevents="1" id="M_Main8" hidden="1"/>				
			<quad scriptevents="1" id="M_Main9" hidden="1"/>							
			<quad scriptevents="1" id="M_Main10" hidden="1"/>				
			<quad scriptevents="1" id="M_Main11" hidden="1"/>				
			<quad scriptevents="1" id="M_Main12" hidden="1"/>							
		</frame>
		
		<quad pos="87 48" z-index="-5" size="60 10" bgcolor="FFFA" style="Bgs1" substyle="BgTitle3_1"/>
		<quad pos="-58 78" z-index="5" size="115 11" bgcolor="FFFA" style="Bgs1" substyle="BgTitle3_1"/>
		<label pos="137 38" z-index="0" size="20 5" id="M_CP" halign="right"/>
		<label pos="97 38" z-index="0" size="20 5" id="M_Author"/>
		<label pos="117 45" z-index="0" size="47 5" id="M_Training" text="???" style="TextChallengeNameMedalNone" halign="center" textsize="2.4"/>
		<label pos="-53 72.5" z-index="6" size="58 7" id="M_Training" text="Challenges available:" style="TextChallengeNameMedalNone" halign="left" textsize="2.5" translate="1" valign="center2"/>
		<label id="M_SP" pos="93 -24"/>	
		<label pos="93 -26" z-index="0" size="46 17" id="M_Comments"/>
		<quad id="M_Icon" style="Bgs1" substyle="BgWindow4" size="50 39" pos="92 31"/>
		<quad id="M_MedalB" pos="93 -10" image="file://Media/Images/Medal/BlackMedal.dds"/>
		<quad id="M_MedalS" pos="105 -10" image="file://Media/Images/Medal/BlackMedal.dds"/>
		<quad id="M_MedalG" pos="117 -10" image="file://Media/Images/Medal/BlackMedal.dds"/>
		<quad id="M_MedalA" pos="129 -10" image="file://Media/Images/Medal/BlackMedal.dds"/>
		<quad style="Icons64x64_1" substyle="First"  posn="92 42" sizen="12 11" image="file://Media/Images/BannerChallengeGreyUnknown.dds" hidden="1"/>
		<label sizen="55 9" bgcolor="00c" scriptevents="1"  posn="92 -42" z-index="-3" style="CardButtonMediumXL" text="Play" translate="1"/>
		
		
		<frame id="Str1" hidden="" z-index="1">	

			<label id="M_Name1"/>
			<label id="M_Name2"/>
			<label id="M_Name3" />
			<label id="M_Name4"/>
			<label id="M_Name5"/>		
			<label id="M_Name6"/>
			<label id="M_Name7"/>
			<label id="M_Name8"/>
			<label id="M_Name9"/>
			<label id="M_Name10"/>
			<label id="M_Name11"/>
			<label id="M_Name12"/>
			
			<label id="M_Time1"/>
			<label id="M_Time2"/>
			<label id="M_Time3"/>
			<label id="M_Time4"/>
			<label id="M_Time5"/>		
			<label id="M_Time6"/>
			<label id="M_Time7"/>
			<label id="M_Time8"/>
			<label id="M_Time9"/>
			<label id="M_Time10"/>
			<label id="M_Time11"/>
			<label id="M_Time12"/>
		</frame>

		<script><!--


#Include "TextLib" as TextLib
Void Deselect()	{
	(Page.GetFirstChild("M_Main1") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main2") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main3") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main4") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main5") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main6") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main7") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main8") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main9") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main10") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main11") as CMlQuad).StyleSelected = False;
	(Page.GetFirstChild("M_Main12") as CMlQuad).StyleSelected = False;
}
Void Deselect2()	{
	(Page.GetFirstChild("M_MedalA") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
	(Page.GetFirstChild("M_MedalG") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
	(Page.GetFirstChild("M_MedalS") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
	(Page.GetFirstChild("M_MedalB") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
	(Page.GetFirstChild("M_Icon") as CMlQuad).ImageUrl = "";
	(Page.GetFirstChild("M_CP") as CMlLabel).SetText("");
	(Page.GetFirstChild("M_SP") as CMlLabel).SetText("");
	(Page.GetFirstChild("M_Training") as CMlLabel).SetText("???");
	(Page.GetFirstChild("M_Comments") as CMlLabel).SetText("");
	(Page.GetFirstChild("M_Author") as CMlLabel).SetText("");
}
main() 
{
		declare Rob = False;
		
		declare SP = "";//body zručnosti 
		declare Real M_posY;
		declare Text _ThumbnailUrl;
		declare Text Flag; //pocetsrean;
		declare S = 1;	//strana
		declare p = -9.; //medzera okna v Y
		//declare Text LastOpenedMap;
		log("nejde to moc zatiaľ");
		declare path = "RaceTM2UF/1";
		//declare MCount = TextLib::ToInteger(DataFileMgr.Map_GetGameList(path, True)); //not working, but it's needed
		declare CampA_ = DataFileMgr.Map_GetGameList(path, True);
		
		sleep(30);
		Rob = True;
		
		while(True){
		(Page.GetFirstChild("M_Path") as CMlLabel).SetText(""^path);
		
		
        foreach (Event in PendingEvents) {
            if (Event.Type ==  CMlEvent::Type::MouseClick) {
				for (y, 1, 12){					
					if (Event.ControlId == "M_Main"^y) {																		
						wait( DataFileMgr.Map_GetGameList(path, True) != Null);	
						if (CampA_.MapInfos[y+(S*12)-13] != Null)	{
						
						
							declare  Map = CampA_.MapInfos[y+(S*12)-13];										
						if ((Page.GetFirstChild("M_Main"^y) as CMlQuad).StyleSelected == True) 	{
							(Page.GetFirstChild("M_Main"^y) as CMlQuad).StyleSelected = False;
							Deselect2();
						}
						
						
						else if ((Page.GetFirstChild("M_Main"^y) as CMlQuad).StyleSelected == False) {
							Deselect();
							(Page.GetFirstChild("M_Main"^y) as CMlQuad).StyleSelected = True;
							
							if (Map.Name != (Page.GetFirstChild("M_Name"^y) as CMlLabel).Value)	{
							log("ERROR!");
							}
							(Page.GetFirstChild("M_Training") as CMlLabel).SetText(""^Map.Name);
							(Page.GetFirstChild("M_Comments") as CMlLabel).SetText(""^Map.Comments);
							(Page.GetFirstChild("M_Author") as CMlLabel).SetText(""^Map.AuthorLogin);		
			//meDAJly
			declare NbMedals = ScoreMgr.Map_GetMultiAsyncLevel(NullId, Map.MapUid, "");
			switch (NbMedals)	{
			case 4: {
				(Page.GetFirstChild("M_MedalA") as CMlQuad).ImageUrl = "file://Media/Images/Medal/NadeoMedal.dds";
				(Page.GetFirstChild("M_MedalG") as CMlQuad).ImageUrl = "file://Media/Images/Medal/GoldMedal.dds";
				(Page.GetFirstChild("M_MedalS") as CMlQuad).ImageUrl = "file://Media/Images/Medal/SilverMedal.dds";
				(Page.GetFirstChild("M_MedalB") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BronzeMedal.dds";
			}				
			case 3: {
				(Page.GetFirstChild("M_MedalA") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalS") as CMlQuad).ImageUrl = "file://Media/Images/Medal/SilverMedal.dds";
				(Page.GetFirstChild("M_MedalB") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BronzeMedal.dds";
				(Page.GetFirstChild("M_MedalG") as CMlQuad).ImageUrl = "file://Media/Images/Medal/GoldMedal.dds";
				}
			case 2: {
				(Page.GetFirstChild("M_MedalA") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalG") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalB") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BronzeMedal.dds";
				(Page.GetFirstChild("M_MedalS") as CMlQuad).ImageUrl = "file://Media/Images/Medal/SilverMedal.dds";
			}
			case 1: {
				(Page.GetFirstChild("M_MedalA") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalG") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalS") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalB") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BronzeMedal.dds";
			}
			case 0: {
				(Page.GetFirstChild("M_MedalA") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalG") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalS") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
				(Page.GetFirstChild("M_MedalB") as CMlQuad).ImageUrl = "file://Media/Images/Medal/BlackMedal.dds";
			}
			}

			//(Page.GetFirstChild("M_Flag") as CMlQuad).ChangeImageUrl(Flag);
			
			
			_ThumbnailUrl = "file://Media/Images/Icon/IconEnvStadium.dds";//docasne riesenie
			(Page.GetFirstChild("M_Icon") as CMlQuad).ChangeImageUrl(_ThumbnailUrl);
			
			//skillBODY
			SP = Map.CollectionName;
			(Page.GetFirstChild("M_CP") as CMlLabel).SetText(""^Map.CopperPrice);
			if (SP == "")	{
			(Page.GetFirstChild("M_SP") as CMlLabel).SetText("");
			}
			else	{
			(Page.GetFirstChild("M_SP") as CMlLabel).SetText("Environment: "^SP);
			}
			}
						}
						
					}
				}
				if (Event.ControlId == "Reset") {
					DataFileMgr.Map_RefreshFromDisk();
					log("Refr. maps");
					Deselect();
					Deselect2();
					Rob = True;
				}
				if (Event.ControlId == "Browse") {
					Rob = True;
                	}
				if (Event.ControlId == "UndoPath") {
					path = "";
					Deselect();
					Deselect2();
					Rob = True;
					CampA_ = DataFileMgr.Map_GetGameList(path, True);
                	}
				if (Event.ControlId == "Right")	{
					Deselect();
					Deselect2();
					S += 1;
					(Page.GetFirstChild("Page") as CMlLabel).SetText(""^S);	
					}
				if (Event.ControlId == "Left")	{
					Deselect();
					Deselect2();
					if (S >1)	{
						S -= 1;
					}
					(Page.GetFirstChild("Page") as CMlLabel).SetText(""^S);
                	}
				}										
			}	
			
		//pre každú trať v danej kampani
		
			for(i, 1, 12)	{ 
			
	
			if (Rob == True)	{
			
			//wait (CampA_== Null);		
			declare Map = CampA_.MapInfos[i+(S*12)-13];
			M_posY = i*p;
			
			(Page.GetFirstChild("M_Main"^i) as CMlQuad).Show();
			(Page.GetFirstChild("M_Name"^i) as CMlQuad).Show();
					
						
			(Page.GetFirstChild("M_Name"^i) as CMlLabel).SetText(""^Map.Name);
			(Page.GetFirstChild("M_Time"^i) as CMlLabel).SetText(""^TextLib::TimeToText(Map.TMObjective_GoldTime));
			//PoziCIA vsetkeho					
			
			(Page.GetFirstChild("M_Main"^i) as CMlQuad).RelativePosition.Y = M_posY+ 65;
			(Page.GetFirstChild("M_Name"^i) as CMlLabel).RelativePosition.Y = M_posY+ 60;
			(Page.GetFirstChild("M_Time"^i) as CMlLabel).RelativePosition.Y = M_posY+ 60;		
		}
	}
	yield;
	}
	log(S^" (not) works! "^M_posY^" blabla");	
}
	
		

		--></script>
</manialink>
Thanks for your reply :thx:
/\rkady
Image

zocka
Posts: 205
Joined: 15 Jun 2010, 17:56

Re: Scripted Choose map help

Post by zocka » 09 Mar 2018, 20:43

Map_GetGameList returns a CTaskResult_MapList which has the array MapInfos...
If your resulting object doesn't have anything like size or length, just look through the docs where you can go towards anything like array length from the data you have...

Code: Select all

DataFileMgr.Map_GetGameList(path, True).MapInfos.count
manialink minigame shatter
my manialink: zockaml
my maniaflash: maniaflash?zocka

User avatar
adamkooo2
Posts: 1309
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

Re: Scripted Choose map help

Post by adamkooo2 » 09 Mar 2018, 21:11

Thank you, it works! :thumbsup: :thx:

I'd like to ask:
Is there's possibility to get map thumbnail with maniascript?

I have searched on maniascript refence, but I've found nothing :/
This is the last thing (I hope) need for completing my script :)
/\rkady
Image

Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 3 guests