enclave's WML Macros questions Thread
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.
Re: enclave's WML Macros questions Thread
Are you sure it is removed? Its description just has
It doesnt sound like it would be removed from scenario.The event is copied from this unit's wml description into the scenario. The event is carried along with the unit (it can advance etc) and inserted into every scenario where this unit is first created
Re: enclave's WML Macros questions Thread
I was about to edit my post after realize I expect that behavior but never really tested it, sryRavana wrote:Are you sure it is removed? Its description just hasIt doesnt sound like it would be removed from scenario.The event is copied from this unit's wml description into the scenario. The event is carried along with the unit (it can advance etc) and inserted into every scenario where this unit is first created
Edit: I was just trying to imagine how [event] inside [unit] could be usefull in a single scenario. My second try: "you have a macro to spawn different enemies that relies in [insert_tag] stored [unit] tags into variables. You suddenly decide introduce an event when some unit is spawned, so write [event] inside [unit] would be straightforward solution."
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: enclave's WML Macros questions Thread
Thanks Tekelili, will keep it in mind, sounds useful.tekelili wrote:In general... yes; but not exactly. Its usefullness is defined as event is written every time unit is on scenario and event is removed when unit dies (if no other unit with same event still alive). So in a single multiplayer scenario, theorically could have some use like "when player do X give him a teasure but only if his first recruit is still alive". Sure you can do it from a scenario [event], but could be more clean write event inside player 1st recuit "[unit]".enclave wrote:Thanks Tekelili, so it is mostly for compaigns and not for multiplayer scenarios then?
PS. will also test if its actually stops working when unit dies
Re: enclave's WML Macros questions Thread
Question number #2
Does observer have a team? if so, then what is the team_name?
Question number #3
Can [label] have multiple team_name? for example team_name=1,2 ? If not I guess i could still do it by placing label twice.. quite sure.?
Does observer have a team? if so, then what is the team_name?
Question number #3
Can [label] have multiple team_name? for example team_name=1,2 ? If not I guess i could still do it by placing label twice.. quite sure.?
Re: enclave's WML Macros questions Thread
As for question #1 I found my best way to modify ability with:
1) first use [unit] to_variable=x
2) modify ability with {VARIABLE x.abilities. ... }
3) unstore units on map with [unstore_unit] variable=x
Have not complete my code yet, but it seem to work well and this way I feel I am able to code everything I need.. Will report back if any problems..
1) first use [unit] to_variable=x
2) modify ability with {VARIABLE x.abilities. ... }
3) unstore units on map with [unstore_unit] variable=x
Have not complete my code yet, but it seem to work well and this way I feel I am able to code everything I need.. Will report back if any problems..
Re: enclave's WML Macros questions Thread
You can set a unit's abilities directly in their [unit] tag, without going through variable manipulation. For example:
Code: Select all
[unit]
side=1
type=Elvish Fighter
x,y=1,1
[modifications]
[object]
[effect]
apply_to=new_ability
[abilities]
{ABILITY_HEALS}
[/abilities]
[/effect]
[/object]
[/modifications]
[/unit]
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
Re: enclave's WML Macros questions Thread
Thanks vultraz, but the reason I need to use alternative ways is because I need to add abilities from array of abilities..vultraz wrote:You can set a unit's abilities directly in their [unit] tag, without going through variable manipulation. For example:
Re: enclave's WML Macros questions Thread
I still think [insert_tag] should solve it, mostly because I deal with lot of stuff stored in arrays in WC II via insert_tag.enclave wrote:Thanks vultraz, but the reason I need to use alternative ways is because I need to add abilities from array of abilities..vultraz wrote:You can set a unit's abilities directly in their [unit] tag, without going through variable manipulation. For example:
If you have your abilities stored in my_awesome_abilities and want give the 3rd one, why you can not do something like this?
Code: Select all
[unit]
side=1
type=Elvish Fighter
x,y=1,1
[modifications]
[object]
[effect]
apply_to=new_ability
[insert_tag]
name=abilities
variable=my_awesome_abilities[2]
[/insert_tag]
[/effect]
[/object]
[/modifications]
[/unit]
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: enclave's WML Macros questions Thread
Tekelili You Are The Best!!! Thank you so much! Your solution worked best for me so far!!!tekelili wrote: If you have your abilities stored in my_awesome_abilities and want give the 3rd one, why you can not do something like this?
I started to work my way but I came to a new problem.. I could not find way to add array to an array... I had my ability stored in array like your example "my_awesome_abilities" but I failed to find way to insert it into array of previously stored unit (into array "my_awesome_unit.abilities"). If anybody knows the way, please let me know how it could be done?
Now with [insert_tag] my next problem is how to insert 2 abilities? because [unit] most likely will not let me use {FOREACH} or do you think it will let me? Or maybe you have some better way in mind? I will need to split somehow "1,2" (string with coma separated list of ability numbers) and then add all abilities in that list.. Splitting a string my least concern, but adding multiple abilities with [insert_tag]?
Thank you so much Tekelili again, I am 1 step forward now.. but still need help
PS. tried FOREACH, didn't work or maybe I need more sleep.. I don't know..
if anyone knows how to add array to an array please let me know..
PPS. would [lua] tag work inside [unit]?
Last edited by enclave on May 23rd, 2015, 8:48 pm, edited 1 time in total.
Re: enclave's WML Macros questions Thread
Do you think this would work?
PPS. This one worked.. and {FOREACH} now working also..
I think would make sense for developers to add new tag or macro for insertion of array into array.. instead of code above..
Thanks Tekelili again, your insert_tag came very handy anyway!
So for anyone who would like to insert ability or traits, or role, or special attacks or anything at all into your units, there is a way like this:
As for me, now I need to find way to split string "1,6,18,4" into 4 variables..
Spoiler:
Code: Select all
[set_variables]
name=NS_recruited_unit.abilities
mode=insert
[insert_tag]
name=value
variable=database.abilities[1]
[/insert_tag]
[/set_variables]
Thanks Tekelili again, your insert_tag came very handy anyway!
So for anyone who would like to insert ability or traits, or role, or special attacks or anything at all into your units, there is a way like this:
Spoiler:
Re: enclave's WML Macros questions Thread
I don't know for sure if this would work, but there is a [set_variables] mode=append key (see InternalActionsWML#.5Bset_variables.5D).
Again, I do not know if that would work, I'm just guessing. As for splitting a string into 4 variables, you could either use [set_variables] again:
Should result in array_of_split_keys[0].value being 1, array_of_split_keys[1].value being 6, etc. Or you could use lua (this is a copy of the split() function used in core wml tags:
Code: Select all
[set_variables]
name=my_array_1
mode=append
to_variable=my_array_2
[/set_variables]
Code: Select all
[set_variables]
name=array_of_split_keys
[split]
list="1,6,18,4"
key="value"
seperator=","
[/split]
[/set_variables]
Code: Select all
local function split(s)
return tostring(s):gmatch("[^%s,][^,]*")
end
local list = "1,6,18,4"
for i in split(list) do
-- this inserts the value into the variable name as well, for distinction. So it would be named "my_split_variable1", "my_split_variable6", etc
wesnoth.set_variable("my_split_variable" .. i, i)
end
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
Re: enclave's WML Macros questions Thread
insert_tag has a magical behavior: if you dont specify an index, then isnsert the whole arrayenclave wrote:Now with [insert_tag] my next problem is how to insert 2 abilities? because [unit] most likely will not let me use {FOREACH} or do you think it will let me? Or maybe you have some better way in mind? I will need to split somehow "1,2" (string with coma separated list of ability numbers) and then add all abilities in that list.. Splitting a string my least concern, but adding multiple abilities with [insert_tag]?
Code: Select all
## this code will write as many [abilities] tags as $my_awsome_abilities.length
[insert_tag]
name=abilities
variable=my_awsome_abilities
[/isert_tag]
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: enclave's WML Macros questions Thread
I tried just to confirm that unfortunately for me it didn't work, not with append, not with insert, not merge and quite sure I tried replace also.. none of them worked. Would be a nice/neat solution if worked. I was even expecting it to work somehow Maybe I did something wrong, I don't know.vultraz wrote:I don't know for sure if this would work, but there is a [set_variables] mode=append key (see InternalActionsWML#.5Bset_variables.5D).Again, I do not know if that would work, I'm just guessing.Code: Select all
[set_variables] name=my_array_1 mode=append to_variable=my_array_2 [/set_variables]
So the current best solution to anyone who wants to add array into array (insert array inside another array) would be something like this:
1) Better first create a macro in any of your working macros .cfg(s) like this:
#define ARRAY_TO_ARRAY ARRAY_1 TO_ARRAY_2
Code: Select all
[set_variables]
name={TO_ARRAY_2}
mode=insert
[insert_tag]
name=value
variable={ARRAY_1}
[/insert_tag]
[/set_variables]
#enddef
for example:
Code: Select all
{ARRAY_TO_ARRAY my_ability my_unit.abilities}
Thank you very much vultraz, this one I can confirm, it works flawlessly! You saved me a lot of time.vultraz wrote: As for splitting a string into 4 variables, you could either use [set_variables] again:Should result in array_of_split_keys[0].value being 1, array_of_split_keys[1].value being 6, etc.Code: Select all
[set_variables] name=array_of_split_keys [split] list="1,6,18,4" key="value" seperator="," [/split] [/set_variables]
Now I'm 99% done with my abilities code.
Thanks tekelili that would definitely work! So now anybody who read this thread will know how to add abilities from array of abilities in 2 ways.. depending on what they prefer, or even mix them. Thank you for all your time and help!tekelili wrote: insert_tag has a magical behavior: if you dont specify an index, then isnsert the whole arrayIf you want write several tags after use a FOREACH, do your loop before using [unit] tag, store whatever code you want write in a temporal variable, and insert that temporal variable into [unit] or whereever you want. As general advice, you can store any kind of code into variables, and you can write code from variables wherever varible substitution is supportedCode: Select all
## this code will write as many [abilities] tags as $my_awsome_abilities.length [insert_tag] name=abilities variable=my_awsome_abilities [/isert_tag]
New question #3
When I download replay of my mod, from replays.wesnoth.org/1.12/
If the replay was a reload it often has out of sync problem. And the first thing that I can see straight away is that there are no villages on map created by means of {MODIFY_TERRAIN {REPLACEMENT} $structures[$i].x $structures[$i].y} macro (http://www.wesnoth.org/macro-reference.xhtml). When players reload, they play perfectly fine.. villages there.. but replay of reload from server.. is problems. Any ideas? Thank you!
PS. just to remind of question #2
Does observer have a team? if so, then what is the team_name?
Re: enclave's WML Macros questions Thread
Question #4
How could I access array of unit_type?
I would need to use some parameters of some unit from list of all existing units of core.. for my descriptions of units..
is there such an array? Please WML version, not lua (if you know lua way, would be useful also for future reference), I'm not in a mood for advanced coding when there is no need to.. I still dont know what causing some OOS in my mod games.. its upsetting enough.
I basically need something like:
...
message="Orcish Assasin, HP: $wesnoth.unit_type.Orcish_Assasin.hitpoints, Moves: $wesnoth.unit_type.Orcish_Assasin.movement ..."
...
How to do it?
Question #5
in core unit_type Troll Whelp has something like #ifdef ENABLE_TROLL_SHAMAN [advance_to] value=Troll Shaman [/advance_to] #enddef
how do I enable troll whelp to advance to troll shaman? I'm less concerned about this one, but really need to know how to do #4..
Thank you everyone!
How could I access array of unit_type?
I would need to use some parameters of some unit from list of all existing units of core.. for my descriptions of units..
is there such an array? Please WML version, not lua (if you know lua way, would be useful also for future reference), I'm not in a mood for advanced coding when there is no need to.. I still dont know what causing some OOS in my mod games.. its upsetting enough.
I basically need something like:
...
message="Orcish Assasin, HP: $wesnoth.unit_type.Orcish_Assasin.hitpoints, Moves: $wesnoth.unit_type.Orcish_Assasin.movement ..."
...
How to do it?
Question #5
in core unit_type Troll Whelp has something like #ifdef ENABLE_TROLL_SHAMAN [advance_to] value=Troll Shaman [/advance_to] #enddef
how do I enable troll whelp to advance to troll shaman? I'm less concerned about this one, but really need to know how to do #4..
Thank you everyone!
Re: enclave's WML Macros questions Thread
There may not be such an array. Instead, "store_unit_type" tag (or "store_unit_type_ids") will satisfy your demand.
example:
You can add multiple types in single "store_unit_type" with comma separated list...
For ENABLE_TROLL_SHAMAN, see description about "extra_defines" parameter of campaign tag: http://wiki.wesnoth.org/CampaignWML#The ... ign.5D_tag
You will immediately understand.
example:
Code: Select all
[store_unit_type]
type = "Orcish Assassin"
variable = variable_name
[/store_unit_type]
[message]
message = _"Orcish Assassin, HP: $variable_name.hitpoints, Moves: $variable_name.movement ..."
[/message]
For ENABLE_TROLL_SHAMAN, see description about "extra_defines" parameter of campaign tag: http://wiki.wesnoth.org/CampaignWML#The ... ign.5D_tag
You will immediately understand.
Discord: @tamanegi
It is true that we cannot be free from bugs, but at least let our bugs not always the same...
A Group in a War: my first campaign, An Independence War: and the sequel
It is true that we cannot be free from bugs, but at least let our bugs not always the same...
A Group in a War: my first campaign, An Independence War: and the sequel