Heindals WML Questions
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: Heindals WML Questions
I know that I can't just replace the for each with a while loop. I have to rethink the whole process and as I said make a workaround, which so far worked for a single object. Still having problems with manipulating a comma seperated list. I will post the solution when I'm done.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Heindals WML Questions
Hi !
I have recently designed something rather close to your need (AFAICS). The main macro builds a message tag listing the modification objects of an unit which can be used in a set_menu_item. Maybe this can help you. The code is here:
It's not really important in this example, but the 'objects' used here are all stored in a array built in this way:
Where OBJs have this definition:
HTH,
I have recently designed something rather close to your need (AFAICS). The main macro builds a message tag listing the modification objects of an unit which can be used in a set_menu_item. Maybe this can help you. The code is here:
Code: Select all
# This is the 'command' tag of each option.
#define LSB_CLEAR_UNITOBJECT
{LSB_DROP_OBJECT $unit.modifications.object[$nc].uid $x1 $y1}
{CLEAR_VARIABLE unit.modifications.object[$nc]}
#enddef
# list 'unit' objects
#define LSB_LIST_UNIT_THINGS
{VARIABLE t_done non}
[while]
[variable]
name=t_done
equals=non
[/variable]
[do]
{CLEAR_VARIABLE t_menu}
{VARIABLE t_menu.message "Drop items:"}
{VARIABLE t_menu.speaker narrator}
{FOREACH unit.modifications.object nc}
[set_variables]
name=t_action
mode=replace
[value]
{LSB_CLEAR_UNITOBJECT}
[/value]
[/set_variables]
[set_variables]
name=t_menu.option
mode=append
[value]
message=$unit.modifications.object[$nc].name
[insert_tag]
name=command
variable=t_action
[/insert_tag]
[/value]
[/set_variables]
{NEXT nc}
{VARIABLE nc $t_menu.option.length}
[set_variables]
name=t_menu.option
mode=append
[value]
message="Exit."
[/value]
[/set_variables]
[set_variables]
name=t_stop
[value]
name=t_done
value=oui
[/value]
[/set_variables]
[set_variables]
name=t_menu.option[$nc].command
[value]
[insert_tag]
name=set_variable
variable=t_stop
[/insert_tag]
[/value]
[/set_variables]
[insert_tag]
name=message
variable=t_menu
[/insert_tag]
[/do]
[/while]
{CLEAR_VARIABLE t_menu,t_stop,nc,t_action}
#enddef
# --- can be used in a menu:
[set_menu_item]
id=LSB_drop
description="Drop items."
[show_if]
[variable]
name=unit.side
equals=1
[/variable]
[/show_if]
[command]
{LSB_LIST_UNIT_THINGS}
[/command]
[/set_menu_item]
Code: Select all
[set_variables]
name=Objets
mode=replace
[value]
{LSB_DEXTERITY_OBJ}
[/value]
# ... and much more
[/set_variables]
Code: Select all
#define LSB_DEXTERITY_EFF
[effect]
apply_to=attack
remove_specials=nomiss
increase_damage=25%
[set_specials]
mode=append
{LSB_NOMISS 90}
[/set_specials]
[/effect]
#enddef
#define LSB_DEXTERITY_OBJ
name= _ "Dexterity circlet"
image=items/circlet.png
description= _ "Add dexterity to all your weapons."
category=rings
level=2
{LSB_DEXTERITY_EFF}
#enddef
HowTos: WML filtering, WML variables
Re: Heindals WML Questions
Thanks for this, I will check this out when I have time - which should be sometimes next week .
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
Hi again,
so far I've been creating a very promising random map generator using puzzle tiles of terrain and placing them on the map.
I'm using the following code:
The code however works fine, even so I've got to make it leaner. The dungeon is placed.
However I receive following bug report:
data/lua/wml/items.lua:8: bad argument #1 add_tile_overlay (number expected got string)
This somehow messes with the placement of images and items. Its seems impossible to place images on random locations within such a random map, even so the events will be fired. Any ideas and experience with that matter? What causes the problem?
Edit: Blast it, even so I tried hours before to solve it I now found a solution and found the reason for the bug.
I needed to place the images within the start event tag, however I still can't place images outside of the start event :/.
so far I've been creating a very promising random map generator using puzzle tiles of terrain and placing them on the map.
I'm using the following code:
Code: Select all
[terrain_mask]
x,y={STARTX},{STARTY}
mask="border_size=1
usage=map
Qxe , Qxe , Qxe , Uue , Qxe , Qxe , Qxe
Uue , Qxe , Qxe , Uue , Qxe , Qxe , Qxe
Uue , Uue , Uue , Uue , Uue , Qxe , Uue
Uue , Qxe , Qxe , Uue , Qxe , Uue , Uue
Qxe , Qxe , Qxe , Uue , Qxe , Qxe , Qxe
Qxe , Qxe , Qxe , Uue , Qxe , Qxe , Qxe"
[/terrain_mask]
However I receive following bug report:
data/lua/wml/items.lua:8: bad argument #1 add_tile_overlay (number expected got string)
This somehow messes with the placement of images and items. Its seems impossible to place images on random locations within such a random map, even so the events will be fired. Any ideas and experience with that matter? What causes the problem?
Edit: Blast it, even so I tried hours before to solve it I now found a solution and found the reason for the bug.
I needed to place the images within the start event tag, however I still can't place images outside of the start event :/.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
It'se me again, Mario err Heindalo. Currently I'm cleaning out the bugs in my 1.14 campaigns. Five Fates is almost done, even so there where some troublesome news about my random dungeon generator, but I found a workaround. But I keep getting this message and can't get rid of it. Any ideas where to look?
"lua/wml/object:lua:23 bad argument #1 to 'get_unit' (expected string or location)
stack traceback: ..."
"lua/wml/object:lua:23 bad argument #1 to 'get_unit' (expected string or location)
stack traceback: ..."
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
I looked "lua/wml/object:lua:23 which leads to line 9 which suggests you called [object] without event and filter.
Re: Heindals WML Questions
Thanks Ravana, now I could solve the problem. So the error messages is referencing to a file, where I could look up the reason.
I added a statue of Ravana the Keeper to the add-on. Will have to test the add-on however before its finished.
I added a statue of Ravana the Keeper to the add-on. Will have to test the add-on however before its finished.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
I´m currently trying to upgrade one of my trap macros. It´s called "Areatrap" trap that generates area damage.
While the old version worked fine, I wanted to change the behavior.
So far the trap is triggered by only one coordinate, harming and affecting all units in an area. But I want to change that, so that it is triggered by a coordinate and it´s adjacent tiles. So far I´ve tested "filter_adjacent_location" as well as "radius" and "filter_radius". I failed. While the animation can be done with radius and works fine with it, it seems impossible for me to manipulate a moveto event to filter the adjacent locations as well.
Is it possible to use a moveto event with one coordinate and trigger it with the adjacent tiles as well?
The only workaround I could think of, is to define the range of coordinates in the macro itself.
While the old version worked fine, I wanted to change the behavior.
So far the trap is triggered by only one coordinate, harming and affecting all units in an area. But I want to change that, so that it is triggered by a coordinate and it´s adjacent tiles. So far I´ve tested "filter_adjacent_location" as well as "radius" and "filter_radius". I failed. While the animation can be done with radius and works fine with it, it seems impossible for me to manipulate a moveto event to filter the adjacent locations as well.
Is it possible to use a moveto event with one coordinate and trigger it with the adjacent tiles as well?
The only workaround I could think of, is to define the range of coordinates in the macro itself.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Heindals WML Questions
That sounds like an enter_hex event?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Heindals WML Questions
Enter_hex is a good way for a trap, but I still need to define an area, that triggers this event and harming all units on this spot and the adjacent spots. So a trap could be used to harm enemy units or to use discovered traps for your advantage. On the other hand, as "enter" hex stops the movement it would never allow me to reach the "center" of a trap, which causes a different damage and different effects.
So moveto seems like the best choice.
So moveto seems like the best choice.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Heindals WML Questions
This should work. x and y are properties of the unit and the terrain, that's why one can use them in [filter] for x,y. Radius is only in [filter_location] possible.
[filter_radius] can be used to … filter the radius. Then only specific hexes are included, i.e. one can use it to exclude chasms or cave walls.
[filter_radius] can be used to … filter the radius. Then only specific hexes are included, i.e. one can use it to exclude chasms or cave walls.
Code: Select all
[event]
name=moveto
first_time_only=no
[filter]
[filter_location]
x=19
y=43
radius=1
[/filter_location
[/filter]
…
Try out the dark board theme.
Re: Heindals WML Questions
@Shiki, thank you, this works fine .
I`ve tried to use radius or filter_radius without filter location, which did not do the trick.
I`ve tried to use radius or filter_radius without filter location, which did not do the trick.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer