Creating a simple add-on to load units

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
The_Gnat
Posts: 2078
Joined: October 10th, 2016, 3:06 am
Contact:

Creating a simple add-on to load units

Post by The_Gnat » November 20th, 2016, 7:00 am

Hi, Stopsignal had asked how to load his unit he has created to play it in game and i thought (since he is planning on creating more units anyway) that creating a simple add-on would probably be the best option for him.

To create a simple add-on you need: :P (maybe this isn't as simple as i had originally said but if you read through the steps you should understand whats going happening)

1. a folder in the userdata/data/add-ons/ folder (this is your add-on's folder)

2. a _main.cfg file (which will load all your add-on for you place it in your addon folder)
what to put into the _main.cfg file
Inside the _main.cfg file you need:
- to load your images using:

Code: Select all

[binary_path]
    path=data/add-ons/YOUR_FOLDER
[/binary_path]
- to load your units using:

Code: Select all

[+units]
    {~add-ons/YOUR_FOLDER/units}
[/units]
- to only do this if you are playing multiplayer put the above two sections of code inside:

Code: Select all

#ifdef MULTIPLAYER

     #PUT THE ABOVE TWO SECTIONS OF CODE RIGHT HERE

#endif
3. a folder to store your units (just create another folder called units in your addon's folder and put all your units in it)

4. a folder to store your images (just create another folder called images in your addon's folder)
Other steps to create a multiplayer era
5. a folder called utils to store your era files

6. a file called YOUR_ERA.cfg in the utils folder and a file called YOUR_SIDE.cfg
- and inside YOUR_SIDE file put a multiplayer side:

Code: Select all

[multiplayer_side]
    id=YOUR_SIDES_ID
    name= _"YOUR_SIDES_NAME"
    image="YOUR_SIDES_PICTURE"
    {MAGENTA_IS_THE_TEAM_COLOR}
    type=random
    leader=YOUR_COMA_SEPERATED_LIST_OF_WHAT_YOUR_SIDES_LEADER_CAN_BE
    random_leader=YOUR_COMA_SEPERATED_LIST_OF_WHAT_YOUR_SIDES_LEADER_CAN_BE
    recruit=YOUR_COMA_SEPERATED_LIST_OF_WHAT_YOUR_SIDE_CAN_RECRUIT
    music=traveling_minstrels.ogg
    terrain_liked=Um,Us,Uu
    [ai]
        recruitment_pattern=fighter, fighter, healer, mixed fighter
    [/ai]
[/multiplayer_side]
- and inside YOUR_ERA file put a multiplayer era:

Code: Select all

[era]
    id=YOUR_ERA_ID
    name= _ "Default + YOUR_ERA_NAME"
    description= _ "The YOUR_ERA_NAME along with the standard factions"

    {RANDOM_SIDE}
    {~add-ons/YOUR_FOLDER_NAME/utils/YOUR_SIDE_FILE_NAME.cfg}
    {multiplayer/factions/rebels-default.cfg}
    {multiplayer/factions/loyalists-default.cfg}
    {multiplayer/factions/northerners-default.cfg}
    {multiplayer/factions/knalgans-default.cfg}
    {multiplayer/factions/drakes-default.cfg}
    {multiplayer/factions/undead-default.cfg}

[/era]
In the previous two sections of code all the places where is says YOUR_XXXX just remove them and replace them with the what you want to go in their (ex: YOUR_FOLDER_NAME replace with Deepones_Era) (don't change RANDOM_SIDE or MAGENTA_IS_THE_TEAM_COLOR)
- and when you want to upload your add-on to the wesnoth add-on database you need a server.pbl file read this

I have attached a archive for Stopsignal which is an era that loads his units! (EDIT the newest version of stopsignals era the deepones is on the addon server for 1.12 it currently is in beta)

NOTE: the deepones era is available on the 1.12 add-on server.
Attachments
Deepones_Era.zip
Second version
(165.91 KiB) Downloaded 151 times
Deepones_Era.zip
deepones era, EDIT: version 1.2
(134.79 KiB) Downloaded 153 times

Post Reply