Jump to content

SDF Max value


Lazarus.

Recommended Posts

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.

Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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*.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.)
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...