1. you're correct about the terminology of quest's 'variable' and 'attribute', though do note that to be global, it must be attached to an object (Object.global_variable_aka_quest's_attribute), but otherwise quest's 'variable' and 'attribute' is the same thing: it's merely a string value that equals an Attribute Type's Value. Sorry, I couldn't word this very clearly, lol. keep reading below, to hopefully have a more clear reading~understanding of it, lol.
(Variable) = (Value_or_Expression)
(String) = (Value_or_Expression)
example: strength = 100
(Attribute) = (Value_or_Expression)
(Object.String) = (depends on the type of attribute that it is: string, integer~int, boolean, list, dictionary, double, etc)
example: player.strength = 100
------
Quest's terminology is a bit different from the generic programming terminology:
(quest's "double" is the same as a "float~floating point", ie a decimal number amount)
(quest's "dictionaries", and maybe "lists" too ~ not sure, is the same as "arrays", I think anyways ~ arrays confused me, lol)
In quest, the generic programming terminology of "Variable" is split into two sub-categories:
"Variable" and "Attribute"
A "Variable" is local, as it is *NOT* attached to something permanent (an Object, well so long as the Object still exists, anyways, of course, lol)
Variable = Value_or_Expression
ie: handled = false
ie: you_go_first = true
ie: strength = 100
ie: primary_pigment_color_string_list = split ("red;blue;yellow",";")
ie: x = 5
ie: x = 4 * (5 + y)
An "Attribute" is global, as it *IS* 'attached' (has the dot~period between the "Object" and the "Attribute") to something permanent (an Object, well... so long as the Object still exists, anyways, of course, lol)
Object.Attribute_or_Variable_whatever_you_want_to_call_this_String_Value_lol = Value_or_Expression
ie: room.radiation = 30
ie: table.material = "wood"
ie: game.x = 5
ie: game.turns = 0
ie: player.turns = 0
ie: player.strength = 20
ie: HK.strength = 100
ie: HK.favorite_color = black
ie: HK.favorite_color_string_list = split ("black;red",";")
ie: HK.dead = false
ie: orc.fight => { see scripting below, shown in the Tag for the "orc" Object }
<object name="orc">
-> inherit name="editor_object" />
-> <attr name="fight" type="script">
->-> if (orc.dead = true) {
->->-> msg ("It is already dead, silly.")
->-> } else if (orc.dead = false) {
->->-> orc.hp = HK.damage - orc.hp
->->-> msg ("HK attacks the orc for " + HK.damage + " damage, leaving the orc with only " + orc.hp + " hp left.")
->->-> if (orc.hp <= 0) {
->->->-> orc.dead = true
->->->-> msg ("You killed the orc.")
->->-> }
->-> }
-> </attr>
-> <attr name="displayverbs" type="listextend">Fight</attr>
</object>
-----
see that dot~period, separating the "Object" from the "Attribute" (Object.Attribute) ??? this is how you "attach" it in scripting
or in the GUI~Editor:
you would "add" an Attribute to an Object to do the 'attachment'
ie: "HK" Object -> Attributes (Tab) -> Attributes -> Add -> (set it up)
-----
when you have an "Object.Attribute" defined (ie: HK.strength), you can then "call upon or use" that Attribute in any scripting:
<object name="HK">
-> <inherit name="editor_object" />
-> <attr name="strength" type="int">100</attr>
</object>
<function name="blah_1_function">
-> if (HK.strength = 100) {
->-> msg ("HK is strongest in the world, muwhahaha!")
-> }
</function>
<function name="blah_2_function">
-> orc.hp = (HK.strength - orc.endurance) - orc.hp
</function>
<function name="blah_3_function">
-> HK.strength = HK.strength + 100
</function>
---------------------
whereas, if you set a 'Variable', it's local, it's only useable for that script that you set~defined it within:
<function name="blah_1_function">
-> you_go_first = false
-> if (HK.speed > orc.speed) {
->-> you_go_first = true
-> }
-> if (you_go_first = true) {
->-> orc.hp = HK.damage - orc.hp
-> } else if (you_go_first = false) {
->-> HK.hp = orc.damage - HK.hp
-> }
</function>
<function name="blah_2_function">
-> if (you_go_first = true) {
->-> HK.mp = spell.cost - HK.mp
-> } else if (you_go_first = false) {
->-> orc.mp = spell.cost - orc.mp
-> }
</function>
// ERROR, as "you_go_first" is never defined, and because it's local (no attachment to an object), it can't be used outside of the "blah_1_function" Function, such as within the "blah_2_function" Function.
-------------
A Library is merely a code file (think of a Library as like being a "patch", an "expansion_pack", or even the "game_engine_source_code_itself"), quest itself, is actually made up of libraries:
English.aslx
Core.aslx (which is merely a database, ie it runs~executes, of all the many individual core files, if I understand it correctly)
and you can add in other libraries too:
<asl version="540">
<include ref="English.aslx"/>
<include ref="Core.aslx"/>
<include ref="Pixie's Spell Library File.aslx"/>
<include ref="Chase's Wearables Library File.aslx"/>
<game name="Testing Game Stuff">
<gameid>d67ec73f-f879-4911-9d88-c02ea527c534</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>
or, heck, create your own quest game engine:
<asl version="540">
<include ref="English.aslx"/>
<include ref="HK's Game Engine Library File.aslx"/>
// the code design would be totally different, lol
</asl>
--------------------------
2. it depends on the variable (aka 'attributes'), if it's an attribute specific to an object, then you'd want to define it within that object obviously, but if its a game attribute, than there's a few ways of doing this. but let me explain first what I mean here.
"strength" would be set~defined on every "actor~character~pc~npc" Object, obviously, as it's a (RPG common) in-game stat attribute for those type of objects.
HK.strength = 100
blackstar.strength = 50 // hehe
orc.strength = 25
etc...
but say you've got "game progression event flag~boolean" variables~attributes, such as:
dragon_slayer_sword_acquired = false
dragon_killed = false
rescued_princess = false
<turnscript name="global_turn_script">
-> <enabled />
-> <script>
->-> if (dragon_slayer_sword_acquired = true) {
->->-> // script that moves or creates the "dragon" Object into the game world
->-> }
->-> if (dragon_killed = true) {
->->-> // script that unlocks the door to the "princess" Object
->-> }
->-> if (rescued_princess = true) {
->->-> msg ("You won the game!")
->->-> finish
->-> }
-> </script>
</turnscript>
these, would be "game event" ("progression") boolean attributes, which aren't applied to multiple objects as "strength" would be.
so, you can "add" these attributes to the "game" Object:
in the GUI~Editor:
"game" Object -> Attributes (Tab) -> Attributes -> Add -> (set them up)
but, the "game" Object is already crowded enough already...
so, a nifty thing to do, is to create an Object, which isn't within a room type Object:
<object name="game">
</object>
<object name="room" >
-> <object name="player">
-> </object>
</object>
<object name="global_data_object"
-> <attr name="dragon_slayer_sword_acquired" type="boolean">false</attr>
-> <attr name="dragon_killed" type="boolean">false</attr>
-> <attr name="princess_rescued" type="boolean">false</attr>
</object>
HOWEVER, the only problem with this, is that if you want this stuff to be displayed during game play in the right panel, you must use the "game" Object (or the Player Objects). Though, you can display it by using, a Command, for example to display it within the left text window~pane during game play:
<command name="quest_command">
-> <pattern>show quest</pattern>
-> <script>
->-> msg ("Dragon Slayer Sword Acquired?: " + global_data_object.dragon_slayer_sword_acquired)
->-> msg ("Dragon Killed?: " + global_data_object.dragon_killed)
->-> msg ("Princess Rescued?: " + global_data_object.princess_rescued)
-> </script>
</command>
here's an example (feel free to use it ~ ask if you don't know how to copy and paste this into a new game file of yours):
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<game_is_paused type="boolean">false</game_is_paused>
<game_turns type="int">0</game_turns>
<point_score type="int">0</point_score>
<statusattributes type="simplestringdictionary">game_turns =;game_is_paused =;point_score =</statusattributes>
<start type="script">
msg ("NOTE: Type in something in the command box and hit enter on each turn, to see the attributes being changed.")
msg ("")
</start>
</game>
<function name="show_attributes_function">
msg ("")
msg ("Player's Attributes:")
msg ("")
msg ("Flying: " + player.flying)
msg ("Player Turns: " + player.player_turns)
msg ("")
msg ("Game's Attributes:")
msg ("")
msg ("Game Is Paused: " + game.game_is_paused)
msg ("Game Turns: " + game.game_turns)
msg ("Point Score: " + game.point_score)
msg ("")
msg ("Global Data Object's Attributes:")
msg ("")
msg ("Dragon Slayer Sword Acquired: " + global_data_object.dragon_slayer_sword_acquired)
msg ("Dragon Killed: " + global_data_object.dragon_killed)
msg ("Princess Rescued: " + global_data_object.princess_rescued)
msg ("")
msg ("Turnscript's Scripting Steps's Changed Attributes' Results:")
msg ("")
</function>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<flying type="boolean">false</flying>
<player_turns type="int">0</player_turns>
<statusattributes type="simplestringdictionary">player_turns =;flying =</statusattributes>
</object>
</object>
<object name="global_data_object">
<inherit name="editor_object" />
<dragon_killed type="boolean">false</dragon_killed>
<princess_rescued type="boolean">false</princess_rescued>
<dragon_slayer_sword_acquired type="boolean">false</dragon_slayer_sword_acquired>
</object>
<turnscript name="global_events_turnscript">
<enabled />
<script>
show_attributes_function
if (player.flying=false) {
player.flying=true
} else if (player.flying=true) {
player.flying=false
}
if (game.game_is_paused=false) {
game.game_is_paused=true
} else if (game.game_is_paused=true) {
game.game_is_paused=false
}
if (global_data_object.dragon_slayer_sword_acquired=false) {
global_data_object.dragon_slayer_sword_acquired=true
game.point_score = game.point_score + 50
msg ("dragon_slayer_sword_acquired: " + global_data_object.dragon_slayer_sword_acquired)
msg ("Point Score: " + game.point_score)
if (global_data_object.princess_rescued=true) {
global_data_object.princess_rescued=false
msg ("Princess Rescued: " + global_data_object.princess_rescued)
}
}
if (global_data_object.dragon_slayer_sword_acquired=true) {
global_data_object.dragon_killed=true
game.point_score = game.point_score + 250
global_data_object.dragon_slayer_sword_acquired=false
msg ("Dragon Killed: " + global_data_object.dragon_killed)
msg ("Point Score: " + game.point_score)
msg ("dragon_slayer_sword_acquired: " + global_data_object.dragon_slayer_sword_acquired)
}
if (global_data_object.dragon_killed=true) {
global_data_object.princess_rescued=true
game.point_score = game.point_score + 400
global_data_object.dragon_killed=false
msg ("Princess Rescued: " + global_data_object.princess_rescued)
msg ("Point Score: " + game.point_score)
msg ("Dragon Killed: " + global_data_object.dragon_killed)
}
game.game_turns = game.game_turns + 1
player.player_turns = player.player_turns + 5
</script>
</turnscript>
</asl>
-----------------------
@Jay,
aren't technically, most of the ELEMENTS (Objects, Commands, Functions, Timers ~ if global, Turnscripts ~ if global, Types ~ Object Types, and etc?) global (ie: can 'hold~contain', thus 'save-load or call upon~use' any place, attributes~scripts~objects) ?
what is the technical 'object' of the 'object-oriented programming' of quest's design? specifically only the "Object" Element, or are (most of) the Elements (Objects, Commands, functions, and etc) also considered as the technical 'object' of quest's object-oriented programming design ??