How to do these things in the UI and not in Code View.

Hi,

I'm working on my code refactor, to make my game easier to maintain and reduce a lot of the code redundancy. I've found a few things that could greatly assist me in doing this code refactor, but... I can't figure out how to do them in the UI. All the documentation on how to do lists, dictionaries, and menus, requires you to do it in Code View, despite there being quite a few ways of modifying existing lists, or dictionaries in the UI.

So, how would I go about creating a list OR a dictionary, in the UI? Is a list or dictionary a separate entity or does it have to be attached to an object, much like most variable declarations in Quest?


K.V.

image


image


image


Using foreach

image


image


image


image


Adding to lists manually:

image


image


image


Using Split*

image


image


image


image


Dictionaries are up next...


K.V.

Is a list or dictionary a separate entity or does it have to be attached to an object, much like most variable declarations in Quest?

If you don't set it as an attribute on something, it won't be global.

You can put it on the game, but the game is an object, too...


If you used game.my_list as your list or dictionary, it would be saved throughout the game, unless you change it.

If you just used my_list, you couldn't access that list anymore once the script you created it in stopped running (which would be pretty much immediately).


If you don't like using game, player, or any other objects due to clutter, just create an object called list_object or something, and use it.


K.V.

Just for fun, before we do dictionaries, let's do this real fast:


image


Click on Code View

image

image---


Then, just click OK, and it's all loaded in the UI

image


This accomplishes the same exact thing as the first method in this post:

http://textadventures.co.uk/forum/quest/topic/j78jsi4te0k7fhugwc7-tq/how-to-do-these-things-in-the-ui-and-not-in-code-view#9320d760-b9d5-432a-980d-88c94d5b1d4c, but with much less work (and I didn't actually USE the list the fist time like I did in this example).


Thanks! REALLY appreciate it!

So, this Set Variable thing, is basically variable declaration in something like C++ then.


K.V.

I think so, but I don't really know C++ (unless I learned some from Quest and didn't notice, ha-ha), but it's the same thing as putting this in Code View, which just creates a new object list in this case:

game.myObjectList = NewObjectList()

...if that helps.


Or, if I'm learning JavaScript correctly:

var game.myObjectList = [];

(Correct me if I'm wrong on that one, anyone!)


...but you can use it for anything like that, except for a script.

x = GetDisplayName(crate)

If you had a crate in the game, x would equal a crate.

(That wouldn't be a global variable, though.)

crate.displayverbs = NewStringList()

That would clear the list of verbs on the crate's menu.

...unless you created verbs, then you'd need to run this in the games' start script:

crate.generatedverbslist = NewStringList()

NOTE: You can also turn the generated verbs list off in the UI.


Then, to set the crate's verbs back up:

crate.displayverbs = Split("Look at;Take;Push;Pull;Move;Open:Close", ";")

image


the 'set variable VARIABLE = VALUE_OR_EXPRESSION' Script is the:

GUI/Editor: run as script -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script

in-code: VARIABLE = VALUE_OR_EXPRESSION

yes, this is how you create, or modify-its-value-of, a VARIABLE (Variable or Attribute) in quest's GUI/Editor


there's also the 'set' Function too, as well (not sure where it can be found within the GUI/Editor though):

http://docs.textadventures.co.uk/quest/scripts/set.html


as for List and Dictionary VARIABLES:

you can do them a few ways (in code, as I'm lazy --- hopefully you can figure out how to do in the GUI/Editor)

game.my_list_attribute = split ("ITEM_1;ITEM_2", ";")

// or:

game.my_stringlist_attribute = NewStringList ()
list add (game.my_stringlist_attribute, "ITEM_1")
list add (game.my_stringlist_attribute, "ITEM_2")

// and for objectlists (you have to do it this way in the GUI/Editor):

game.my_objectlist_attribute = NewObjectList ()
list add (game.my_objectlist_attribute, NAME_OF_OBJECT_1)
list add (game.my_objectlist_attribute, NAME_OF_OBJECT_2)

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums