totally random

justaquestion
22 Sept 2016, 15:13

So question:
Let's say I've got more representations for an object or character. Far I figured I can use the if script and then possibly a flag to prevent spamming the same stuff by skipping the last one, but... Is there a way to make their appearance random, from a pool like a folder?


Jay Nabonne
22 Sept 2016, 16:11

You could throw them all in a list and then remove the ones you use from the list as you use them, so they don't get used again.

Assuming I understand your question.


hegemonkhan
22 Sept 2016, 19:44

if you could describe a bit more what you want to do or have happen, as right now, we're not too clear on exactly what you want, so we can't really respond as it's still a bit too ambigious for us, we'd be taking guesses at what you want.


if you want a bunch of choices, and after each choice, to remove it, resulting in fewer choices for a next time, that involves using lists (as we can add/remove items from a list).

if you just want a set of random (simple) responses, the simplest method would be using the text processor commands

if you want to check for whether something matches up with an Object's various 'alt' (alternative names) String List Attribute, you'd do that via the 'if' Script and the 'alt' String List Attribute.

if you're just asking about in general how to do randomization, there's 4 built-in randomization Functions: GetRandomInt, GetRandomDouble, DiceRoll, and/or RandomChance. Which you would then use to achieve (or do with) whatever you want to achieve (or do with) with the randomization.

and there's many more things too... we need you to describe as to what you're trying to tell us, as there's too many different things that you could be trying to tell us, as we can't quite narrow down what it is you're trying to tell us.

(I know it's hard to describe something that you don't understand and thus don't know how to describe... I've been in your shoes many times in the past, trying to do the same thing, and the other people have no clue at what I'm trying to explain/ask of them, and I have no clue on how to ask/explain my question better either, lol)

(actually... I still have this problem with new things I'm trying to understand, and thus I don't know how or what to say or ask about, so people are confused by what I'm trying to ask about ... laughs)


justaquestion
23 Sept 2016, 11:54

Thanks for the replies and the listing/removing idea guys!

Now to somewhat specify it:
Got a folder where those pictures are contained in, say for character "X", and when that character comes up in a dialogue or action I want to show a portrayal from that map's folder. Could the program pick a picture randomly from there? Just for the sake that I wouldn't have to put in every single file manually, LoL


Jay Nabonne
23 Sept 2016, 13:23

You will need to have the file names in your code. There is no way to query the file system from within a running Quest game.


hegemonkhan
24 Sept 2016, 04:22

if I understand with images (which I don't, lol) ... what Jay is saying is roughly that (I think) ...

you'll need the exact file names (I presume this includes the ext) in a String List Attribute, which you can select one of them randomly (using for example: GetRandomInt), which will be put/used within the Function for getting/displaying an image file

for example, something somewhat like this:

<object name="global_data_object">
  <attr name="picture_stringlist_attribute" type="simplestringlist">pic1; pic2; pic3</attr>
</object>

// the ext is added to it in the Function below, instead of including it in the String List Attribute above

<function name="display_random_picture_function">
  randomly_selected_picture_name_string_variable = StringListItem (global_data_object.picture_stringlist_attribute, GetRandomInt (0, ListCount (global_data_object.picture_stringlist_attribute) - 1)) + ".png"
  msg (GetFileURL (randomly_selected_picture_name_string_variable))
</function>

but, I don't understand pictures/images/JS-usage that well, so you may need to look here ( http://docs.textadventures.co.uk/quest/guides/modifying_the_ui__advanced_.html ) or like places about using pictures/images in quest, or let Jay clarify on what to actually do.