project #3 code some unit: basic wesnoth creating units guide: unit id

The place to post your WML questions and answers.

Moderator: Forum Moderators

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
needmoreplayers
Posts: 67
Joined: November 17th, 2023, 7:33 pm

project #3 code some unit: basic wesnoth creating units guide: unit id

Post by needmoreplayers »

this thread is for any questions specific to creating addons units

ref: https://wiki.wesnoth.org/BuildingUnits


where to see find things much more detail and indepth when it comes to 'id' and about 'id' so can understand how 'id' in wesnoth codes work exactly

1

for example lets say we have a unit call

id= special unit Symphony of War



2

can we also have

name= special unit Symphony of War

or does the 'name=' Have to be different

if it has to be different, why? is it cos wml was made like that

if it doesn't have to be different, why? is it cos wml was made like that

if you do the above, and below, things in lua, would that be the same way as doing it in wml


3

is a name= needed or no?

is it cos lua and wml is like that?

if you dont have a name= would that break map/campaign or it wont[/list]

let's say name= is blank

would that break map/game or is name= not actually needed


4

also this id= can or cannot be the same name as used in any other addon?
or it has to be always be different?

let's say those other addons (made by others) are used sometimes and sometimes not


5

> When referencing the unit type, the id need be reproduced verbatim, without typos, and in a case-sensitive manner

is there anyway in lua or wml to shorten the names used for id=

are there any ways to reset and redefined things when they were previously marked or defined or set?


for example lets say

id= special unit Symphony of War

then can we do

special unit Symphony of War = susw or su:sw

and then always use 'susw or su:sw' throughout code after that point or we cannot?

for example in english or other languages you can do that

can that be done in wesnoth coding stuff

if we cant, why not? is it cos lua is like that?

if we can, why? is it cos lua is like that?


6

and later on use

recruit= su:sw

and it'd also work?

since now su:sw is being used consistently and is a constant

7

> When referencing the unit type, the id need be reproduced verbatim, without typos, and in a case-sensitive manner
> the game will throw Unknown Unit errors.

when debugging testing stuff in different maps/campaigns, this error was one of the ones that happend

when Unknown Unit errors happens for units (that came From addons not being used in a map/game)

is that a problem with the addon with those units names (even when that addon wasn't used)

or is that a problem with a different addon (used in that map/campaign)?


8

> You can have a complex id, but a simple name. Remember that this is NOT the same as the name of a specific instance of a unit created in a scenario via [unit].

what links or pages or places anywhere talks about w/e this part is about
Last edited by needmoreplayers on December 30th, 2023, 5:33 pm, edited 4 times in total.
User avatar
Pentarctagon
Project Manager
Posts: 5566
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: creating addons units: basic wesnoth creating units guide: unit id

Post by Pentarctagon »

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
Ravana
Forum Moderator
Posts: 3014
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: creating addons units: basic wesnoth creating units guide: unit id

Post by Ravana »

1) correct
2) test it yourself, you learn more that way
3) test it yourself, you learn more that way
4) you should be familiar with error config: Multiple [unit_type]s with id=.. encountered.
5) there is no builtin way
6) if you used wml variable based way in 5, you could do something like recruit=$nmp_unit_map.susw. For your skill level I suggest skipping 5) and 6).
8) is probably about difference between [unit] and [unit_type]
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: creating addons units: basic wesnoth creating units guide: unit id

Post by gnombat »

In case it's not obvious:
  • The name is what gets displayed to the player in the game. (In the sidebar, in the recruit list, etc.)
  • The id is what you use to refer to the unit type from within code. (WML code, Lua code, etc.) It's not intended to be displayed to the player in the game. (The BuildingUnits page seems not entirely clear on this point.)
Post Reply