LISTs will be the death of me! (SOLVED)

CheeseMyBaby
20 Mar 2018, 09:18Hey guys,
I'm working on my first game. It's an adventure type (like the very old Kings quest, Larry etc etc).
I have zero coding experience (except for html) which is why quest is such a great tool to start with and I'm loving it!
Ok, enough with the introduction and pleasantries.
Here's my problem.
In my game there's a computer (object) that will run on commands input by the player (stored in a switch AND a list).
When using the computer all input must start with the string "cmd" so "cmd help" will give the player instructions on how to run the computer (and this will only work when actually using the "computer")
I want the player to be able to list all available computer commands stored in the list by inputting:
cmd commands
... but when I try it nothing happens.
At the moment the cmd commands in the switch will do this:
DisplayList (cc, true)
... which isn't doing anything.
In the game scripts I have this:
cc = NewList()
list add (cc, "E-mail")
list add (cc, "Screensaver")
list add (cc, "Applications")
list add (cc, "Games")
I'm having a heartattack over this!
Have I completely misunderstood the purpose of lists (highly probable)?
Am I "just" missing something (equally probable)?
Or do I just suck (please don't answer that)?
All help appreciated!
//Cheese

CheeseMyBaby
20 Mar 2018, 09:27Oh, and I feel the need to say that I've read everything I can find on lists.
I just don't understand it.
I need someone to explain in words, as opposed to syntax, how I'm failing this! =)
hegemonkhan
20 Mar 2018, 10:18I think a small change will let it work for you... assuming you got everything other wise set up right...
your use of 'cc' is a 'Variable' VARIABLE, which means that it is destroyed (ceases to exist) as soon as its scripting location's script(s) finishes, and thus it can NOT be used elsewhere within your game, such as within your 'WHATEVER' Verb for your 'computer' Object.
instead, try changing it into an 'Attribute' VARIABLE, which is done by having it be some Object's created/added Attribute. Since an Attribute is contained within an Object, it will always exist (so long as its Object, exists / still exists, of course), and thus you can use it anywhere within your game.
so, just change this stuff of yours:
At the moment the cmd commands in the switch will do this:
DisplayList (cc, true)
... which isn't doing anything.
In the game scripts I have this:
cc = NewList()
list add (cc, "E-mail")
list add (cc, "Screensaver")
list add (cc, "Applications")
list add (cc, "Games")
to this instead:
DisplayList (game.cc, true)
// ----------------------
game.cc = NewList ()
list add (game.cc, "E-mail")
list add (game.cc, "Screensaver")
list add (game.cc, "Applications")
list add (game.cc, "Games")
simply changing this scripting, causes your (now) 'cc' String List Attribute to be created/added-to (contained within) the 'game' Game Settings Object
let me know if you need help and/or if it's still not working for you
I try to explain Attributes and the 'if' Script usage, using words, code, and etc, in this "guide" of mine:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
I try I to explain List and Dictionary usage, using words, code, and etc, in this "guide" of mine:
http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk
let me know if you need any help with anything and/or don't understand something

Forgewright
20 Mar 2018, 14:07Read this thread earlier right after it was made. I thought, "Isn't that NewList just temporary. He should make it an attribute."
Holy Questicles Batman, I was right. Small potatoes to most here but thinking you know and knowing can be quite far apart. And taking a jump into answering a post has proven embarrassing/humiliating.
Yep that gives you an idea as to where I am with coding. Do it everyday, most of the day and still unsure.
Nice explanation @Hegemonkhan. If I understand it so should CheeseMyBaby

CheeseMyBaby
20 Mar 2018, 14:58@hegemonkhan
So one word and a dot was all it took to almost end me.
Your solution worked perfectally well (and not only that... your explaination actually made me understand WHY it wasn't working before)!
I'm very grateful, your help is highly appreciated!
Thanks a million!
//Cheese