ForestDragon's WML questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
ForestDragon
Posts: 1340
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » November 26th, 2017, 8:17 am

Pentarctagon wrote:You didn't need to add .value it to XP_bank_start.
oh, ok. EDIT: works now, thanks! :D

User avatar
ForestDragon
Posts: 1340
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » January 6th, 2018, 4:26 pm

I'm making yet another MP mod. So, I'm trying to store all sides' default team names, but it seems I messed something up with variables again. here's the current work-in-progress code of the mod:

Code: Select all

#define STORE_DEFAULT_ALLEGIANCE SIDE
  [store_side]
    side={SIDE}     
    variable=side{SIDE}_stored
  [/store_side]
#enddef
[modification]
    id=Alliances_Mod
    name="Alliance Mod"
    description="allows players to make/break alliances with eachother."
    require_modification=no
#    [options]
#    [/options]
[event]
  name=start

  {STORE_DEFAULT_ALLEGIANCE 1}
  {STORE_DEFAULT_ALLEGIANCE 2}
  {STORE_DEFAULT_ALLEGIANCE 3}
  {STORE_DEFAULT_ALLEGIANCE 4}
  {STORE_DEFAULT_ALLEGIANCE 5}
  {STORE_DEFAULT_ALLEGIANCE 6}
  {STORE_DEFAULT_ALLEGIANCE 7}
  {STORE_DEFAULT_ALLEGIANCE 8}
  {STORE_DEFAULT_ALLEGIANCE 9}
  [set_menu_item]
    id=alliance_menu
    description="Alliance Menu"
#    image=".png"
#    [default_hotkey]
#      key="~"
#    [/default_hotkey]
	[show_if]
		[have_unit]
                        x=$x1
                        y=$y1
			side=$side_number
			canrecruit=yes
		[/have_unit]
        [/show_if]		    
    [command]
	[message]
		speaker=narrator
		image=portraits/humans/transparent/marshal.png
		caption="Alliances Menu"
                message="What do you want?"
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Return To Game"}
			[command]
                         [/command]
		[/option]
                [option]                        
			message=  {MENU_IMG_TXT "icons/crossed_sword_and_hammer.png" "Break all your current alliances"}
			[command]
			 [modify_side]
			   side=$side_number
			   team_name=$side[$side_number]_stored.team_name
			 [/modify_side]
                         [/command]
		[/option]
	[/message]            
    [/command]    
  [/set_menu_item]  
  [set_menu_item]
        description=_ "Send alliance request to this side"
        id="send_request"
#        image="misc/cross-white.png"
        [show_if]
            [have_unit]	
                [filter_side]
		   [not]
                    [allied_with]
                        side=$side_number
                    [/allied_with]
		    [or]
		      controller=ai
		    [/or]
		   [/not]
                [/filter_side]
                canrecruit="yes"
                x="$x1"
                y="$y1"
            [/have_unit]
            [and]
              [not]
                [have_unit]	
                   x="$x1"
                   y="$y1"
                   side=$side_number
                 [/have_unit]
              [/not]
            [/and]
        [/show_if]
		  [command]
                         [store_unit]
                            [filter]
                              x=$x1
                              y=$y1
                            [/filter]
                            variable=thisleader
                            kill=no
                         [/store_unit]
                         [store_unit]
                            [filter]
                              side=$side_number
			      canrecruit=yes
                            [/filter]
                            variable=thisleader2
                            kill=no
                         [/store_unit]
	[message]
		speaker=narrator
		image=portraits/humans/transparent/marshal.png
#		for_side=$thisleader.side
		caption="Alliances Menu"
                message="player $side_number| ($thisleader2.name|) wants to ally with you."
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Decline"}
			[command]
               	          [message]
     		             speaker=narrator
 		             image=portraits/humans/transparent/marshal.png
            		     for_side=$side_number
		             caption="Alliances Menu"
                             message="player $thisleader.side| ($thisleader.name|) declined your alliance request."
               	          [/message]
                         [/command]
		[/option]
                [option]                        
			message=  {MENU_IMG_TXT "icons/crossed_sword_and_hammer.png" "Agree"}
			[command]
			 [modify_side]
			   side=$side_number
			   team_name=$side[$side_number]_stored.team_name|,alliance
#			   user_team_name="Alliance"
			 [/modify_side]
			 [modify_side]
			   side=$thisleader.side
			   team_name=$side[thisleader.side]_stored.team_name|,alliance
#			   user_team_name="Alliance"
			 [/modify_side]
               	          [message]
     		             speaker=narrator
 		             image=portraits/humans/transparent/marshal.png
            		     for_side=$side_number
		             caption="Alliances Menu"
                             message="player $thisleader.side| ($thisleader.name|) accepted your alliance request."
               	          [/message]
                         [/command]
		[/option]
	[/message]            
     [/command]
[/set_menu_item]
[/event]
[/modification]

User avatar
Pentarctagon
Forum Administrator
Posts: 3155
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: ForestDragon's WML questions

Post by Pentarctagon » January 6th, 2018, 5:50 pm

side{SIDE}_stored doesn't put it in an array. It means there are variables literally called side1_stored, side2_stored, etc. So rather than
$side[$side_number]_stored.team_name, I believe you would want $side$side_number|_stored.team_name.

Your modification, if meant only for MP, should also specify type=mp.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

User avatar
ForestDragon
Posts: 1340
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » January 6th, 2018, 5:56 pm

Pentarctagon wrote:side{SIDE}_stored doesn't put it in an array. It means there are variables literally called side1_stored, side2_stored, etc. So rather than
$side[$side_number]_stored.team_name, I believe you would want $side$side_number|_stored.team_name.
Works perfectly, thanks! :)

Post Reply