Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: SSH on Tue 12/12/2006 17:48:08

Title: MODULE: UltraVariables (formerly DeNGVaT) v1.10
Post by: SSH on Tue 12/12/2006 17:48:08
UltraVariables? Well, it gives you named global variables, that you don't need to worry about importing/exporting, etc. and that you can "alias" to a normal numbered AGS globalint and thereby set through dialog scripts, interaction editor, etc.

It also has named timers, like the AGS ones but as many as you like and with a memorable name.

It also has a debug GUI for these, which will also hopefully do more debug stuff too in future (see below for some suggestions).

UltraVariablesdocumentation (http://ssh.me.uk/moddoc/UltraVariables)
Download UltraVariableshere (http://ssh.me.uk/modules/UltraVariables.zip)
DeNGVaT wiki page (http://americangirlscouts.org/agswiki/DeNGVaT)

Requires AGS 3.00

use the old DeNGVat 1.01 if you want to use AGS 2.72

Title: Re: Feature requests for new Debug/GlobalInt module
Post by: RickJ on Tue 12/12/2006 19:19:31
SSH, sounds like a good idea. 

Title: Re: Feature requests for new Debug/GlobalInt module
Post by: Rui 'Trovatore' Pires on Tue 12/12/2006 23:11:08
I adore both SSH's original idea and RickJ's suggestion. I furthermore suggest that it would be an excellent module to pack alongside AGS, maybe as a part of any of the two templates it comes with. I add to this that I know I'm thinking too far ahead. I conclude I am ahead of my time.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: SSH on Fri 22/12/2006 13:23:02
Bump, to let you see the first cut of the module is out...
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: monkey0506 on Fri 22/12/2006 17:47:13
Named Timers (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28979.0) huh? Oh well. I guess you got around to implementing infinity billion possible timers before I did. Good for you. :P

[EDIT:]

Waaaaiiiiiit a second....I actually took a look at the module's internals...and with the default settings you can only have up to 200 of these named timers. Increasing that may or may not even be possible (depending on how much memory other things use, I didn't look at it too extensively)...but...you clearly state "as many as you like". You LIEEEEE!!!! ;D I'm only making a big deal because your claims inspired me to write the Timer v2.0 module (which I'll be uploading shortly). Which does allow as many timers as you want! 8)

~Cheers
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: EnterTheStory (aka tolworthy) on Sat 08/03/2008 09:00:45
Forgive the extremely stupid noob question, but...

how do I declare a new DeNGVaT-controlled string (or int) in the first place?

I can see the functions for getting and setting existing strings, but nothing for creating the string. I tried just setting a string in the hopes that it might be created automatically, but that wouldn't compile. Sorry for being so dense!
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: SSH on Sat 08/03/2008 09:59:29
That should be how it works. What error did you get? Remember you need to put quotes around the names...
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: EnterTheStory (aka tolworthy) on Sat 08/03/2008 10:42:36
Quote from: SSH on Sat 08/03/2008 09:59:29
Remember you need to put quotes around the names...

Ah...

now where is the icon for "extremely embarassed" or "hits head against brick wall"?

Fantastic module, BTW
Title: Re: DeNGVaT bug (with demo code)
Post by: EnterTheStory (aka tolworthy) on Mon 10/03/2008 16:07:24
DeNGVaT is fantastic! A real godsend. Thanks!

But I think I may have found a bug. I've tested this code on two different games (it goes in the keypress section) and it does the same weird stuff on both.

It's much simpler than it looks. I just save the string "rrrr1" or "cccc1" in a global called "woman and child_r1" or "woman and child_c1." Then reload and resave a few times. The second part (Ctrl-U) is identical to the first part (Ctrl-T) except that 'c' and 'r' have been swapped round.


if (keycode==20) { // Ctrl-T, test, temporary

Display("saving message called 'woman and child_c1' containing 'cccc1'");
Global.Sets("woman and child_c1", "cccc1");

String t = Global.Gets("woman and child_c1");
Display("contents of 'woman and child_c1' is now '%s'", t);

t = Global.Gets("woman and child_c1");
Display("contents (again) of 'woman and child_c1' is now '%s'", t);

Display("saving message called 'woman and child_r1' containing 'rrrr1'");
Global.Sets("woman and child_r1", "rrrr1");

t = Global.Gets("woman and child_r1");
Display("contents of 'woman and child_r1' is now '%s'", t);

t = Global.Gets("woman and child_c1");
Display("contents of 'woman and child_c1' is now '%s'", t);

t = Global.Gets("woman and child_r1");
Display("contents (once more) of 'woman and child_r1' is now '%s'", t);

}
if (keycode==21) { // Ctrl-U, another test, temporary

Display("saving message called 'woman and child_r1' containing 'rrrr1'");
Global.Sets("woman and child_r1", "rrrr1");

String t = Global.Gets("woman and child_r1");
Display("contents of 'woman and child_r1' is now '%s'", t);

t = Global.Gets("woman and child_r1");
Display("contents (again) of 'woman and child_r1' is now '%s'", t);

Display("saving message called 'woman and child_c1' containing 'cccc1'");
Global.Sets("woman and child_c1", "cccc1");

t = Global.Gets("woman and child_c1");
Display("contents of 'woman and child_c1' is now '%s'", t);

t = Global.Gets("woman and child_r1");
Display("contents of 'woman and child_r1' is now '%s'", t); // ********** now returns (null) ************

t = Global.Gets("woman and child_c1");
Display("contents (once more) of 'woman and child_c1' is now '%s'", t);

}


Ctrl-U returns a null bug if it is run first.

Ctrl-T works perfectly every time.

Ctrl-U works perfectly if Ctrl-T is run first.

Any idea what is happening here? I am guessing that this has something to do with the length of the strings? And DeNGVaT is scared of the letter 'r' for some reason? SSH did you have an old girlfriend who's name started with 'r' by any chance? :)
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: SSH on Mon 10/03/2008 16:46:54
Ah, thanks for finding this. I missed a line out of the insertion code...

You can change in the module script:

    this.name[i]=this.name[j];
    this.val[i]=this.val[j];


to:


    this.name[i]=this.name[j];
    this.val[i]=this.val[j];
    this.str[i]=this.str[j];


at around line 38. Or remove the module, download v1.01 and put that in (which comes to the same thing).

Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.0
Post by: EnterTheStory (aka tolworthy) on Mon 10/03/2008 17:07:03
Thanks! And sorry for giving such a long piece of code. I just narrowed it down to just a couple of lines, then came to upload the new code and you've already fixed it! Thanks again!
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: Rui 'Trovatore' Pires on Sat 15/03/2008 11:00:24
A 404? Forshame.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: SSH on Sat 15/03/2008 14:38:48
hajo hasn't restored my server yet. Go shout at him...  :(
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Tue 18/03/2008 08:03:57
I've been using DangVIT/dungVET/DengXiouPing/WhAtEvEr for a week now and it is AWESOME!!! Far more useful than I ever imagined. My game is based on large amounts of dialog, and I've got to the stage of coding the endless conversations and "if-then" choices. DoNgVoTe is the only way to make my code usable. I can take anything complicated, give it a meaningfully named alias, and just shove it into its own function. Without DeNeroVT my code would be utterly unreadable and unmaintainable. Thanks, SSH!
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Wed 26/03/2008 09:56:09
How fast is DeNGVaT? Does anyone have real-world experience of using thousands of DeNGVaT global strings? I'm thinking of rewriting my code so that around a thousand DeNGVaYT strings are assigned when the game starts, and some mouse clicks instantly search several hundred DeNGVaT strings. Is this likely to affect performance? Any ideas?
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: SSH on Wed 26/03/2008 11:45:57
If you hit performance problems, I could probably write some code that loads initial values for a huge pile of variables in from a file, which may be quicker.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Wed 26/03/2008 12:36:50
Thanks! And now for a completely different question...

Is it possible to find the array index number of a DeNGVaT string? I often use DeNGVaT as a way to associate strings with unique numbers. At present I have to make up a unique number and assign it to the string, then search all the strings for that number to find the string I want. It would be extremely helpful if I could just refer to the DeNGVaT string by its index number.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: SSH on Wed 26/03/2008 13:41:45
So basically you want to have an array of strings?

DengVaT index numbers can change dynamically, so that wouldn't help. Perhaps what you want is really:


Global.SetS(String.Format("Myvar%d", number), "This is the string associated with that number");


Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Wed 26/03/2008 13:52:20
Thanks for the suggestion.  I'll have a look at that.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Mon 14/04/2008 14:50:15
Hi SSH! Is there a simple way to copy ALL the variables saved by Global.Gets() and Global.Get() ?

I'm writing a function to save data to a file between games. I don't want to just use "savegame" because I only want specific things. But one of things I want is globals saved through DeNGVaT. I could just run through all the variables I might have made, but it would be MUCH easier to just globally save them all to an array, then read that array back when the game is loaded again.

Is that possible?
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Tue 15/04/2008 16:25:42
Quote from: tolworthy on Mon 14/04/2008 14:50:15
Hi SSH! Is there a simple way to copy ALL the variables saved by Global.Gets() and Global.Get() ?
I'll take that as a "no" then. Oh well, guess I'll do it the long way.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: SSH on Tue 15/04/2008 17:20:48
27 hour response too slow for you, eh?

You could add a function to the Dengvat module to iterate over the array(s) and write them to a file. I won't have time to do this in the near future, though.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: EnterTheStory (aka tolworthy) on Tue 15/04/2008 21:58:17
Quote from: SSH on Tue 15/04/2008 17:20:48
27 hour response too slow for you, eh?
Last time you replied in 27 MINUTES! I thought you must be dead or in hospital or something. Really, I was beginning to wonder why I pay you that generous salary for 24/7 service.

Seriously though, thanks for the idea. I'm just being lazy. DeNGVaT is the by far the most useful thing to ever be added to AGS, and I am forever in your debt.
Title: Re: MODULE: DeNGVaT (DEbug, Named Global VAriables & Timers) v1.01
Post by: Gilbert on Wed 16/04/2008 02:08:51
This is a forum, not a chatroom, so be patient to wait for replies, as people are not always online and are standby for your service. Sometimes it may cost days for a reply and that is normal.

Please don't do that again.
Title: Re: MODULE: UltraVariables (formerly DeNGVaT) v1.10
Post by: SSH on Wed 02/07/2008 16:36:59
Well, this has been updated so that the GUI will import into AGS 3.0+ and renamed so that people have a better idea what it does!

Also added:

Global.Dump function to dump all variable and timer values to a file
max setting for Global.Inc to allow increments to automatically stop when they reach the top...
Title: Re: MODULE: UltraVariables (formerly DeNGVaT) v1.10
Post by: EnterTheStory (aka tolworthy) on Sat 05/07/2008 21:18:10
Question: any plans for allowing wildcards? I have a couple of thousand globals, grouped into names like
Global.Set("1_person6_object23",1);
or
Global.Set("1_person7_object99",2);


I frequently reset groups of globals, depending on their initial number. At present I search every global, use 'Contains" and hope that the initial number is not repeated elsewhere in some other global. but it would be nice to be able to write
Global.Set("1_*",0);
or
Global.SetGroup("1_",0);


Any chance...? :)

EDIT: if you're wondering why I don't just use arrays, it's because I pass a lot of data between different games. I have fewer bugs if I stick to one data type. Using SSH's globals is the most flexible option.
Title: Re: MODULE: UltraVariables (formerly DeNGVaT) v1.10
Post by: EnterTheStory (aka tolworthy) on Mon 08/09/2008 15:41:17
I think I found a minor bug in the original DeNGVaT code. It's probably fixed in the enwer version (I'm sticking weith the old version for various reasons) but thought I'd mention it for the record.


String test = Global.Gets("cutscene_waiting"); Display("1 waiting:'%s'",test);
String what = Global.Gets("rightClickedObject");
String test2 = Global.Gets("cutscene_waiting"); Display("2 waiting:'%s'",test2);


result: the second line ERASES the content of 'cutscene_waiting'

workaround: this only happens if 'rightClickedObject' has not been defined. Adding Global.Sets("rightClickedObject",""); at an earlier stage fixes it.

EDIT:
It seems I spoke too soon. On further examination, it appears that, in some circumstances, TWO globals can be stored with the same name. So when you then search for that global, you may access the wrong value. Any suggestions would be much appreciated!

LATER EDIT:
It's possible that the previous problem was caused by a line in the 'find' function. If anyone's interested I'll post more details.
Title: Re: MODULE: UltraVariables (formerly DeNGVaT) v1.10
Post by: SSH on Wed 17/09/2008 17:55:06
As the changelog in the latest version says, this bug was fixed in v1.01.