Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: monkey0506 on Tue 11/07/2006 06:14:30

Title: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: monkey0506 on Tue 11/07/2006 06:14:30
The Properties module provides methods for the user to create, edit, and delete custom properties via the script at run-time.

06 October 2008

Okay, I'm fairly certain this is the last major bug fix. Originally the point of eProperties_MaxRooms was to prevent the property functions being used in rooms numbered higher than that, but I forgot one line of code (in 12 places!) and it would crash the game if you didn't manually specify a room while the player was in an unsupported room.

I've also implemented default interaction methods. In the included documentation they're listed at the very bottom with a special note that they are only included pending the definition of the PROPERTIES_DEFAULTINTERACTION macro (which is defined by default). This defines the property DefaultInteraction to simplify the process for games which would like the ability to define default interactions (for example, the default for the property is eModeWalkto but for oDoor you may want to change the default interaction to eModeOpen (SCUMM interfaces) or eModeInteract).

05 October 2008

No point bumping this thread again, I'll just put the update here and be on my way. I realized in using the module that I'd mucked up the inventory functions which have now been fixed. Unlike Characters, InventoryItems are indexed from one not zero. All the room-based functions are handled differently anyway and are unaffected. But it's been fixed as of v3.11.

30 September 2008

This isn't a major update over v3.0, but there are some important changes. The module now defines static limits on the number of properties. These can be changed, but if you're going to change them you should read the included documentation/commentation first.

Also, you can once again delete properties. Instead of "removing" the entry, I simply reuse the slot and keep track of the lowest available slot number.

Aside from that this release is largely the same as 3.0. If you have any questions, comments, or otherwise, feel free to post or PM me. -monkey

[Module Pros:]


[Module Cons:]



Download here (http://monkey.05.06.googlepages.com/Properties_312.rar) (Requires AGS v3.1.0 or higher)
View the manual online (http://www.americangirlscouts.org/agswiki/Properties)
v3.0 Mirror 1 (http://www27.brinkster.com/meleepta/ags/Properties_3_0.rar)
v3.0 Mirror 2 (http://www.2dadventure.com/ags/Properties_3_0.zip) Thanks again Neole!
Download v2.0 (http://www.meleepta.com/ags/Properties_2_0.rar) (for use with AGS 2.72)
Mirror v2.0 (http://www.2dadventure.com/ags/Properties_2_0.zip) Thanks Neole!
Mirror v1.0 (http://www.americangirlscouts.org/agsresources/AGS%20resources/Modules/Properties_1_0.rar) Thanks jasonjkay!

For more information on what custom properties are, RTFM n00b! (http://www.adventuregamestudio.co.uk/manual/Custom%20Properties.htm) :=
Title: Re: MODULE: Properties v. 1.0
Post by: jasonjkay on Tue 11/07/2006 12:53:56
Sounds great, ill add it to my site.
Title: Re: MODULE: Properties v1.0
Post by: SSH on Wed 26/07/2006 10:10:20
It would be great if there was a way for this module to scan through the Properties from the schema editor at game and room load and automatically copy these in...
Title: Re: MODULE: Properties v1.0
Post by: monkey0506 on Sun 30/07/2006 03:44:11
AFAIK there isn't a way to do that...is there???

If there is that would be great. But...I don't seem to see any type of function to check if a property with a certain name exists or what said property would already be applied to if it did exist...?

If you know something I don't...please tell. Unless of course you're just saying it would be nice to not have to manually transfer all your existing properties. :P
Title: Re: MODULE: Properties v1.0
Post by: SSH on Sun 30/07/2006 08:44:10
In the meantime, you could have a function that took a comma-separated String that was a list of properties to load from the schema...
Title: Re: MODULE: Properties v1.0
Post by: Kweepa on Sun 30/07/2006 16:14:35
Or save yourself the parsing trouble and just call the function once for each property.
Title: Re: MODULE: Properties v2.0 - Updated 19 September 2006
Post by: monkey0506 on Tue 19/09/2006 19:28:12
*bump for update!*

I've included the changelog for version 2.0 in the first post, and I mentioned that this was a major rewrite of the module. What I forgot to mention there though was that v2.0 saves memory as well! You'll save 360 KB on your compiled EXE's size just by replacing v1.0 with v2.0, and an additional 4 KB per property. Unfortunately* all the functions for setting the properties have been revised, so you'll have to rescript all those parts. However I never actually got word anyone was actually using this...so hopefully it won't cause too many problems. ;)

~Cheers guys!

*It's only unfortunate if you were actually using the module. The new function list is much more reasonable and much more manageable as well.
Title: Re: MODULE: Properties v3.0 - Updated 17 January 2008
Post by: monkey0506 on Thu 17/01/2008 07:51:21
Well folks I've done it again. I've completely changed just about every function this module implemented. 8)

But I did it with good reason. With AGS 3.0 right around the corner I knew I'd better sneak this in there pretty quick. Now using dynamic arrays and extender methods, this is looking better than ever. I realize at this point that I've never provided any example code of how this works, and any new users who might be interested in the script would probably benefit from this.

The first thing we'll need to do is create some properties. One common example might be implementing a "Health" property for your Characters. So to create the "Health" property we would do this:

// inside of game_start in your global script
Properties.CreateProperty("Health", 100); // create a new number property called 'Health' with a default value of 100


That's simple and straightforward enough. Next we'll need to see how our properties are used. Say our player drinks a potion:

// interaction for player drinks potion
player.SetCustomProperty("Health", player.GetCustomProperty("Health") + 15); // player drank potion, add 15 hp


You can also use text properties, just look up the function in the provided manual.
Title: Re: MODULE: Properties v3.0 - Updated 17 January 2008
Post by: Rui 'Trovatore' Pires on Thu 17/01/2008 09:45:33
Very nice. However, I get only a 404...
Title: Re: MODULE: Properties v3.0 - Updated 17 January 2008
Post by: monkey0506 on Thu 17/01/2008 09:48:38
Damn it. They finally got around to upgrading my server. Which means they'll be formatting it now. Blasted free hosting. I'll upload it to some of my other free accounts. := And possibly try to remember the links for those AGS-based hosting solutions...
Title: Re: MODULE: Properties v3.1 - Updated 30 September 2008
Post by: monkey0506 on Tue 30/09/2008 09:48:53
Dear Warning,

  Thank you for your concern. However, I am sure that I wish to reply to this thread to promote awareness that a new version of my module has been uploaded.

Thank you,

monkey_05_06


(aka, BUMP FOR UPDATE!)

The module's back up, with a fix. v3.0 had a slight bug in it if you wanted more than...I believe just a few properties. So for anyone wishing to use this module (including myself, yay!), it's now available once more for download (of course it has been via the mirrors, but I'd been meaning to release a bug-fix anyway). ;)
Title: Re: MODULE: Properties v3.11 - Updated 05 October 2008
Post by: incobalt on Mon 06/10/2008 02:53:07
I'm really looking forward to using this.  I did want to say that while you mention that the module requires 3.02 AGS or higher, it looks like it's actually using the 3.0.1 beta.  I had to change IndexOf to Contains in order to use it on my non-beta AGS (the beta changed it to IndexOf back in beta 1, apparently: "* Renamed String.Contains to String.IndexOf to reduce confusion with other languages such as Java and C#. String.Contains will continue to work as well for the foreseeable future").  Just thought you might like to know and others might if they also get this problem when trying to compile their games.
Title: Re: MODULE: Properties v3.11 - Updated 05 October 2008
Post by: monkey0506 on Mon 06/10/2008 03:26:41
Sorry about the confusion there. For the record, you are right. I simply forgot that I was using that. I didn't think I was using any of the new features introduced by the BETA but I completely overlooked that one. Thanks for the report!

Also, it's not clearly documented but just because it was something I encountered today, eProperties_MaxRooms should always be higher than the actual number of rooms in the game. I would normally decrease the room index by 1 like I did for InventoryItems, except it is possible to be in room 0 (at least AFAIK, intro.crm would return 0 from player.Room).
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Crimson Wizard on Fri 05/03/2010 17:05:57
I have a suggestion to follow latest changes in AGS and make properties be applied to different types of game elements if only explicitly told to; in other words there should be separate properties for Rooms, separate for Objects, etc.

By the way, a little offtop, perhaps, but aren't there any plans to allow intrinsic AGS properties be changed during runtime?
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: monkey0506 on Sat 06/03/2010 06:35:46
I'm sorry but I don't understand exactly what you mean..are you referring to the idea that properties should be applied separately for different types (each with their own list of properties) as opposed to the current implementation where there is one list of properties that can have values set by the actual items using them?

If so, I have no intention of adding that functionality to my module any time in the near future.

As for allowing custom properties (the built-in, user defined properties) to be edited at run-time that has been discussed several times, but I've never seen CJ make any remark to the effect that it was something he considered high priority. So, I wouldn't be holding my breath on that personally.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Worse_Username on Thu 04/07/2013 17:53:02
Hello, I'm having some trouble with the module. There were no apparent problems when importing it, the autocomplete feature immediately started suggesting functions from the module. But I can't get the Properties::Create function to work. I've tried it multiple times in different ways to no avail.
Eventually I've managed to conclude, that the function simply doesn't work. For example, I assigned this code to an object interaction:
Code (AGS) Select
Properties.Create("p", 100);
Display ("Does p exist:%d", Properties.Exists("p"));

It displays "Does p exist:0". This left me completely dumbfounded. Why would something so simple not work? There doesn't seem to be anything similar to my problem in this thread.

I've tried the above code without creating any other custom properties through script or even AGS GUI. I'm using the latest versions for both this module (v3.12) and AGS (3.2.1). I'm running it on Windows XP.

Is this a bug or am I still missing something? Thanks.

Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Ghost on Fri 05/07/2013 00:09:14
Quote from: Worse_Username on Thu 04/07/2013 17:53:02
Is this a bug or am I still missing something? Thanks.

The %d token displays an integer, but "p" is a string. Try %s instead to see if the proper value is returned.

Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Kitai on Fri 05/07/2013 08:01:47
Quote from: Ghost on Fri 05/07/2013 00:09:14
The %d token displays an integer, but "p" is a string. Try %s instead to see if the proper value is returned.
No, it's not the problem: the Exists (http://www.adventuregamestudio.co.uk/wiki/Properties#Properties.Exists) method of this module gives you a bool. In AGS you can display the value of a bool in a string by supplying it as a %d.
But Worse_Username, you can directly check for the value that Create (http://www.adventuregamestudio.co.uk/wiki/Properties#Properties.Create) returns, which is -1 if the property was not created.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Worse_Username on Fri 05/07/2013 15:57:49
Managed to solve the issue. Apparently, MaxProperties being set to 1 by default was causing it. After setting it to a higher value everything started working.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: monkey0506 on Sun 07/07/2013 01:04:36
..why would MaxProperties have been set to 1 by default? What was I thinking?? Glad you got it sorted. ;)
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Khris on Mon 08/07/2013 19:30:44
The fact that you left MaxProperties set to 1 filled me with unfathomable rage.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Calin Leafshade on Tue 09/07/2013 12:32:16
I bet it's because no one appreciates him and because he hates CJ.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: HandsFree on Sat 05/10/2013 20:34:24
I'm afraid I need help with this too.
In global script I have
Code (ags) Select

function game_start() {   
  Properties.Create("testproperty", 1);
}


Then in a room script
Code (ags) Select

function hCurtain_Look()
{
  int i = hCurtain.GetCustomProperty("testproperty");
  Display("The testproperty is %d.", i);
  cEgo.Say("Strange place for a curtain.");
  hCurtain.SetCustomProperty("testproperty", 2);



When I look at the curtain it says "The testproperty is 1". But when I look a second time I expect the property to be 2, but it's still 1.
What am I doing wrong?

The maxproperties was still 1 BTW but I set it to 10. 
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: monkey0506 on Sun 06/10/2013 09:08:55
Seeing as it's been 5 years since I wrote this code, it wouldn't surprise me if none of it even worked. I'm a terrible coder. (laugh) You don't appear to be doing anything wrong. If I get a chance I'll see if I can look through the source and make any sense of it.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: HandsFree on Sun 06/10/2013 10:02:50
Thanks, I hope you/we/I can get it working cause this is one module that's really very useful to me. I'm using 3.2.1. btw.
Are there plans to incorporate this in a future AGS version?
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: monkey0506 on Sun 06/10/2013 21:07:05
There have been some builds that allow editable runtime properties that would deprecate this module. I'm not certain if that's been incorporated into the 3.3.0 betas or not.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: Crimson Wizard on Sun 06/10/2013 21:14:00
Quote from: monkey_05_06 on Sun 06/10/2013 21:07:05
There have been some builds that allow editable runtime properties that would deprecate this module. I'm not certain if that's been incorporated into the 3.3.0 betas or not.
No, it was in 3.4.0 alpha only. That required changing savedgame format, and back then I was trying to keep format compatible with 3.2.1 in 3.3.0 branch... Now I am not sure it was so wise actually. Well, I seem to fail at planning.
Title: Re: MODULE: Properties v3.12 - Updated 06 October 2008
Post by: HandsFree on Mon 07/10/2013 12:07:00
Got a bit further with this.
The eProperties_MaxRooms was set to 2, so I set it to 100 and now the testproperty displays as 1 the first time and 2 the second time.
BUT the third time it's 1 again and the 4th time it's 2 etc.

I added some displays and I see that this line in the SetCustomProperty function gives a different value every time I click on the curtains:
Properties_Hotspots[pID] = Properties_Hotspots[pID].SetVectorValue(Properties_HotspotFormat, this.ID, String.Format("%d", value));

Maybe there's something wrong in this function?