WB Coding Troop name with Player name

Currently viewing this thread:

MarcosPZero

Regular
I'am trying to create a troop in Warband that the name when it's recruited appear has (Playername)'s Regiment or (Playername)'s Mercenary, anyway. So I tried to use the common code for when the AI says your name in the game wich is {playername}, but it did not work out. Can anyone help me make this work ? Thanks.

Here is how I've put it in module_troops.py:
["custom_recruit","{playername}'s Mercenary","{playername}'s Mercenaries" , ...
 
Solution
Thank you @Tocan ! It worked !
So, here how I've done it: I put it at the end of module_triggers

The code provided by @Tocan:

Code:
(0.1, 0, ti_once, [],
[
           (str_store_troop_name, s1, "trp_player"),
           (troop_set_name, "trp_custom_recruit", "@{s1}'s  Mercenary"),
           (troop_set_plural_name, "trp_custom_recruit", "@{s1}'s Mercenaries"),
]),

Well, problem solved. Thank you again.

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
First, when you try something out, tell us always what is happening, even if nothing works.

Second, I think that you need first a normal name for the troops, so without the name of the player included. When the game starts, so after the character creation, I would then set the troops name via the operations str_store_troop_name, str_store_troop_name_plural, troop_set_name and troop_set_plural_name.
 
Upvote 0

MarcosPZero

Regular
I apologize @Eärendil Ardamírë you're totally right . So, what is going wrong it's just that the the troop when recruited appear literally as {playername} Mercenary.

Also, about your reply. Sorry I am new to modding warband, so could you try to elaborate more? Like where and how should I put those operations ? Thank you.
 
Upvote 0

Tocan

Sergeant Knight at Arms
(str_store_troop_name, s1, "trp_player"), (str_store_troop_name, s2, "trp_custom"), (troop_set_name, "trp_custom", "@{s1}'s {s2}"), (troop_set_plural_name, "trp_custom", "@{s1}'s {s2}"),

or

(str_store_troop_name, s1, "trp_player"), (troop_set_name, "trp_custom", "@{s1}'s Mercenary"), (troop_set_plural_name, "trp_custom", "@{s1}'s Mercenaries"),

somewhere in game_start? or get it called before the player enter his name? otherwise a trigger after game_start
edit: added code blocks otherwise Eärendil runs amok at some point ^^
 
Last edited:
Upvote 0

MarcosPZero

Regular
@Tocan. Thank you, but it did not work. I've put it at the end of game_start and the troop really changed its name, but where was supposed to appear the player name, it showed just a blank. It shows like this: 's Mercenary. For some reason the trp_player did not show its name.
 
Upvote 0

John25-

Sergeant at Arms
Maybe the player's name still hasn't been set up when that script is read, let's try to make it happen later - e.g. when you hire the troop in the tavern via module_dialogs.py
 
Upvote 0

Tocan

Sergeant Knight at Arms
try adding a new trigger, like i wrote the game_start get mostly fired before char creation.
(0.1, 0, ti_once, [ #like before/above ]),
 
Upvote 0

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
Yeah, game start is perhaps getting called before the player has a name, so doing it via a trigger once the player enters the world map or something similar should work out fine, as Tocan wrote above.
 
Upvote 0

Tocan

Sergeant Knight at Arms
no, this is a normal trigger, so somewhere in module_triggers. we want that it just run once.
keep in mind with 0.1, 0, ti_once it takes a short ingame time, like the starting message box, after that it should be fine.
 
Upvote 0

MarcosPZero

Regular
@Tocan Well it did not work, it failed at the build_module

FAILED.
MODULE `triggers` ERROR:
failed to parse element #30
not enough elements in module `triggers` entity `None` (4 total): (0.1, 0, 100
000000.0, 'list[len=3]')



COMPILATION FAILED.

I was just writing this messenger when you replied correcting it hahaha. I will try this new one. Thank you.
 
Upvote 0

MarcosPZero

Regular
Thank you @Tocan ! It worked !
So, here how I've done it: I put it at the end of module_triggers

The code provided by @Tocan:

Code:
(0.1, 0, ti_once, [],
[
           (str_store_troop_name, s1, "trp_player"),
           (troop_set_name, "trp_custom_recruit", "@{s1}'s  Mercenary"),
           (troop_set_plural_name, "trp_custom_recruit", "@{s1}'s Mercenaries"),
]),

Well, problem solved. Thank you again.
 
Upvote 0
Solution
Top Bottom