problem with pickable items

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.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: problem with pickable items

Post by beetlenaut »

hermestrismi wrote: March 1st, 2023, 10:59 pm Do you think filtering by comparing key into variables (like a database program ) is possible?
I'm not sure I understand this, but find_in is part of many filters. It searches in arrays of variables.

Otherwise, you could use string searching functions in WFL or Lua.
hermestrismi wrote: March 1st, 2023, 10:54 pm I have to learn lua coding but I don't know where I had a start
Lua is not made by BfW. We are just using it because it is an easy language to add to your own project. You can find many general tutorials and examples of how to use it on line. Using it in your add-on is explained at a link I gave you before. The advantage is that if there isn't a WML tag for what you want to do, you may still be able to program it with Lua. In fact, many WML tags are written in Lua already. The World Conquest add-on is mostly written in Lua, so that would be a good place to look for examples.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: problem with pickable items

Post by hermestrismi »

beetlenaut wrote: March 2nd, 2023, 5:53 am
hermestrismi wrote: March 1st, 2023, 10:59 pm Do you think filtering by comparing key into variables (like a database program ) is possible?
I'm not sure I understand this, but find_in is part of many filters. It searches in arrays of variables.

Otherwise, you could use string searching functions in WFL or Lua.
hermestrismi wrote: March 1st, 2023, 10:54 pm I have to learn lua coding but I don't know where I had a start
Lua is not made by BfW. We are just using it because it is an easy language to add to your own project. You can find many general tutorials and examples of how to use it on line. Using it in your add-on is explained at a link I gave you before. The advantage is that if there isn't a WML tag for what you want to do, you may still be able to program it with Lua. In fact, many WML tags are written in Lua already. The World Conquest add-on is mostly written in Lua, so that would be a good place to look for examples.
the result
first after the pickup event

Code: Select all

	[set_variables]
										name=unit_to_list_2
										mode=append
										[value]
											id=$unit_to_list_1.id|
											name=$unit_to_list_1.name|
											object=$item_list[$this_item.index].name
											sort=$item_list[$this_item.index].sort
											image=$item_list[$this_item.index].image
											unit_image=$unit_to_list_1.image|
											type=$unit_to_list_1.type|
										[/value]
									[/set_variables]
									{CLEAR_VARIABLE unit_to_list_1}
									[set_variables]
										name=add_message
										mode=append
										[value]
											[show_if]
												[have_unit]
													id=$unit_to_list_2.id|
												[/have_unit]
											[/show_if]
												image="$unit_to_list_2.unit_image|"
												label=_"name=$unit_to_list_2.name|
												id=$unit_to_list_2.id|
												name=$unit_to_list_2.name|
												object=$unit_to_list_2.object
												sort=$unit_to_list_2.sort
												image=$unit_to_list_2.image
												type=$unit_to_list_2.type|"
											[command]
												[if]
												[have_unit]
													id=$unit_to_list_2.id|
													[not]
														x,y=recall,recall
													[/not]
												[/have_unit]
												[then]
													[scroll_to_unit]
														[filter]
															id=$unit_to_list_2.id|
														[/filter]
													[/scroll_to_unit]
												[/then]
												[/if]
											[/command]
										[/value]
								[/set_variables]

								[set_variable]
									name=item_list_begin
									value=yes
								[/set_variable]

									{CLEAR_VARIABLE unit_to_list_2}
then, the prestart

Code: Select all

[set_menu_item]
			id=configure_items
			description=_ "Geared units"
			[command]
				[message]
					speaker=narrator
					image=none
					message="list of geared units"
					[show_if]
						[variable]
							name=item_list_begin
							equals=yes
						[/variable]
					[/show_if]
					[insert_tag]
						name=option
						variable=add_message
					[/insert_tag]
					[option]
						label=_ "Back"
						[command]
						[/command]
					[/option]
				[/message]
			[/command]
		[/set_menu_item]
image
Attachments
Capture.PNG
Capgture.PNG
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: problem with pickable items

Post by hermestrismi »

I forget to delete the filter for [scroll_to_unit] loool but everything else is working. the [insert_tag] is really great
Post Reply