SDF Max value

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: SDF Max value
Lifecrafter
Member # 6193
Profile Homepage #0
What is the highest value that a flag can have? I want to know because I am making a bank in my scenario and all the gold numbers are stored as SDFs, it will be easier to make exact numbers if I don't have to use the second option.

I doubt that the max will be high enough, so I'll probably just set the flag to the gold amount /1000. I assume that it will just round the number down if it comes up with a decimal.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Law Bringer
Member # 4153
Profile Homepage #1
quote:
Originally written by Lazarus.:

What is the highest value that a flag can have? I want to know because I am making a bank in my scenario and all the gold numbers are stored as SDFs, it will be easier to make exact numbers if I don't have to use the second option.

I doubt that the max will be high enough, so I'll probably just set the flag to the gold amount /1000. I assume that it will just round the number down if it comes up with a decimal.

I can't find anything in the docs about any sort of limit.

And a bank that can round off 499 gold? Sounds like a ripoff to me...

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
The Establishment
Member # 6
Profile #2
The logical limit for typical variables would be from 0 to 255. Flags are short variables, I believe.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Agent
Member # 5814
Profile #3
I've heard that the maximum is 256. I can't prove that and I can't find my source for this information, though. Jeff handles SDFs from 0 to 250. To be safe, I'd put the cufoff point there.

To cope with your bank problem, I'd use five SDFs: four which span 250 numbers, and one to count the 1000's place. That way, the player can chose how much money to withdraw or deposit with much more accuracy.

I was planning an open scenario where you have to bribe and extort your way through a city, and each day you would make an ammount of money based on the number of people under your thumb. I realized early on that you would have to handle numbers which might exceed the physical limits of the SDF.

EDIT: You know, I think I'll get back to work on that scenario.

[ Sunday, April 23, 2006 14:12: Message edited by: Dead Weight on the Forums ]

--------------------
quote:
Originally written by Kelandon
Well, I'm at least pretty

Posts: 1115 | Registered: Sunday, May 15 2005 07:00
Lifecrafter
Member # 6193
Profile Homepage #4
The only place I saw a limit was in the call inc_flag() which says the highest legal value is 255. Since this is the call I've been using, its kind of important that it doesn't spass it out.

Anyway I finished the script using the rounding method. The original plan called for being able to transfer money between scenarios. Now I see that this is pretty much impossible(items lose their special class evidently) I'll just have to give out high value items that can be sold to merchants.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #5
The simplest and most accurate thing to do as far as storing large numbers in SDFs is simply use two SDFs as the digits of a base-256 number (or base-250 to stay safely away from maximums). Say, flags (250,0) and (250,1):

set_flag(250,0,coins_amount() / 250); // tens digit
set_flag(250,1,coins_amount() % 250); // ones digit

Thus the total numbers of coins stored is (get_flag(250,0) * 250) + get_flag(250,1).

[ Sunday, April 23, 2006 15:35: Message edited by: Kelandon ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
...b10010b...
Member # 869
Profile Homepage #6
quote:
Originally written by *i:

The logical limit for typical variables would be from 0 to 255. Flags are short variables, I believe.
Flags aren't variables. Flags go from 0 to 255; variables go from -32768 to 32767. Sometimes it's better to use a variable for precisely this reason.

It's possible to "unpack" the value of a variable into two SDFs as Kelandon describes, but doing so probably isn't worth the trouble unless you really, really need to.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Infiltrator
Member # 5576
Profile Homepage #7
One thing that I have had to use the two flag method for is storing tick numbers when I can't be sure that the party will stay in the town or outdoor section that uses the tick number.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
The Establishment
Member # 6
Profile #8
quote:
Flags aren't variables. Flags go from 0 to 255; variables go from -32768 to 32767. Sometimes it's better to use a variable for precisely this reason.
Thuryl -- You have an odd definition of a variable as most computer scientists would disagree. Reals, logicals, strings, double precisions, integers are all types of variables -- a fairly general term. What you mean is that 16-bit integers go from -32768 to 32767. Integer is a type of variable, but it is not to only type, just a convenient one for the application of RPGs. I believe the type of variable in C is called a short, either way an 8-bit integer.

Flags are indeed variables of an 8-bit integer type. It's just that flags are a special kind of variable (well, an element in an array actually) that has been predefined for us by Jeff. Keep in mind, we can define "short" variables that behave just like flags do. We can also define "int" variables that give us more bits. Unfortunately, we cannot define reals that would allow floating point operations.

So the answer is, variables go from *it depends on the type*.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
...b10010b...
Member # 869
Profile Homepage #9
quote:
Originally written by *i:

quote:
Flags aren't variables. Flags go from 0 to 255; variables go from -32768 to 32767. Sometimes it's better to use a variable for precisely this reason.
Thuryl -- You have an odd definition of a variable as most computer scientists would disagree.

Correction: Jeff Vogel has an odd definition of a variable. :P

I know and you know the general definition of a variable, but since we're talking specifically about BoA here, I thought it best to use the definitions in the BoA documentation rather than confuse the issue. What I meant, if you want me to be pedantic, was "What BoA calls a 'flag' is not handled internally in the same way as what BoA calls a 'variable'". Happy now? :P

[ Monday, April 24, 2006 06:09: Message edited by: Thuryl ]

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Guardian
Member # 6670
Profile Homepage #10
Quasi-Topic-Related-Question (because I'm too lazy to start another topic):

I made a creature script that would increment a SDF by the amount of a memory cell when it died. I made the general version first, then a made a specific script for summoned monsters - in INIT_STATE, I used set_memory_cell. I set the increment memory cell to -1 (the SDF kept track of the number of spawned creatures in the dungeon). However, the script didn't work. I redid it using variables instead of memory cells, and then it did work.

So: memory cells cannot be negative? I looked in the docs, and they didn't list anything about the legal range of values.

--------------------
IF I EVER BECOME AN EVIL OVERLORD:
I will make it clear that I do know the meaning of the word "mercy"; I simply choose not show them any.
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Master
Member # 5977
Profile Homepage #11
quote:
Originally written by Kelandon:


set_flag(250,0,coins_amount() / 250); // tens digit
set_flag(250,1,coins_amount() % 250); // ones digit

Thus the total numbers of coins stored is (get_flag(250,0) * 250) + get_flag(250,1).

Yes, that's about what I did in my scenario too. Only I made a cash machine with fixed values, so the player can't choose himself what to put in. he'll always have to choose of three options. I know, its a bit middle-ages, but I'm just a beginner, am I.

--------------------
Play and rate my scenarios:

Where the rivers meet
View my upcoming scenario: The Nephil Search: Escape.

Give us your drek!
Posts: 3029 | Registered: Saturday, June 18 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #12
Din: My guess is that your states weren't being called appropriately. I don't recall ever using a negative value for a memory cell, but I'd be surprised if it weren't possible.

Thralni: A numeric input script already exists. It's really easy to make one.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 2820
Profile #13
I am quite sure that memory cells can be negative. I suggest using print_nums() if you want to make sure once and for all.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Master
Member # 5977
Profile Homepage #14
quote:
Originally written by Kelandon:

Thralni: A numeric input script already exists. It's really easy to make one.
I KNOW

--------------------
Play and rate my scenarios:

Where the rivers meet
View my upcoming scenario: The Nephil Search: Escape.

Give us your drek!
Posts: 3029 | Registered: Saturday, June 18 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #15
That was an odd reply.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Master
Member # 5977
Profile Homepage #16
I'm sorry. It was just the first thing that came up to me when I saw that post.

Basically I hate it when I'm proud of something I actually managed to make, being a complete beginner, and immediatly somebody says that there are better things.

I'll get over it, don't worry. At least one day I will.

--------------------
Play and rate my scenarios:

Where the rivers meet
View my upcoming scenario: The Nephil Search: Escape.

Give us your drek!
Posts: 3029 | Registered: Saturday, June 18 2005 07:00
Off With Their Heads
Member # 4045
Profile Homepage #17
My point was that you can take your script and modify it slightly by copying and pasting something that already exists, and you'll have an even better script. I'm not saying that your script is bad; I'm saying that it would be easy to make it even better.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Master
Member # 5977
Profile Homepage #18
quote:
Originally written by Kelandon:

My point was that you can take your script and modify it slightly by copying and pasting something that already exists, and you'll have an even better script. I'm not saying that your script is bad; I'm saying that it would be easy to make it even better.
I know, you (of all people) have seen it time on time again in "the topic," that I jump to conclusions to fast, and that way make mistakes.

--------------------
Play and rate my scenarios:

Where the rivers meet
View my upcoming scenario: The Nephil Search: Escape.

Give us your drek!
Posts: 3029 | Registered: Saturday, June 18 2005 07:00
Lifecrafter
Member # 6193
Profile Homepage #19
A numeric input script, I was thinking about writing something like this involving inputing 5 numbers, then checking each one to see which digit it returns. I went the lazy route, but I might change it.

This is the real question, I want you to be able to ask the banker how much gold you have in the bank. This is the code I have so far (it works fine, so don't bother proof reading it.)
quote:
clear_buffer();
append_string("You currently have ");
append_number(get_flag(3,3) * 1000);
append_string(" gold in the bank.");
get_buffer_text(gold_str);
print_str(gold_str);
break;
The problem is that this prints it in the text area, which can't be viewed when speaking to someone. I want it to appear in the dialog node, or a dialog box. (I hope I was clear and used the right terminology.)

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
...b10010b...
Member # 869
Profile Homepage #20
message_dialog(gold_str,"");

You can just plug in a string variable wherever you would normally use a text string, the same way you can plug in a regular variable wherever you would use a number.

[ Tuesday, April 25, 2006 14:59: Message edited by: Thuryl ]

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Off With Their Heads
Member # 4045
Profile Homepage #21
The numeric input script, by the way, can be found in the High Level Party Maker, in town 2, in state 12. If you want to use it, feel free.

For displaying specialized text in dialogue, do the same thing, but use message_dialog instead of print_str. (EDIT: Which is what Thuryl said a minute before me. Darn him. Darn him to heck.)

[ Tuesday, April 25, 2006 14:59: Message edited by: Kelandon ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Lifecrafter
Member # 6193
Profile Homepage #22
Thank you.

If I do use the number input (which I'm starting to think I will) it will probably look like the script in hlpm. But since it will be checking for very large numbers, I will use ten-thousands place, thousands place, etc. Then check for 0-9 for each place and dump it into an sdf. As I think about it I'm beginning to realize it shouldn't be that hard.

It'll also will use the base 255 system as suggested. My brain is so hard-wired in base 10 that it took me a while to figure it out, now I see that this is a lot cleaner.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00