Random Dictonary Script
ender
04 Aug 2011, 17:54First let me say, I'm loving Quest 5 ... so far it seems to address all of the things I didn't like in Quest 4 ... with some new features to boot. Great job.
I've been doing pretty good working with it despite the lack of full documentation ... but I have run into a problem that I can solve by making my own function, but before I go down that route I wanted to see if there is already something in place ... or at least an easier way to do it.
What I want to do is run a random script from a script dictionary. I can think of a variety of uses for this ... anything from random spell effects to random encounters to random shop inventory.
So is this functionality already in place and I just can't find it? or is there an easy way to do this?
Thanks in advance.
I've been doing pretty good working with it despite the lack of full documentation ... but I have run into a problem that I can solve by making my own function, but before I go down that route I wanted to see if there is already something in place ... or at least an easier way to do it.
What I want to do is run a random script from a script dictionary. I can think of a variety of uses for this ... anything from random spell effects to random encounters to random shop inventory.
So is this functionality already in place and I just can't find it? or is there an easy way to do this?
Thanks in advance.
Alex
04 Aug 2011, 18:11There's nothing built-in that will do this - might be a nice addition for a library though (even the Core library)
The Pixie
04 Aug 2011, 19:30How do you use dictionaries and lists? I can see function calls for adding to and removing from them, but nothing obvious about retrieving values and checking if a vale is there.
ender
05 Aug 2011, 00:35I'm sure Alex will correct me if I'm wrong ... but right now I don't think there is a lot built in to do much with dictionaries ... although if you look at the corecommands.aslx ... there are some uses of it in the DoAskTell function and a few others ... as dictionaries are what power the ask/tell object functions ...
I don't think I'm up for creating a whole library ... but I'll see what I can do about creating a decent random function for what I'm working on and I'll post it here ... If someone wants to do something else with it... like include it in a library ... thats fine.
I don't think I'm up for creating a whole library ... but I'll see what I can do about creating a decent random function for what I'm working on and I'll post it here ... If someone wants to do something else with it... like include it in a library ... thats fine.
The Pixie
05 Aug 2011, 07:01Thanks.
I have since found the answer in the Wiki documentation:
http://quest5.net/wiki/DictionaryItem
Now I have found the documentation, to answer the OP, this might work for a list, my_list, populatedwith scripts:
ScriptListItem(my_list, GetRandomInt(0, ListCount(my_list)))
Hmm, I can see all sorts of uses for random items from lists.
I have since found the answer in the Wiki documentation:
http://quest5.net/wiki/DictionaryItem
Now I have found the documentation, to answer the OP, this might work for a list, my_list, populatedwith scripts:
ScriptListItem(my_list, GetRandomInt(0, ListCount(my_list)))
Hmm, I can see all sorts of uses for random items from lists.
Alex
05 Aug 2011, 08:56That would work - if there was such a thing as a script list, which unfortunately there isn't.
One way you could do it though would be to use a script dictionary and a string list. When adding to the script dictionary, add the key to the string list as well. Or alternatively, populate the string list at the required time using something like this:
One way you could do it though would be to use a script dictionary and a string list. When adding to the script dictionary, add the key to the string list as well. Or alternatively, populate the string list at the required time using something like this:
keys = NewStringList()
foreach (item, my_string_dictionary) {
list add (keys, item)
}
ender
05 Aug 2011, 17:00Excellent. I'll tinker with it and see what I can get.