I am trying to reference selected dialog list items. I know you can reference a list item by its index within the list, however I want to know if I can reference the selected list item by its name. For example, if the list read something like:
Probe
Zealot
Stalker
If I select Zealot I can reference the selection by the 2nd item in the list. I would like to reference it by its string name of "Zealot". This would allow me to add list items in a different order dynamically but still reference the correct selection for the appropriate action.
I have not worked with dialog lists but I am going to guess, if there's no built in indexOf() type function, you are going to have to itterate through all the elements, keeping track of how many you've seen until you get to what you want...
aka
pick each element in the list, elementIndex = elementIndex + 1, if this is the element I want, return elementIndex
Just create a String Array that goes with the list item. so position 2 in the string array = position 2 in the list item.
you can then just use: ListValuesString[IntegerOfSelectedListItem] to get the string value.
Can you explain that a little more for me? Maybe a code snippet. It sounds like what I might need but I'm not sure how to implement that programmatically.
What I plan on having is a unit list. However you must unlock some of the units, so they don't all appear in the list at the same time. Furthermore, you can unlock units in different orders, so while one persons list may read:
Probe
Zealot
Stalker
another might read:
Probe
Stalker
Zealot
I need a way though to always be able to associate the selected list item with the correct unit.
when creating the list for a certain player do something like this as well:
Add "Zealot" to list (or whatever that action is XD)
Set UnitListArray[Picked Player][CurrentPosition] = "Zealot"
you can swap Picked Player out with whatever playernumber is needed.
ofcourse the value CurrentPosition is the same as the value of the selected unit (for example if Zealot is at position 2, the CurrentPosition value is 2)
I made the array 2dimensional because you can have different lists per player.
It's kind of possible, but complicated. For my quest log i used a lot of integer vars. For instance, Quest log[0].index would be 0, then Quest log[0].name would be 'Quest 1'. My quest name wasn't used to referance anything iirc, but i used the index a lot. I'll upload the pre-alpha version of it so you can have a look at it.
Also, helral, it's not possible to check a string or text against a variable. If you found out how to, please tell me :).
EDIT: That log should be what you need if you can understand it. Basically it uses 'Real Index' variables so that it saves the actual position in the list so you can filter for all, but also the current list position so you can referance things when it's clicked
I am trying to reference selected dialog list items. I know you can reference a list item by its index within the list, however I want to know if I can reference the selected list item by its name. For example, if the list read something like:
Probe Zealot Stalker
If I select Zealot I can reference the selection by the 2nd item in the list. I would like to reference it by its string name of "Zealot". This would allow me to add list items in a different order dynamically but still reference the correct selection for the appropriate action.
I have not worked with dialog lists but I am going to guess, if there's no built in indexOf() type function, you are going to have to itterate through all the elements, keeping track of how many you've seen until you get to what you want...
aka pick each element in the list, elementIndex = elementIndex + 1, if this is the element I want, return elementIndex
@Suterusu1337: Go
Just create a String Array that goes with the list item. so position 2 in the string array = position 2 in the list item.
you can then just use: ListValuesString[IntegerOfSelectedListItem] to get the string value.
@Helral: Go
Can you explain that a little more for me? Maybe a code snippet. It sounds like what I might need but I'm not sure how to implement that programmatically.
What I plan on having is a unit list. However you must unlock some of the units, so they don't all appear in the list at the same time. Furthermore, you can unlock units in different orders, so while one persons list may read:
Probe Zealot Stalker
another might read:
Probe Stalker Zealot
I need a way though to always be able to associate the selected list item with the correct unit.
@Suterusu1337: Go
when creating the list for a certain player do something like this as well:
Add "Zealot" to list (or whatever that action is XD)
Set UnitListArray[Picked Player][CurrentPosition] = "Zealot"
you can swap Picked Player out with whatever playernumber is needed.
ofcourse the value CurrentPosition is the same as the value of the selected unit (for example if Zealot is at position 2, the CurrentPosition value is 2)
I made the array 2dimensional because you can have different lists per player.
I don't mean to sound stupid, I'm just not following 100% on what you are saying. Any chance you could provide a code sample or example?
It's kind of possible, but complicated. For my quest log i used a lot of integer vars. For instance, Quest log[0].index would be 0, then Quest log[0].name would be 'Quest 1'. My quest name wasn't used to referance anything iirc, but i used the index a lot. I'll upload the pre-alpha version of it so you can have a look at it.
Also, helral, it's not possible to check a string or text against a variable. If you found out how to, please tell me :).
EDIT: That log should be what you need if you can understand it. Basically it uses 'Real Index' variables so that it saves the actual position in the list so you can filter for all, but also the current list position so you can referance things when it's clicked
@wOlfLisK: Go
I might have misunderstood what he wanted to do....
possibly :)