The Daily Click ::. Forums ::. Klik Coding Help ::. Alterable Values
 

Post Reply  Post Oekaki 
 

Posted By Message

]Alpha[



Registered
  19/09/2003
Points
  245
11th September, 2009 at 17:15:01 -

Quick question :
Is it possible to have more than 26 alterable values on a single object?
If yes, how can I do it?

Thanks

 
All that I see is the years...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
11th September, 2009 at 17:52:52 -

There's the "Value-Add" extension, which should give any active object unlimited alterable values. I haven't tested it, so I'm not sure how well it works (especially with duplicate objects).

You could also use the alterable strings, if you don't need them for something else.

Finally, you may be able to pack several values into a single alterable value (by converting values to strings, putting them one after the other, and then converting back to a value; or by clever use of the mod function).

Anyway, start with the extension, and let us know if it doesn't work out...

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
11th September, 2009 at 19:30:28 -


Originally Posted by Sketchy
Finally, you may be able to pack several values into a single alterable value (by converting values to strings, putting them one after the other, and then converting back to a value; or by clever use of the mod function)



Yeah, I've used this method in the past. You can use LEFT$, RIGHT$, MID$, VAL, ASC & CHR$ with a string object and do all kinds of cool stuff.

Example: Take a string like "ABCD".

Now say the 2nd positon in that string will be a damage rating of a weapon. You could set a variable called DAMAGE like this-

DAMAGE = Val(Mid$(stringobject(2,0))) - 65

Why 65? Because as I remember it 65 is the ASC valule for the letter "A". So if the damage was zero you could set that part of the string to "A". If the damage was 2, you'd set that value to "C" and so on. In the example above the 2nd place of the string is a "B", which is ASC 66, 66 - 65 = 1 so it's a damage value of 1. But this way would only really work up to a value of 26 so what I've done before is have 2 parts of a string for damage but have a tens place and a ones place.

I guess it all really depends. I used something like this for the Diablo-esque stats on my Equin game before where every item had this big string that the computer sorted through to add / subtract character stats to / from whenever you'd equip or remove it. It can be useful IMO, and it can save you a ton of time not having to make a giant If / Then list for every one of your game's items. This way you could have decent item stat randomization. You could use an object's alt strings and go all kinds of nuts if you wanted to but it might be hard to keep track of all that info.

Edited by Del Duio

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

]Alpha[



Registered
  19/09/2003
Points
  245
12th September, 2009 at 09:09:37 -

Thank you guys.
The valued I need to save are values that will surely be greater than 26, so I think that the string values are not suit for me.

I'd like to see that value-add extension
Do you know where can I find it?
And by the way... why this extension should not work with duplicate objects?

Thank you in advance!

 
All that I see is the years...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th September, 2009 at 12:25:02 -

The reason I thought it might not handle duplicates, is that when you come to retrieve values, the function belongs to the "value-add" object, not the active object itself. That would mean any other conditions relating to the active object, would not apply properly.
I thought maybe it would always retrieve the value from the newest instance, like when you use the "compare two general values" function.

I've tried it out though, and it actually asks you to specify the object's fixed-value, so it will work fine with duplicates

Downloads are here:
http://vps.dynamicarcade.co.uk/downloads/extensions2/ValueAdd/

btw: Del Duio's string method was quite different from mine - you could easily handle values greater than 26. Still, I'd go with the extension unless you find a problem with it, or really want to know...



 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
12th September, 2009 at 15:14:12 -

Yeah that's why I had to use 2 spots on the string for the tens place and the ones place, so the value could be 0-99. Usually for a player's stats that was enough. It was an idea I came up with before I ever really went on the internet, back when I used to live in my hole.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

]Alpha[



Registered
  19/09/2003
Points
  245
12th September, 2009 at 19:14:28 -


Originally Posted by Sketchy

btw: Del Duio's string method was quite different from mine - you could easily handle values greater than 26. Still, I'd go with the extension unless you find a problem with it, or really want to know...



Thank you for the answer.
By the way, what's your method to use alterable strings?
I'd like to know 'cause usually I prefer to avoid extensions.
Do you mind to explain, please?
Thank you in advance
Dany

 
All that I see is the years...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th September, 2009 at 20:02:21 -

My method for using alterable strings?
I really just meant using an alterable string exactly like an alterable value - just using Str$() or Val() whenever you write or read a value. I know it's very wasteful.


The "packing" method seems to be pretty much obsolete now, but it's still nice to know (a good lesson in string manipulation if nothing else).

Let's suppose we have 3 values - A, B, and C.
We'll say that each of these can be any positive integer between 0 and 999 (note: it doesn't work with floats, and requires changes to work with negative integers).
That means when you write the number, it will be up to 3 digits in length.

The first step is to convert each value to a string, exactly 3 characters in length - adding 0s on the front if needed.
Eg: "1" becomes "001", "12" becomes "012", and "123" remains unchanged.

String_A = Right$("00" + Str$( Value_A ), 3)
String_B = Right$("00" + Str$( Value_B ), 3)
String_C = Right$("00" + Str$( Value_C ), 3)

Next, you put them all together - one after the other.
Eg: If A=4, B=55, and C=750, you will get the string "004055750".

String_ABC = Right$("00" + Str$( Value_A ), 3) + Right$("00" + Str$( Value_B ), 3) + Right$("00" + Str$( Value_C ), 3)

Finally, you convert back to a value, rather than a string.
You need to add an extra digit on the front first though - otherwise, if one or more of the initial digits are "0" they will be deleted when the number is stored.
Eg: If A=4, B=55, and C=750, you will get the value "1004055750".

Value_ABC = Val( "1" + Right$("00" + Str$( Value_A ), 3) + Right$("00" + Str$( Value_B ), 3) + Right$("00" + Str$( Value_C ), 3))


So that's how you store the 3 values, but now you need to be able to retrieve them...

All you need to do, is convert back to a string, and select the appropriate block of 3 characters.

Value_A = Val( Mid$( Str$( Value_ABC ), 1, 3))
Value_B = Val( Mid$( Str$( Value_ABC ), 4, 3))
Value_C = Val( Mid$( Str$( Value_ABC ), 7, 3))


All this seems fairly redundant now.
Not only is there the "value-add" extension, but there's the "string parser" extension as well.
Using the string parser, you can store almost limitless numbers in one of an object's alterable strings.
The method is basically the same as what I've described here, but you separate each value by a comma, and use the parser's "tokenizing" functions instead of "Mid$". This way the values don't have to be a fixed number of digits long, and they can be floats or integers, positive or negative.

Edited by Sketchy

 
n/a

]Alpha[



Registered
  19/09/2003
Points
  245
14th September, 2009 at 08:36:51 -

Thank you for the useful explanation.
I really appreciated it!

"All this seems fairly redundant now"
Well, maybe it is... but I really like to get into things to understand how they work.
It's like to be able to build a website using pure HTML instead of using a wizard tool

Thank you again!

 
All that I see is the years...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
14th September, 2009 at 14:32:34 -

No problem

You should take a look at this:
http://www.create-games.com/download.asp?id=7417

It's a tile-based level editor/loader, but it stores *all* the map data in a single alterable value - it uses string functions *a lot*.

I agree on the HTML thing too - I always just use notepad



 
n/a
   

Post Reply



 



Advertisement

Worth A Click