by date
Plan for Matthew Langley
Plan for Matthew Langley
| Name: | Matthew Langley | ![]() |
|---|---|---|
| Date Posted: | Jan 24, 2005 | |
| Rating: | 4.0 out of 5 | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Matthew Langley |
Blog post
In game journal system, It is becomming Very open ended and dynamic, probably usable for inventory and other data as well. It is very near finished and extremely robust. It has become basically a database that could be used for literaly any type of game data.
this is continued from my previous plan ... that plan gives you some initial information and details... this plan has a list and description of almost all of the functions I have in the system peresently... it has become very robust
First here are some pics to get an idea...
note: i modified the guiMessageVectorCtrl slightly to return the line I click
here is an entry, notice the picture on the right, this is loaded if you have a property named "image"... with a file path behind it, this is done automatically for any entry you have one listed (another reason this can be used for so much more than a journal... note the data behind these pictures is very robust, it doesnt need linked to the interface I've created.

note in this one the image is different for the different entry... also note the colors did not change... i have it automatically color anything before a ":" in the entry blue, while the text after is different, this is if you include a ":"... the colors can be changed in a profile.

the next text is straight out of my console log from the .debugInfo() command... it shows some of the datastructure (this is explained more in my previous plan
"
------------------- ARRAYS --------------------------
$journalMainTags
------------------------------------------------------------------
$journalMainTags[0] - entry
$journalMainTags[1] - item
------------------------------------------------------------------
$journalSubTags
------------------------------------------------------------------
$journalSubTags.contents[0].contents[0] - name
$journalSubTags.contents[0].contents[1] - text
$journalSubTags.contents[0].contents[2] - item
$journalSubTags.contents[0].contents[3] - image
$journalSubTags.contents[1].contents[0] - name
$journalSubTags.contents[1].contents[1] - value
$journalSubTags.contents[1].contents[2] - power
------------------------------------------------------------------
$mainValueArray
------------------------------------------------------------------
$mainValueArray.contents[0] - 3
$mainValueArray.contents[1] - 1
------------------------------------------------------------------
$subValueArray
------------------------------------------------------------------
$subValueArray.contents[0].contents[0].contents[0] - Quest given by: BoB
$subValueArray.contents[0].contents[0].contents[1] - Quest text: Go here and do that
$subValueArray.contents[0].contents[0].contents[2] - Quest item: sword of fire
$subValueArray.contents[0].contents[0].contents[3] - Dark.Game/client/ui/GarageGames.jpg
$subValueArray.contents[0].contents[1].contents[0] - BoB2
$subValueArray.contents[0].contents[1].contents[1] - slay the beast and return its head
$subValueArray.contents[0].contents[1].contents[2] - rod of death
$subValueArray.contents[0].contents[1].contents[3] - Dark.Game/client/ui/background.jpg
$subValueArray.contents[0].contents[2].contents[0] - BoB3
$subValueArray.contents[0].contents[2].contents[1] - Go here and do that3
$subValueArray.contents[0].contents[2].contents[2] - shield of valor
$subValueArray.contents[1].contents[0].contents[0] - rod of death
$subValueArray.contents[1].contents[0].contents[1] - 500
$subValueArray.contents[1].contents[0].contents[2] - death
------------------------------------------------------------------
---------------------- VARIABLES -----------------------
$journalArrayCount contents: 22
$mainTagCount contents: 2
$subTagCount[0] contents: 4
$subTagCount[1] contents: 3
$sub2TagCount contents: 0
"
Functions for the journal system
--------------------- File loading and unloading Functions---------------------------
.dumpFile()
This function takes all of the existing information in the arrays and dumps it to a config (setup file)
as well as a journal file that holds all of the entries, data, etc.
.loadFile()
This function is the heap of loops that parses the config file to gain access to the values it will parse
the journal file with. It loads all the information into the arrays as well as the counters that keep track of
everything.
--------------------- Data Manipulation Functions (what you will most likely use the most
of)---------------------------
------Delete functions
.deleteClass()
This function will delete a class if you pass it the class you want deleted... for example
say I wanted to delete the "entry" class...
JournalDemo.deleteProperty("entry");
This will delete that class, as well as all of the instances of that class, updating the arrays
and counters properly
.deleteProperty()
This function will delete a property if you pass it the class and the property you want deleted... for
example
say I wanted to delete the "name" property of the "entry" class...
JournalDemo.deleteProperty("entry", "name");
This will delete that property for the class, and in all of the instances of that class, updating the arrays
and counters properly
.deleteInstance()
This function will delete an instance if you pass it the class, identifying property and value(instance)
of that
property... for example... say I want to delete the "entry"(class) with the "name" (property) of "BoB2"
(instance)
JournalDemo.deleteInstance("entry", "name", "BoB2");
this successfully deleted that instance and correctly updates the arrays and counters
------Write functions
.writeClass()
This will add a new class to the data that will eventually be dumped to the config file
Important to remember you must write the class with this function then populate its
properties with the following functions... You must include one property and value
so it will add one instance on creation, further instances can be added via the
JournalDemo.addInstance function as used inside this function... for example
JournalDemo.writeClass("spell", "name", "ball of fire");
this will add the spell class, which in turn adds "<spell>" and "</spell>" to the config
.writeProperty()
This will add a new property to the specified class that will eventually be dumped to
the config file... for example
JournalDemo.writeProperty("spell", "damage");
this will add the spell class, which in turn adds "<spell>" and "</spell>" to the config
------Write functions - to the data (journal in my example)
.writePropertyValue()
This function will write a value to a property. For example... say I wanted to change the name of my
"rod of death"
under the "item" class. I would do this
JournalDemo.writePropertyvalue("item", "name", "rod of death", "name", "new rod of death");
As you can see I pass all the information needed to identify the rod of death and to change its property
.addInstance()
This function will add an instance... Key things to remember, the class must exist and the
property must exist already... using the above functions this is accomplished...
you must specify at least one starting value to reference the instance, can be any that you
created or that are already there
for example... say you wanted to add an instance of the "item" class, thats called
"Sword of Fire"
JournalDemo.addInstance("item", "name", "Sword of Fire");
now the instance of item with the name property of "Sword of Fire" has been added
from here you can use JournalDemo.writePropertyValue to add values to the existing properties
of the "item" class or the JournalDemo.writeProperty to add more properties to the "item"
class
NOTE: the following is a bit more advanced, knowledge of Script Object arrays is needed
you do not NEED to use them, the above specifies normal use, this is additional use
Now I also added support for passing it ScriptObject arrays... though you could just loop
this function and create all sorts of instances I figured I'd make this resource as robust
as possible... There are two types of ScriptObject arrays that it will take... "single" and
"multi"... to pass a ScriptObject array you would call do a call like
JournalDemo.addInstance("entry", "single", $testArray);
note the first value is the same, the class, the second specifies "single" or "multi" and
the last is the ScriptObject array, the code will automatically detect if its a ScriptObject
array and process it accordingly... for example
Example of "single"
$testArray = new ScriptObject();
$testArray.contents[0] = new ScriptObject();
$testArray.contents[1] = new ScriptObject();
$testArray.contents[0].contents[0] = "name";
$testArray.contents[0].contents[1] = "person1";
$testArray.contents[0].contents[2] = "text";
$testArray.contents[0].contents[3] = "BLAH BLAH BLAH";
$testArray.contents[0].contents[4] = "item";
$testArray.contents[0].contents[5] = "Sword of Fire";
$testArray.contents[1].contents[0] = "name";
$testArray.contents[1].contents[1] = "person2";
$testArray.contents[1].contents[2] = "text";
$testArray.contents[1].contents[3] = "blah blah blah";
$testArray.contents[1].contents[4] = "item";
$testArray.contents[1].contents[5] = "Sword of Death";
Example of "multi"
$testArray = new ScriptObject();
$testArray.contents[0] = new ScriptObject();
$testArray.contents[1] = new ScriptObject();
$testArray.contents[0].contents[0] = "name";
$testArray.contents[0].contents[1] = "person1";
$testArray.contents[0].contents[2] = "person2";
$testArray.contents[0].contents[3] = "person3";
$testArray.contents[0].contents[4] = "person4";
$testArray.contents[1].contents[0] = "item";
$testArray.contents[1].contents[1] = "sword1";
$testArray.contents[1].contents[2] = "sword2";
$testArray.contents[1].contents[3] = "sword3";
$testArray.contents[1].contents[4] = "sword4";
Single is set up like this
Array[0][0] - property
Array[0][1] - value
Array[0][2] - property
Array[0][3] - value
Array[1][0] - property
Array[1][1] - value
Array[1][2] - property
Array[1][3] - value
etc etc... this will create two new instances, the first array number denotes the seperation
of instances....
Multi is set up like this
Array[0][0] - property
Array[0][1] - value
Array[0][2] - value
Array[0][3] - value
Array[1][0] - property
Array[1][1] - value
Array[1][2] - value
Array[1][3] - value
Now this is quite a bit different, six different instances will be created, basically multi
is a good way to spam a bunch of simple instances, while single adds instances with multiple
properties
------Search functions
.searchByClass()
search by passing the class and returning the entire class contents
for example... I have "entry" and "item" classes... If I want to
return all entry types I would use
$entries = JournalDemo.searchByClass("entry");
then I could use
echo($entries.contents[0].contents[0]);
and the first property of the first "entry" should display in console
this will be usefull if you use this system as inventory, dialog, etc,
like a database, so you can return only the type you want
.searchByInstanceWithClass()
search by passing the class, property, and instance and returning the instance
for example... I want to get the item by the property "name" of "rod of death" and I know
its of class "item"... I would use
$testInstance = JournalDemo.searchByInstanceWithClass("item", "name", "rod of death");
then I could use
echo($testInstance.contents[0]);
and the first property of "rod of death" would be displayed in console, which would be
"rod of death"
the name we searched by...
echo($testInstance.contents[1]);
would reveal "500"
.searchByInstance()
search by passing the property, and instance and returning the instance, without passing class
note: its recommended to use the previous function, specifying the class will increase efficiency
especially if you have a lot of classes
for example... I want to get the item by the property "name" of "rod of death" without knowing
the class... note: the property instance must be unique! or it will simply return the first
match it finds
$testInstance = JournalDemo.searchByInstance("name", "rod of death");
then I could use
echo($testInstance.contents[0]);
and the first property of "rod of death" would be displayed in console, which would be
"rod of death"
the name we searched by...
echo($testInstance.contents[1]);
would reveal "500"
.searchByPropertyWithClass()
search by passing the class, property, instance, and return property and returning the
property value you specified in %returnProperty
for example... I want to get the item by the property "name" of "rod of death" and I know
its of class "item" and I want to get its "value" I would use
$testProperty = JournalDemo.searchByPropertyWithClass("item", "name", "rod of death", "value");
then I could use
echo($testProperty);
and it would reveal the "value" of "500"
.searchByProperty()
search by passing the property, instance, and return property and returning the
property value you specified in %returnProperty
for example... I want to get the item by the property "name" of "rod of death" and I know
its of class "item" and I want to get its "value" I would use
$testProperty = JournalDemo.searchByProperty("name", "rod of death", "value");
then I could use
echo($testProperty);
and it would reveal the "value" of "500"
-----------------------------------------------------------
Using these search functions... heres an example
-----------------------------------------------------------
Say you have the quest for the "rod of death"... the user wants to know its value...so you do
$testProperty = JournalDemo.searchByPropertyWithClass("item", "name", "rod of death", "value");
The value returns "500"... they like this... so they then want to see what the quest entails..
to get the text associated with the journal entry for this, you would do
$testProperty = JournalDemo.searchByPropertyWithClass("entry", "item", "rod of death", "text");
and it returns "slay the beast and return its head"
then the user asks, who do I return it to... you would get this info by
$testProperty = JournalDemo.searchByPropertyWithClass("entry", "item", "rod of death", "name");
which would return "BoB2"
this is just an example of the many ways to manipulate these functions... note I did include
search functions 'without' the class specification, though you can tell this will decrease
search efficiency
Another great use for this will be setting up a user searchable journal, item list
really its more like a database that can be used for anything... Quite nifty...
In all truth with the functions given it isnt too hard, though it won't be very smart...
(unless you add a bit of a smartness to it, like estimating what the user means, etc)
I may include GUIs and such for this by the time I release this resource, lol if you see it
included then I decided to go ahead and do that, if not then you shouldn't have much trouble
doing it yourself
I may even add functionality to search through the text of each entry, though adding searching
by item, name, or any 'property' or 'class' should be a snap with these functions
------Return functions
.returnClass()
This is for internal uses, it will return the class number used in the data arrays
by passing it the class name ... for example
$classNum = JournalDemo.returnClass("entry");
will return "0"... which then could be identified by using it in the arrays, like
echo($journalMainTags[JournalDemo.returnClass("entry")]);
should display "entry"
.returnProperty()
This is for internal uses, it will return the property number used in the data arrays
by passing a class, and property... for example
$propertyNum = JournalDemo.returnProperty("item","name");
this will return the array number
.returnInstance()
This is for internal uses, it will return the instance number used in the data arrays
by passing a class, property, and instance... for example
$instanceNum = JournalDemo.returnInstance("item","name","rod of death");
this will return the array number
.returnClassName()
This function is used if you have the internal array class Number and want to get the
class name... After some thought I decided to use the above return commands passing the
text name... like "entry" rather than having you convert it to the 0 it is in the internal
array... so I added these two function to help if you already have the number and need the
name, whether for the above functions or for another use... for example
$className = JournalDemo.returnClassName(0);
echo($className);
this should display "entry" in the console
.returnPropertyName()
Heres the second number to name function... pass it the class "text" and the property
number an it will return the property name, look above for reasons you might use this
... for example
$propertyName = JournalDemo.returnPropertyName("entry", 0);
echo($propertyName);
this should print "name" in the console
--------------------- Debug Functions---------------------------
.debug()
and
.debugInfo()
I included a couple debug functions, one that loads the file and displays the journal ... the other is
called from the debug command but can be run seperately also, debugInfo is very usefull it will display all the
contents of the arrays and counters, correctly labeled.
--------------------- String Helper Functions---------------------------
.getTagName()
Here is an internal command that is very usefull... it will get the name out of a tag... for example...
you pass it "<entry>" and it gets "entry" out of it... just a helper string function
.returnStringAfter()
Here is another internal helper string function... pass it .returnStringAfter("name=bob", "=") and it
will return "bob"...
.returnStringBefore()
Same as .returnStringAfter except it returns the string before the character
--------------------- Display Functions---------------------------
.displaySub(%lastMenu, %obj)
This function will display a sub object of the journal overlayed over the journal (as well as an image in
the right pane if you have one under that sub... In a journal example this displays the journal entry, the text,
the name, items associated with it, etc... Basically this displays an "instance"
.displayType(%lastMenu)
This will display all of the types or "classes"... so if you have an "entry" class and an "item" class
then it will display entry and item... so then you can browse down further
.displayMain(%lastMenu, %obj)
This will display the contents of a type or "class"... so if you want to display all the journal entries
this would be the function that would... note: the first property of an entry is what is display when listing
all the entries, so you can choose to make the first entry a name, a title, or whatever you choose.
First here are some pics to get an idea...
note: i modified the guiMessageVectorCtrl slightly to return the line I click
here is an entry, notice the picture on the right, this is loaded if you have a property named "image"... with a file path behind it, this is done automatically for any entry you have one listed (another reason this can be used for so much more than a journal... note the data behind these pictures is very robust, it doesnt need linked to the interface I've created.
note in this one the image is different for the different entry... also note the colors did not change... i have it automatically color anything before a ":" in the entry blue, while the text after is different, this is if you include a ":"... the colors can be changed in a profile.
the next text is straight out of my console log from the .debugInfo() command... it shows some of the datastructure (this is explained more in my previous plan
"
------------------- ARRAYS --------------------------
$journalMainTags
------------------------------------------------------------------
$journalMainTags[0] - entry
$journalMainTags[1] - item
------------------------------------------------------------------
$journalSubTags
------------------------------------------------------------------
$journalSubTags.contents[0].contents[0] - name
$journalSubTags.contents[0].contents[1] - text
$journalSubTags.contents[0].contents[2] - item
$journalSubTags.contents[0].contents[3] - image
$journalSubTags.contents[1].contents[0] - name
$journalSubTags.contents[1].contents[1] - value
$journalSubTags.contents[1].contents[2] - power
------------------------------------------------------------------
$mainValueArray
------------------------------------------------------------------
$mainValueArray.contents[0] - 3
$mainValueArray.contents[1] - 1
------------------------------------------------------------------
$subValueArray
------------------------------------------------------------------
$subValueArray.contents[0].contents[0].contents[0] - Quest given by: BoB
$subValueArray.contents[0].contents[0].contents[1] - Quest text: Go here and do that
$subValueArray.contents[0].contents[0].contents[2] - Quest item: sword of fire
$subValueArray.contents[0].contents[0].contents[3] - Dark.Game/client/ui/GarageGames.jpg
$subValueArray.contents[0].contents[1].contents[0] - BoB2
$subValueArray.contents[0].contents[1].contents[1] - slay the beast and return its head
$subValueArray.contents[0].contents[1].contents[2] - rod of death
$subValueArray.contents[0].contents[1].contents[3] - Dark.Game/client/ui/background.jpg
$subValueArray.contents[0].contents[2].contents[0] - BoB3
$subValueArray.contents[0].contents[2].contents[1] - Go here and do that3
$subValueArray.contents[0].contents[2].contents[2] - shield of valor
$subValueArray.contents[1].contents[0].contents[0] - rod of death
$subValueArray.contents[1].contents[0].contents[1] - 500
$subValueArray.contents[1].contents[0].contents[2] - death
------------------------------------------------------------------
---------------------- VARIABLES -----------------------
$journalArrayCount contents: 22
$mainTagCount contents: 2
$subTagCount[0] contents: 4
$subTagCount[1] contents: 3
$sub2TagCount contents: 0
"
Functions for the journal system
--------------------- File loading and unloading Functions---------------------------
.dumpFile()
This function takes all of the existing information in the arrays and dumps it to a config (setup file)
as well as a journal file that holds all of the entries, data, etc.
.loadFile()
This function is the heap of loops that parses the config file to gain access to the values it will parse
the journal file with. It loads all the information into the arrays as well as the counters that keep track of
everything.
--------------------- Data Manipulation Functions (what you will most likely use the most
of)---------------------------
------Delete functions
.deleteClass()
This function will delete a class if you pass it the class you want deleted... for example
say I wanted to delete the "entry" class...
JournalDemo.deleteProperty("entry");
This will delete that class, as well as all of the instances of that class, updating the arrays
and counters properly
.deleteProperty()
This function will delete a property if you pass it the class and the property you want deleted... for
example
say I wanted to delete the "name" property of the "entry" class...
JournalDemo.deleteProperty("entry", "name");
This will delete that property for the class, and in all of the instances of that class, updating the arrays
and counters properly
.deleteInstance()
This function will delete an instance if you pass it the class, identifying property and value(instance)
of that
property... for example... say I want to delete the "entry"(class) with the "name" (property) of "BoB2"
(instance)
JournalDemo.deleteInstance("entry", "name", "BoB2");
this successfully deleted that instance and correctly updates the arrays and counters
------Write functions
.writeClass()
This will add a new class to the data that will eventually be dumped to the config file
Important to remember you must write the class with this function then populate its
properties with the following functions... You must include one property and value
so it will add one instance on creation, further instances can be added via the
JournalDemo.addInstance function as used inside this function... for example
JournalDemo.writeClass("spell", "name", "ball of fire");
this will add the spell class, which in turn adds "<spell>" and "</spell>" to the config
.writeProperty()
This will add a new property to the specified class that will eventually be dumped to
the config file... for example
JournalDemo.writeProperty("spell", "damage");
this will add the spell class, which in turn adds "<spell>" and "</spell>" to the config
------Write functions - to the data (journal in my example)
.writePropertyValue()
This function will write a value to a property. For example... say I wanted to change the name of my
"rod of death"
under the "item" class. I would do this
JournalDemo.writePropertyvalue("item", "name", "rod of death", "name", "new rod of death");
As you can see I pass all the information needed to identify the rod of death and to change its property
.addInstance()
This function will add an instance... Key things to remember, the class must exist and the
property must exist already... using the above functions this is accomplished...
you must specify at least one starting value to reference the instance, can be any that you
created or that are already there
for example... say you wanted to add an instance of the "item" class, thats called
"Sword of Fire"
JournalDemo.addInstance("item", "name", "Sword of Fire");
now the instance of item with the name property of "Sword of Fire" has been added
from here you can use JournalDemo.writePropertyValue to add values to the existing properties
of the "item" class or the JournalDemo.writeProperty to add more properties to the "item"
class
NOTE: the following is a bit more advanced, knowledge of Script Object arrays is needed
you do not NEED to use them, the above specifies normal use, this is additional use
Now I also added support for passing it ScriptObject arrays... though you could just loop
this function and create all sorts of instances I figured I'd make this resource as robust
as possible... There are two types of ScriptObject arrays that it will take... "single" and
"multi"... to pass a ScriptObject array you would call do a call like
JournalDemo.addInstance("entry", "single", $testArray);
note the first value is the same, the class, the second specifies "single" or "multi" and
the last is the ScriptObject array, the code will automatically detect if its a ScriptObject
array and process it accordingly... for example
Example of "single"
$testArray = new ScriptObject();
$testArray.contents[0] = new ScriptObject();
$testArray.contents[1] = new ScriptObject();
$testArray.contents[0].contents[0] = "name";
$testArray.contents[0].contents[1] = "person1";
$testArray.contents[0].contents[2] = "text";
$testArray.contents[0].contents[3] = "BLAH BLAH BLAH";
$testArray.contents[0].contents[4] = "item";
$testArray.contents[0].contents[5] = "Sword of Fire";
$testArray.contents[1].contents[0] = "name";
$testArray.contents[1].contents[1] = "person2";
$testArray.contents[1].contents[2] = "text";
$testArray.contents[1].contents[3] = "blah blah blah";
$testArray.contents[1].contents[4] = "item";
$testArray.contents[1].contents[5] = "Sword of Death";
Example of "multi"
$testArray = new ScriptObject();
$testArray.contents[0] = new ScriptObject();
$testArray.contents[1] = new ScriptObject();
$testArray.contents[0].contents[0] = "name";
$testArray.contents[0].contents[1] = "person1";
$testArray.contents[0].contents[2] = "person2";
$testArray.contents[0].contents[3] = "person3";
$testArray.contents[0].contents[4] = "person4";
$testArray.contents[1].contents[0] = "item";
$testArray.contents[1].contents[1] = "sword1";
$testArray.contents[1].contents[2] = "sword2";
$testArray.contents[1].contents[3] = "sword3";
$testArray.contents[1].contents[4] = "sword4";
Single is set up like this
Array[0][0] - property
Array[0][1] - value
Array[0][2] - property
Array[0][3] - value
Array[1][0] - property
Array[1][1] - value
Array[1][2] - property
Array[1][3] - value
etc etc... this will create two new instances, the first array number denotes the seperation
of instances....
Multi is set up like this
Array[0][0] - property
Array[0][1] - value
Array[0][2] - value
Array[0][3] - value
Array[1][0] - property
Array[1][1] - value
Array[1][2] - value
Array[1][3] - value
Now this is quite a bit different, six different instances will be created, basically multi
is a good way to spam a bunch of simple instances, while single adds instances with multiple
properties
------Search functions
.searchByClass()
search by passing the class and returning the entire class contents
for example... I have "entry" and "item" classes... If I want to
return all entry types I would use
$entries = JournalDemo.searchByClass("entry");
then I could use
echo($entries.contents[0].contents[0]);
and the first property of the first "entry" should display in console
this will be usefull if you use this system as inventory, dialog, etc,
like a database, so you can return only the type you want
.searchByInstanceWithClass()
search by passing the class, property, and instance and returning the instance
for example... I want to get the item by the property "name" of "rod of death" and I know
its of class "item"... I would use
$testInstance = JournalDemo.searchByInstanceWithClass("item", "name", "rod of death");
then I could use
echo($testInstance.contents[0]);
and the first property of "rod of death" would be displayed in console, which would be
"rod of death"
the name we searched by...
echo($testInstance.contents[1]);
would reveal "500"
.searchByInstance()
search by passing the property, and instance and returning the instance, without passing class
note: its recommended to use the previous function, specifying the class will increase efficiency
especially if you have a lot of classes
for example... I want to get the item by the property "name" of "rod of death" without knowing
the class... note: the property instance must be unique! or it will simply return the first
match it finds
$testInstance = JournalDemo.searchByInstance("name", "rod of death");
then I could use
echo($testInstance.contents[0]);
and the first property of "rod of death" would be displayed in console, which would be
"rod of death"
the name we searched by...
echo($testInstance.contents[1]);
would reveal "500"
.searchByPropertyWithClass()
search by passing the class, property, instance, and return property and returning the
property value you specified in %returnProperty
for example... I want to get the item by the property "name" of "rod of death" and I know
its of class "item" and I want to get its "value" I would use
$testProperty = JournalDemo.searchByPropertyWithClass("item", "name", "rod of death", "value");
then I could use
echo($testProperty);
and it would reveal the "value" of "500"
.searchByProperty()
search by passing the property, instance, and return property and returning the
property value you specified in %returnProperty
for example... I want to get the item by the property "name" of "rod of death" and I know
its of class "item" and I want to get its "value" I would use
$testProperty = JournalDemo.searchByProperty("name", "rod of death", "value");
then I could use
echo($testProperty);
and it would reveal the "value" of "500"
-----------------------------------------------------------
Using these search functions... heres an example
-----------------------------------------------------------
Say you have the quest for the "rod of death"... the user wants to know its value...so you do
$testProperty = JournalDemo.searchByPropertyWithClass("item", "name", "rod of death", "value");
The value returns "500"... they like this... so they then want to see what the quest entails..
to get the text associated with the journal entry for this, you would do
$testProperty = JournalDemo.searchByPropertyWithClass("entry", "item", "rod of death", "text");
and it returns "slay the beast and return its head"
then the user asks, who do I return it to... you would get this info by
$testProperty = JournalDemo.searchByPropertyWithClass("entry", "item", "rod of death", "name");
which would return "BoB2"
this is just an example of the many ways to manipulate these functions... note I did include
search functions 'without' the class specification, though you can tell this will decrease
search efficiency
Another great use for this will be setting up a user searchable journal, item list
really its more like a database that can be used for anything... Quite nifty...
In all truth with the functions given it isnt too hard, though it won't be very smart...
(unless you add a bit of a smartness to it, like estimating what the user means, etc)
I may include GUIs and such for this by the time I release this resource, lol if you see it
included then I decided to go ahead and do that, if not then you shouldn't have much trouble
doing it yourself
I may even add functionality to search through the text of each entry, though adding searching
by item, name, or any 'property' or 'class' should be a snap with these functions
------Return functions
.returnClass()
This is for internal uses, it will return the class number used in the data arrays
by passing it the class name ... for example
$classNum = JournalDemo.returnClass("entry");
will return "0"... which then could be identified by using it in the arrays, like
echo($journalMainTags[JournalDemo.returnClass("entry")]);
should display "entry"
.returnProperty()
This is for internal uses, it will return the property number used in the data arrays
by passing a class, and property... for example
$propertyNum = JournalDemo.returnProperty("item","name");
this will return the array number
.returnInstance()
This is for internal uses, it will return the instance number used in the data arrays
by passing a class, property, and instance... for example
$instanceNum = JournalDemo.returnInstance("item","name","rod of death");
this will return the array number
.returnClassName()
This function is used if you have the internal array class Number and want to get the
class name... After some thought I decided to use the above return commands passing the
text name... like "entry" rather than having you convert it to the 0 it is in the internal
array... so I added these two function to help if you already have the number and need the
name, whether for the above functions or for another use... for example
$className = JournalDemo.returnClassName(0);
echo($className);
this should display "entry" in the console
.returnPropertyName()
Heres the second number to name function... pass it the class "text" and the property
number an it will return the property name, look above for reasons you might use this
... for example
$propertyName = JournalDemo.returnPropertyName("entry", 0);
echo($propertyName);
this should print "name" in the console
--------------------- Debug Functions---------------------------
.debug()
and
.debugInfo()
I included a couple debug functions, one that loads the file and displays the journal ... the other is
called from the debug command but can be run seperately also, debugInfo is very usefull it will display all the
contents of the arrays and counters, correctly labeled.
--------------------- String Helper Functions---------------------------
.getTagName()
Here is an internal command that is very usefull... it will get the name out of a tag... for example...
you pass it "<entry>" and it gets "entry" out of it... just a helper string function
.returnStringAfter()
Here is another internal helper string function... pass it .returnStringAfter("name=bob", "=") and it
will return "bob"...
.returnStringBefore()
Same as .returnStringAfter except it returns the string before the character
--------------------- Display Functions---------------------------
.displaySub(%lastMenu, %obj)
This function will display a sub object of the journal overlayed over the journal (as well as an image in
the right pane if you have one under that sub... In a journal example this displays the journal entry, the text,
the name, items associated with it, etc... Basically this displays an "instance"
.displayType(%lastMenu)
This will display all of the types or "classes"... so if you have an "entry" class and an "item" class
then it will display entry and item... so then you can browse down further
.displayMain(%lastMenu, %obj)
This will display the contents of a type or "class"... so if you want to display all the journal entries
this would be the function that would... note: the first property of an entry is what is display when listing
all the entries, so you can choose to make the first entry a name, a title, or whatever you choose.
Recent Blog Posts
| List: | 11/30/06 - Torque Game Builder 1.1.3 Goes Live! 11/05/06 - The Future of the TGB Documentation 05/16/06 - TGB Bounties Extended! 05/12/06 - Final review of TGB Bounties today 05/04/06 - Call to the TGB Community 02/28/06 - New TGB Particle Editor (Preview) 02/06/06 - A lot has happened 12/09/05 - Preview of a TDN T2D Strategy Article |
|---|
Submit your own resources!| Josh Williams (Jan 24, 2005 at 02:34 GMT) |
Edited on Jan 24, 2005 02:37 GMT
| Billy L (Jan 24, 2005 at 05:27 GMT) |
What shall you do with it when you finished it ?
| Matthew Langley (Jan 24, 2005 at 17:22 GMT) |
Right now I'm planning on releasing this as a resource, with the Journal System. Know this is one of those things a lot of developments on more complex games, like RPGs, get halted on due to dealing with data efficiently and being able to access it. Plus this allows for a central storage of game data.
If there is demand for more complex systems, or other systems for people then I might consider putting a lot of work into putting together some sort of pack with in game gui's and script using this for dialog, inventory, mission loading, etc etc... Maybe even dynamic generation of content, can see storing diff placement information, or any other generation information stored easily, as well as highly searchable content. Though not sure if there is demand for it.
EDIT: submited a dev snapshot so guess if it gets approved I'll find out if theres any demand for more... if not then I still will submit this as a resource, should round off some of the RPG resources with a journal system as well as the posibilities.
Edited on Jan 24, 2005 19:42 GMT
| Nick Zafiris (Jan 24, 2005 at 21:34 GMT) Resource Rating: 5 |
In case this will be used as an inventory system too, have you thought about a way to encrypt the data file so that the average user won't hack it?
Nick
| Matthew Langley (Jan 24, 2005 at 23:31 GMT) |
| Nick Zafiris (Jan 25, 2005 at 09:06 GMT) Resource Rating: 5 |
Nick
| Matthew Langley (Jan 25, 2005 at 18:17 GMT) |
Edited on Jan 25, 2005 18:19 GMT
| Matthew Langley (Jan 30, 2005 at 01:06 GMT) |
Now off of that tagent I went on, I tested loading objects into this system, works quite well, the base of the system is a three dimension array of ScriptObjects and call me slow but it clicked "duh" you can load objects in script objects lol, so tested a couple quick ones real quick and works nicely. Just figured I'd share the knowledge and I should submit the resource either tonight or tomorrow night (either today and tomorrow I'm going to go comment crazy to make sure everyone has good reference).
| Matthew Langley (Feb 03, 2005 at 18:43 GMT) |
btw this is basically an in game database... I am trying to figure out the best way to display a gui that displays all of the information in a database structure.
| Matthew Langley (Feb 17, 2005 at 16:31 GMT) |
for one with the added hover color change whenever you scroll then hover over an entry it redraws the entries and places you at the beginning again... rather than figure out how to make it scroll to the same position I decided to take the scrolling part off and add a back and next page functionality... at first this seems easy, after some working on it its taken a lot more than expected... right now 99.9% of it works... a bit sloppy on the scripting end (maybe I can clean it up later)... but most functionality seems to work, a very minor bug is causing me a little greif ( had to step away from the code ) so when I get a half hour or an hour I will pick it up and try to fix it, clean it up a bit and document somethings a bit more... I don't want to release the resource without enough documentation for people to understand it (though agian 99.9% of this is done)... I worked up a couple diagrams of how the system works to help others who may want to use this for more than just a journal system (or to understand it better in general) in a new plan I will throw the diagrams up there...
I really would like to finish this and get this out today (at least submitted) so people will have a journal system (or can use this)... I've tried some stress testing, so far so good, tried loading a 1,000 entries at once (extremely unlikely you'll ever load even 100 at a time) and it loads them in without delay... tried 100,000 and it delays for a bit, though all the info is loaded (mainly wanted to see how it would access the info considering its unlikely anyone would load 100,000 entries all at once - expect when loading the text file at game start).... The only other concern is the ammount of script objects... due to the ability of being able to pass script objects I use them to make the arrays... especially the 3 dimensional array, so not sure if that will have any effect on the game, but a concern I'll warn people about and hopefully see if it does or not.
| Matthew Langley (Feb 20, 2005 at 04:54 GMT) |
| Matthew Langley (Apr 20, 2005 at 16:25 GMT) |
You must be a member and be logged in to either append comments or rate this resource.



4.0 out of 5


