I want to create a list box and a button. The list box will have a list will all units and the button will spawn the selection in the list box, but I can't manage to find a way to link the units in the listbox and spawn them. I also want to have a field with spawned unit count and another for the owner, how do I do that?
there is a function to return the selected index of a listbox for player. you now have two choices, either you create a variable array of type unit type. for example: var units[1] = Marine; add list item "Marine" to dialog item.
on button use you create unit of type units[selected index of dialog item]
other way would be to use user data tables and match index with index of dialog item.
the counter is a variable of type integer, also an array for each player.
Thanks, and how do I create a search filter for the list? For example I want to be able to type "ab" and see all the units containing "ab" in their names and IDs if possible.
well, you also have to save the names as string in an array.
so filtering is basically delete all items from the list and repopulate it with items which contain the entered string. but now you have to rematch the index of dialog item to the right index of unit type. therefore you need another array of ints which save the index of the original entry.
example:
lets say you have 10 units, your filter selects unit 3 and 8. your int array MatchInt[1] = 3, MatchInt[2] = 8;
Less memory-efficient, but easier, would be to create a copy of the original array that contains only matching units. Then you can use the same code to populate the list box and respond to selection. Just make the original array two-dimensional and use index 0 for the main list and index 1 for the filtered list (as well as two separate variables to track the number of elements in each list).
I want to create a list box and a button. The list box will have a list will all units and the button will spawn the selection in the list box, but I can't manage to find a way to link the units in the listbox and spawn them. I also want to have a field with spawned unit count and another for the owner, how do I do that?
there is a function to return the selected index of a listbox for player. you now have two choices, either you create a variable array of type unit type. for example: var units[1] = Marine; add list item "Marine" to dialog item.
on button use you create unit of type units[selected index of dialog item]
other way would be to use user data tables and match index with index of dialog item.
the counter is a variable of type integer, also an array for each player.
Thanks, and how do I create a search filter for the list? For example I want to be able to type "ab" and see all the units containing "ab" in their names and IDs if possible.
well, you also have to save the names as string in an array.
so filtering is basically delete all items from the list and repopulate it with items which contain the entered string. but now you have to rematch the index of dialog item to the right index of unit type. therefore you need another array of ints which save the index of the original entry.
example:
lets say you have 10 units, your filter selects unit 3 and 8. your int array MatchInt[1] = 3, MatchInt[2] = 8;
Less memory-efficient, but easier, would be to create a copy of the original array that contains only matching units. Then you can use the same code to populate the list box and respond to selection. Just make the original array two-dimensional and use index 0 for the main list and index 1 for the filtered list (as well as two separate variables to track the number of elements in each list).
Sounds a bit complex... I tried but got lost. Can somebody write the trigger?
i have to go now, here is something to work with. might update later
ok, fully working version
It works greatly, but how do you set it to work with all units on the unit catalog?
EDIT: Nevermind, fixed!