MP Tutorial Presentation [NW] Creating a new unit section

Users who are viewing this thread

[Tutorial] Creating a new unit section


I've been toying around a bit with the unit menu of NW the past hours. With some sweet results. (For someone who barely touches presentations etc) Considering I haven't really seen this in any mod currently I thought that I mind as well create a quick tutorial for it.

What is the advantage of a new section?
You can fit in a whole new bunch of units in the menu without scretching it out or anything. Simple and efficient. Especially for the modifications out there that could use the space!

This is the result we will be working towards in this tutorial:
1FE43110AF67EBAB5A36B9BCADEC4EF931BE3336


Files we will be edditing (coloured Green):

- module_strings
- module_presentations
- module_constants
- module_scripts

Section name

We shall be naming our new section "Bydanders" for the sake of whatever. You can change the name of your section to whatever you want. But you'll have to replace "bydanders".

Getting started

Let's start with module_strings as we will need to start with creating a new string to be used in the presentation.
This will be the name of the section.

Search for:
Code:
("cavalry", "Cavalry"),
Place under that:
Code:
  ("bydanders", "Bydanders"),

Now we will head to module_presentations to create the new section.

Search for:
Code:
        (create_mesh_overlay, reg0, "mesh_white_plane"),
        (overlay_set_color, reg0, 0x000000),
        (overlay_set_alpha, reg0, 0xD0),
        (position_set_x, pos1, 370),
        (position_set_y, pos1, 660),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 5500),
        (position_set_y, pos1, 1600),
        (overlay_set_size, reg0, pos1),

Place under that (leave one line between it)
Code:
        (create_mesh_overlay, reg0, "mesh_white_plane"),
        (overlay_set_color, reg0, 0x000000),
        (overlay_set_alpha, reg0, 0xD0),
        (position_set_x, pos1, 370),
        (position_set_y, pos1, 610),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 5500),
        (position_set_y, pos1, 1600),
        (overlay_set_size, reg0, pos1),

Search for:
Code:
        (create_button_overlay, "$g_presentation_obj_select_cavalry", "str_cavalry", 0),
        (try_begin),
          (eq, "$g_multiplayer_select_presentation_unit_type", troop_select_type_cavalry),
          (overlay_set_color,"$g_presentation_obj_select_cavalry",0xECEB82),
        (else_try),
          (overlay_set_color,"$g_presentation_obj_select_cavalry",0xFFFFFF),
        (try_end),
        (position_set_x, pos1, 255),
        (position_set_y, pos1, 660),
        (overlay_set_position, "$g_presentation_obj_select_cavalry", pos1),
        #(position_set_x, pos1, 1500),
        #(position_set_y, pos1, 1500),
        #(overlay_set_size, "$g_presentation_obj_select_cavalry", pos1),
        (troop_set_slot,"trp_x_pos","$g_presentation_obj_select_cavalry",250),
        (troop_set_slot,"trp_y_pos","$g_presentation_obj_select_cavalry",660),
        (troop_set_slot,"trp_x_size","$g_presentation_obj_select_cavalry",1000),
        (troop_set_slot,"trp_y_size","$g_presentation_obj_select_cavalry",1000),

Under that, (leave one line between it) place the following:
Code:
        (create_button_overlay, "$g_presentation_obj_select_bydanders", "str_bydanders", 0),
        (try_begin),
          (eq, "$g_multiplayer_select_presentation_unit_type", troop_select_type_bydanders),
          (overlay_set_color,"$g_presentation_obj_select_bydanders",0xECEB82),
        (else_try),
          (overlay_set_color,"$g_presentation_obj_select_bydanders",0xFFFFFF),
        (try_end),
        (position_set_x, pos1, 370),
        (position_set_y, pos1, 610),
        (overlay_set_position, "$g_presentation_obj_select_bydanders", pos1),
        #(position_set_x, pos1, 1500),
        #(position_set_y, pos1, 1500),
        #(overlay_set_size, "$g_presentation_obj_select_bydanders", pos1),
        (troop_set_slot,"trp_x_pos","$g_presentation_obj_select_bydanders",300),
        (troop_set_slot,"trp_y_pos","$g_presentation_obj_select_bydanders",660),
        (troop_set_slot,"trp_x_size","$g_presentation_obj_select_bydanders",1000),
        (troop_set_slot,"trp_y_size","$g_presentation_obj_select_bydanders",1000),

Search for:
Code:
      (else_try),
          (eq,":object","$g_presentation_obj_select_cavalry"),
          (assign, "$g_multiplayer_select_presentation_unit_type",troop_select_type_cavalry),
          (presentation_set_duration, 0),
          (start_presentation,"prsnt_multiplayer_item_select"),

Place under that:
Code:
        (else_try),
		  (eq,":object","$g_presentation_obj_select_bydanders"),
          (assign, "$g_multiplayer_select_presentation_unit_type",troop_select_type_bydanders),
          (presentation_set_duration, 0),
          (start_presentation,"prsnt_multiplayer_item_select"),
(make sure that there is a (else_try) between this new section and the begin of the artillery section)

Next file: module_constants

Search for:
Code:
troop_select_type_artillery

Place under that:
Code:
troop_select_type_bydanders = 4

Now we will head to the last file, module_scripts in order to get units in the new section.

Search for:
Code:
(assign,":unit_type",troop_select_type_artillery),

Between that and (try_end) place this:
Code:
	(else_try),
	  (is_between, ":troop_no", "trp_british_infantry2","trp_british_highlander"), # Brits
	
      (assign,":unit_type",troop_select_type_bydanders),
(You can toy around with what units you want to be on it. At this moment we have the units british_infantry2 and british_highlander placed in the new section.

Run the build and check if they're errors, if none goodjob!


You can create more sections, just re-do the above steps and toy around a bit with the positioning of the string and box.

Hope this helps, there could be a tiny possibility that there could be a mistake in there. If so and noticed please inform me so it can be rapidly adjusted. My first somewhat modding tutorial so mistakes are expected to be made.  :-X

If there are any questions feel free to ask them!

Cheers,
Gokiller

BTW: If this is the complete wrong forum section, appologies.  :oops:
 
Back
Top Bottom