Copying String Lists

afrotoast
Hi guys, I've gotten very far just by searching the forums but I have an ease-of-use question to ask.

In my arguably primitive game I set up a system where you can hold on to an item and wear it, but over time (through turn scripts) the item evolves. I did this by making the turn script change out the actual object for a different one that behaves the same way. i.e. (object_level1, object_level2).

So... because the item is a core part of the game, I needed to make many different alt names for it so that the player can refer to it really easily without breaking immersion. But because I have quite a few levels it can be in, I need to use the same alt name list for each object. I've been keying it in manually using the Quest UI, but its slow and tedious - is there actually a way for me to force all of them to refer to one master string list? or a way for me to copy all the entries across each version of the object?

Finally, if a mod reads this, I accidentally my name. ): Idk why I thought the username field was asking for my email address. Can this be fixed?

Alex
I updated your username for you.

The Pixie
The best way would be to do it on the fly, when the object upgrades.
object_level2.alt = object_level1.alt

XanMag
My code-nooby fix would simply be to create however many items you need equal to the number of times it updates. When an event triggers an update (or timer or turn script), simply swap out the old item and replace it with a new item from a "storage room". That way you don't need to update any alt names at all. Just my thought, but if you understand Pixie's post, do it that way - I'm sure it is simpler and more logical. Who knows... maybe that is what you did and I don't understand you either? :lol:

Good luck!

XanMag

afrotoast
@Alex - Thanks! I noticed when I couldn't get in using my email address anymore, haha.

@The Pixie: Thank you! I'll give it a shot, but I'm still really new to all this. Where should I go to put in actual code? So far I've only been using the Quest GUI.

@XanMag: Yeah the system right now uses a turnscript to decide when the object should "level up", then swaps it out for the other one. The problem comes because this swap is invisible to the player, and they have to be able to use the same alternate names to refer to it.

It's just an ease of use issue for me: I need to manually "add" entries to the string list one by one for each object through the Quest UI, so I was hoping there was a way I could either:

[list]A: Copy-paste the string list between each object.
B: Have each object refer to one singular master string list.[/list:u]

I haven't been able to find anything on the forums /: either I'm not searching the right terms or its not been talked about before.

The Pixie
You need to put it in your turn script. It is hard to describe for the GUI, so I will try to explain for the code view. Go to the turn scipt. Above the scripts you added there will be a row of icons, with the word "Script" at the left. The seventh icon will take you to the code view for this script only. Click it.

Every line of GUI script corresponds exactly to a line of code, so if you look through the code, you should see a line like this:
MoveObject (object_level2, player)

This is where the level 2 object is moved to the player. That is when you need to copy the list across.
MoveObject (object_level2, player)
object_level2.alt = object_level1.alt

You will also need to do that for all the other level ups, so:
MoveObject (object_level3, player)
object_level3.alt = object_level2.alt

... and so on.

Now you only have to create the alt list on the first object, and Quest will sort the rest out.

If you are still struggling, copy all the code for your turnscript into your post, and we will look at it.

HegemonKhan
here's Pixie's detailed guides on coding in quest (if you're interested in learning):

viewtopic.php?f=18&t=5422
viewtopic.php?f=18&t=4953

and here's some of mine, which *may* (I'm not as clear-concise as Pixie and others, lol) help too:

viewtopic.php?f=18&t=5559 (game making basics: Attributes and the 'if' Script)

afrotoast
@The Pixie:

Awesome! It successfully translated the code as "Set Variable (object_level2.alt) = expression (objectlevel1.alt)" in the GUI as well, I will have to test it to make sure it works. Thank you!

I noticed that my code for swapping the objects out was:

RemoveObject (object_level1)
AddToInventory (object_level2)


Whereas you suggested MoveObject instead. Is there any reason to use one over the other, or is it just many ways to get the same thing done?

@HK:

It's HK! One of your replies to someone else helped me figure out a weird bug in my project! Come to think of it, I recognize a lot of usernames here hahaha I'm going to guess its a pretty small but active community =p

Thanks for the link! I'll have a read through it soon!

The Pixie
afrotoast wrote:Awesome! It successfully translated the code as "Set Variable (object_level2.alt) = expression (objectlevel1.alt)" in the GUI as well, I will have to test it to make sure it works. Thank you!

Great. You can use that as a guide to doing it with the GUI rather than code for the next time if you prefer that way.

I noticed that my code for swapping the objects out was:

RemoveObject (object_level1)
AddToInventory (object_level2)


Whereas you suggested MoveObject instead. Is there any reason to use one over the other, or is it just many ways to get the same thing done?


I was trying to guess what you would have used. Your way is better just because it is more obvious what is happening.

afrotoast
@The Pixie:

Using code makes me feel like I know what I'm doing, but really I don't, hahaha. But thanks to you I've learnt a little bit about the interactions between the GUI and actual code, so in the future I know where to look to pay attention to how the GUI works under the hood. I think it'll slowly give me more freedom in the software as I go along.

HegemonKhan
you're coding ;), even if you don't understand it that well right now, you've done coding, hehe :D

--------

if you interested:

create a new game, and in your new game's GUI~Editor, at the top of the screen, in the horizontal bar at the top, between the 'play' and and 'help' buttons, is a notepaper--like button. This notepaper-like button is a toggle to go back and forth between the GUI~Editor mode, and Code View mode (this shows you, your *ENTIRE* game code). Just look at the code for a bit. It should look for the most part, like this:

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="blah">
<gameid>blah</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


this is your entire game code (think of these as 'blocks' of code):

<asl version="550">
// your entire game's content~code, must be between the upper-starting '<asl>' tag and the lower-ending '</asl>' tag
</asl>


the, version="550", is the version of the quest that you downloaded. So, your code of, version="###", must match up with the actual software version of quest that you're downloaded and using. Fro example, say I'm still using an earlier version of quest, say version="520", and I want my game to work on your current version of quest, version="550". I would simply have to change my game's code from: <asl version="520">, to, <asl version="550">, ignoring some other code line's form-syntax that got changed between some versions of quest, for my game to work for your current quest that you downloaded.

the 2 'include refs' code lines are library files (extra code) that is added to your game. Quest is actually very customizable, the default quest engine is made up of lots of library files, the 'English.aslx' file and the 'Core.aslx' file (this is actually a collection of a bunch of files). So, if you're a very good programmer, you could write own library files, creating your own entirely new game engine for quest! Library files can be very simple 'patches' (like with game-software patches) of code, that you want to add to your game (such as something as simple as an Object or a Verb), they don't have to be code that creates an entire game engine, but thay can be, lol.

next is the Game Object block:

<game name="blah">
<gameid>blah</gameid>
<version>1.0</version>
</game>


Now, go back into the GUI~Editor mode (press that notepaper like button at the top), and on the left side, click on 'game', so it is highlighted, then click on one of the Tabs on the right side and put in some setting (for example: the 'author' or 'category' or whatever). Now, go back into Code View, and see if you can find the additional code line~s (Attribute tag lines~blocks) to your Game Object.

thus, you can compare doing something in the GUI~Editor, to what it really is (as code) in code, and vice versa.

after the special Game Object (it holds all the global game-wide settings and options), you've got the default 'room' Room Object block:

<object name="room">
// blah stuff for now
</object>


and within the default 'room' Room Object is the default 'player' Player Object:

// the default 'player' Player Object tag block:

<object name="player">
// blah
</object>

// and as can be seen, the 'player' Player Object is (placed) inside (see how its indented over) of the default 'room' Room Object:

<object name="room">
// blah
<object name="player">
// blah
</object>
</object>

--------------------------------------------------------------------

// or, instead of (1) "physically" placing the player into the room as seen above, we can do it, this way too:

<object name="room">
// blah Attributes
</object>

<object name="player">
// blah Attributes
<attr name="parent" type="object">room</attr>
</object>

// the (2) 'parent' Attribute does the same thing as the GUI~Editor's add new script: (3) 'MoveObject(moving_Object, destination_Object)' Script
// these 3 ways, are all ways of determining-setting-assigning an Object's current location (such as being inside of another Object)


are you starting to see~understand how the code is structured a little bit?

afrotoast
@HK

That's really fascinating, I was actually under the impression that my ability to look at the game's code was limited to only the little windows within each object, but being able to see the whole game as nothing but letters and symbols on a screen is pretty mind-blowing: coding is something I've always regretted not getting into when choosing my post secondary-education and all this is really exciting. Is this a language unique to quest? Or will I be able to take what I learn here into more complex environments as well?

The idea of customizing and making my own engines sounds super exciting but I think I have a lot more to learn before I can think about unpacking all that =p

The Pixie
Quest uses several laguages. When you go Tools - Code view, you are looking at the XML that holds the data. You do not usually need to worry about that, though it is probably the easioer to understand. The code that actually does stuff, what I was using, is unique to Quest, and is worth getting familar with. Text is displayed with HTML (almost the same as XML), and manipulated with JavaScript.

HegemonKhan
I actually used quest to learn to program (I found quest, ~ 2-3 years ago, not knowing anything at all about programming)! And now I'm currently (right now) taking my very first programming classes in C++, Java, and Python, and I've been shocked at how well I know and am doing in these 3 programming language classes. The only thing that quest hasn't covered (fully or not at all) is: (not fully) encapsulation (Classes-Objects), (not fully) inheritance (quest's user level: Object Types, aren't quite the same level of complexity, as quest makes it easier, lol), and polymorphism (too hard to explain this, lol), and designing your own somewhat large-complex program, at least so far with what I've learned~done from using quest.

Also, now that I'm taking programming language classes, I can say with experience, that quest is a great way to learn the basics of programming. It is so much easier to learn the basics of programming (well, scripting, anyways) through quest than the actual programming languages, lol.

-----------

aside from learning to program from quest, there's also:

codecademy.com
udemy.com

and of course numerous websites~forums on computers~programming

and youtube videos too, for example, the MIT programming 101 videos (the Professors suck though at teaching progrmaming, lol)

------

you can see the quest engine game coding, I'd recommend doing it through the GUI~Editor though (lower left corner: Filter -> Show Library Elements -> toggle-check it so that it is toggled-checked 'on' -> now in the 'tree of stuff' is light grey text, this is all the built-in code), so you don't accidentally mess up the actual quest files ("core~blah.aslx" files), and have to re-download quest. But, if you can be careful, you can go into the quest folder, and look at all of its engine files, just open them up with a text software like notepad, wordpad, notepad++ (if you want to learn~do programming, I recommend you DL this), Apple: text editor, etc, and look at quest's code.

---------

Notepad++

https://notepad-plus-plus.org/

this has a lot of great features that I need to learn about and use, lol.

but the main reason to DL it, is that it has a lot (~most) programming languages, and it color codes the lines for you, making it easier to read, write, and troubleshoot code.

once you DL'ed, installed, and started-opened up and are in notepad++, at the top of the screen in the horizontal bar at the top, is 'languages', click on it, and then select the programming language you need. For quest, choose 'XML' (eXtensible Markup Langauge).

--------

just learned a bit more from Pixe's post above, laughs.

here's how I would describe what Pixie said (if I understand correctly):

'XML' is (at least like) a web-browser language similar to 'HTTP', and in quest, the 'XML', is what I call the 'creation' tags (conceptually, this code is~gives the "physical form ~ existence" of stuff, its your "physical" things in your game~code):

all the stuff with the (showing it horizontal, but usually it's vertical): '<xxx>xxx</xxx>' or '<xxx />'

the computer doesn't care whether you write vertically or horizontally, but humans have a very hard time reading horizontal code.

<asl version="550">
</asl>

<game name="xxx">
</game>

<object name="room">
</object>

<object name="HK">
<attr name="strength" type="int">100</attr>
<attr name="endurance" type="int">100</attr>
<attr name="dexterity" type="int">100</attr>
<attr name="agility" type="int">100</attr>
// etc Attributes
</object>

<function name="xxx">
</function>

// etc etc etc


-------

then there's the all the scripting (the action~event coding), which is unique to quest, but similar to many~some languages (Quest is similar in design structure to Python, as Alex~Quest is European~U.K., and Python is more popular in Europe than in the U.S. currently):

(there's no 'creation' tags, '<xxx>xxx</xxx' or '<xxx />', on any of this code)

HK.strength = 100
HK.strength = HK.strength * 10000000

HK.damage = 100000000

orc.dead = false
orc.current_life = 100

a 'fight' Verb's scripting added to the 'orc' Object:

if (orc.dead = false) {
orc.current_life = orc.current_life - HK.damage
msg ("You attack the orc.")
if (orc.current_life <= 0) {
orc.dead = true
msg ("You killed the orc.")
} else {
// the orc attacks you, code lines, (I'm lazy)
}
} else {
msg ("The orc is already dead, silly.")
}

// etc etc etc examples of scripting code lines~blocks


--------

and lastly, JS (JavaScript) can be used too, for doing whatever, with quest.

--------------------------

here's mostly vertical code format:

(very easy to read and understand, once you get its structure, of course)

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="blah">
<gameid>blah</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


here's horizontal code format:

(we humans hate it, as we can't read it easily like a computer can)

<asl version="550"><include ref="English.aslx" /><include ref="Core.aslx" /><game name="blah"><gameid>blah</gameid><version>1.0</version></game><object name="room"><inherit name="editor_room" /><object name="player"><inherit name="editor_object" /><inherit name="editor_player" /></object></object></asl>

afrotoast
@HK & The Pixie

Wow, thanks for taking the time to explain all this to me. So I guess I can understand it as - the <XML> tags define what exists, and the scripting defines how the things that exist interact?

I didn't actually know that code would work horizontally as well - I thought that the indents and spacings were important to the way code worked hahaha, like the computer read that information in certain orders because of how far tabbed they are.

The most fascinating thing is how logical everything is - if you want to implement a certain function, you just need to think logically about how it would work and you can translate it into a rough system/mechanic. Then you just have to use some words to smooth over what's happening under the hood and it creates an illusion of reality.

Like, it's so counter intuitive, that when you "wear" an item in this game i'm working on, the game actually removes "item" from your inventory, and places a "item_worn" in your inventory, but I can use flavor text to make it seem like your character is actually putting something on.

Right now the biggest obstacle is that when the interactions get more complex, and I need certain things I've added early on while fumbling with the basics to also interact with the newer things, I lose track of what code means what, and sometimes find that i need to completely rewrite the interactions of the older objects.

I take it as a good sign that I'm learning as I move forward, hahaha.

HegemonKhan
in some languages, the indenting matters (such as Python, I think), but some other languages it doesn't ~~~ it depends if the language has statement-ending symbols (usually it's a semicolon) or not, and~or if it's otherwise programmed in, to understand where endings and begginings occur.

----------

oh definately... it is SOOOOOOO OVER-WHELMING at first... if you want a laugh, you can see me when I first found quest (~ 2 to 3 years ago), laughs:

(I went through the tutorial, understanding most of it, but when got done, I was so confused by all of the terms, when I tried to do stuff on my own, I was at a total lost, lol)

viewtopic.php?f=10&t=3348

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

Support

Forums