MODULE: UltraVariables (formerly DeNGVaT) v1.10

Started by SSH, Tue 12/12/2006 17:48:08

Previous topic - Next topic

SSH

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
Download UltraVariableshere
DeNGVaT wiki page

Requires AGS 3.00

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

12

RickJ

SSH, sounds like a good idea. 

  • How about adding the ability to modify and/or force values.   I guess the "modify" function is self explanatory.  The "force" function is similar to modify except that a forced value would not be overwritten.  So if you had a value being calculated in the script and written to a global int and then you forced it to a particular value, the script would no longer be able to overwrite and the forced value. The forced value would be retained until the force was removed.

  • How about adding the ability to add or remove individual variables from an on-screen display.  Possibly implemented using an overlay or gui.   

  • How about an on-screen display of mouse coordinates.  Perhaps if the mosue button was held down and the cursor moved then the display could show delta-x and delta-y.

  • How about a debug mouse mode where a right or center click would popup a display of the properties of the item under the cursor.  And wouldn't it be sweet if you could be able to select and modify said properties? 


    That's all I can think of now!   ;D

Rui 'Trovatore' Pires

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.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

Bump, to let you see the first cut of the module is out...
12

monkey0506

Named Timers 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

EnterTheStory (aka tolworthy)

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!

SSH

That should be how it works. What error did you get? Remember you need to put quotes around the names...
12

EnterTheStory (aka tolworthy)

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

EnterTheStory (aka tolworthy)

#8
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.

Code: ags

	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? :)

SSH

Ah, thanks for finding this. I missed a line out of the insertion code...

You can change in the module script:
Code: ags

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


to:

Code: ags

	    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).

12

EnterTheStory (aka tolworthy)

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!

Rui 'Trovatore' Pires

Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

hajo hasn't restored my server yet. Go shout at him...  :(
12

EnterTheStory (aka tolworthy)

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!

EnterTheStory (aka tolworthy)

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?

SSH

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.
12

EnterTheStory (aka tolworthy)

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.

SSH

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:

Code: ags

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


12

EnterTheStory (aka tolworthy)

Thanks for the suggestion.  I'll have a look at that.

EnterTheStory (aka tolworthy)

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?

EnterTheStory (aka tolworthy)

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.

SSH

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.
12

EnterTheStory (aka tolworthy)

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.

Gilbert

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.

SSH

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...
12

EnterTheStory (aka tolworthy)

#25
Question: any plans for allowing wildcards? I have a couple of thousand globals, grouped into names like
Code: ags
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
Code: ags
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.

EnterTheStory (aka tolworthy)

#26
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.

Code: ags

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.

SSH

As the changelog in the latest version says, this bug was fixed in v1.01.
12

SMF spam blocked by CleanTalk