variables and SDF's

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: variables and SDF's
Master
Member # 5977
Profile Homepage #0
Now, I found a way to let the game remember a certain variable value for always, even when quitting the game.

if (get_flag(250,1) > 0) {
tick1 = get_flag(250,1);

if (get_current_tick() == tick1 + 10) {
if (get_flag(33,2) == 1) {
message_dialog("","");
set_flag(33,0,1);
}
}
}
Now the problem is, the message_dialog doesn't appear after 10 ticks. maybe the code simply deosn't work, I don't know how ticks work, or there is again such a bug which I have never heard off. what i do know, is that after ten ticks (ten paces which I made with my party) the message_dialog doesn't show.

the above code stands in the scenario script. the flag is set in the town script:

if (get_current_tick() >= 29990) {
set_ticks_forward(-15);
}

if (get_current_tick() == 0) {
set_ticks_forward(1);
}

tick1 = get_current_tick();
set_flag(250,1,tick1);
set_flag(33,2,1);
end();
I really hope its not something with bugs or my code that can't work that way. not that I thought that long about it, but it would be a pitty if it didn't work.

--------------------
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
Post Navel Trauma ^_^
Member # 67
Profile Homepage #1
Please post the whole script. In the meantime, try changing '== tick1 + 10' to '>= tick1 + 10'.

--------------------
Barcoorah: I even did it to a big dorset ram.

New Mac BoE
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Master
Member # 5977
Profile Homepage #2
Whole town script, whole scenario script, or both?

I was thinking, the number of ticks can be 29999. A SDF can't get higher then 30, can it?

--------------------
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
The Establishment
Member # 6
Profile #3
Remember that flags can only be from 0 to 255, you can think of them as a "short" variable whereas the ticks are integers. It's not too hard to fix this, but keep it in mind. This may be a problem, but I am unsure.

On your first bit of script, try putting the right hand side of the conditional in parenthesis. In other words (tick1 + 10). Also, as pointed out before use >= instead of == as it is less limiting.

A good way to test these things is to use the print_num() command on relevant variables like tick1 and get_current_tick to find out what the computer thinks the actual value is on each move. This would make things a little more transparent.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Master
Member # 5977
Profile Homepage #4
Okay, thanks. I thought the values of a flag could only be from 0 tp 29, actually. At least, that's what it said in the docs.

I think I know how to fix this, but is it possible to have a value SDF value which is not even? So something like 29.999? i suppose not. In that case it will be just a little more complicated, or, no. Actually not, only I'll have to type a bit more.

--------------------
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
Shock Trooper
Member # 932
Profile #5
If you are asking about what number a SDF is referenced by: you can have SDFs ranging from 0,0 to 299,29.

If you are asking what is the largest number that can be stored? Then I'm not sure. It would most likely be a byte (0-255), a short integer (0-65535), or a long integer (0-4294967295). (The numbers used in ranges are assuming they are unsigned, of course.) I would say that anything under 100 would be a safe bet though.

--------------------
Microsoft Patents Ones, Zeroes (March 25, 1998)
"Asians are good at Starcraft because they're always squinting, thus they can see things sharply. Remember to always squint in war." ~ Sun-Tzu
Posts: 215 | Registered: Sunday, April 7 2002 08:00
Master
Member # 5977
Profile Homepage #6
I mean the second thing you mentioned, Cpeters. the docs don't say anything about it, for as far I saw.

Now I also want to know for ance and always what the difference exactly is between a "short" and an "integer" variable. After looking in the docs, I thought it was the same, or I didn't understand what Jeff was trying to tell me.

--------------------
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
Shock Trooper
Member # 932
Profile #7
In the C/C++ programming language there are differences between a short integer and a long integer. In Avernumscript there are no long integers. The keywords "int" and "short" are synonymous, but "int" is two characters shorter. If you are die hard on trying to reduce a script's file size, decalare number variables as ints rather than shorts.

Shorts are also something you can wear. For more information, see verse 3 of revelations, or consult your dentist.

--------------------
Microsoft Patents Ones, Zeroes (March 25, 1998)
"Asians are good at Starcraft because they're always squinting, thus they can see things sharply. Remember to always squint in war." ~ Sun-Tzu
Posts: 215 | Registered: Sunday, April 7 2002 08:00
Master
Member # 5977
Profile Homepage #8
Okay, thanks. Now I saw this expression in the docs: %. of what is written to clarify it, I don't understand a thing. what exactly does it do? And when I divide, does the program automatically round off, or is there a call I should use to let it do that?

You see, the main thing is, I think, that when I use ticks, the number is almost always far to big for the SDF. I'm trying to find a way to reduce the amount of ticks, without recking the whole scenario, but that it does fit in the SDF. If there are any suggestion, please! I';m running low on energy.

I don't think an integer is something that is comfortable when wearing. Shorts, are indeed nice, but not in this weather. How about longs?

--------------------
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
Shock Trooper
Member # 932
Profile #9
quote:
Originally written by Thralni, chicken god prophet:

...I saw this expression in the docs: % ...what exactly does it do?
That is the modulo. You use it when you want to divide something and get the remainder.

quote:
Originally written by Thralni, chicken god prophet:

...when I divide, does the program automatically round off...?
Yes, division in Avernumscript automatically rounds things off.

quote:
Originally written by Thralni, chicken god prophet:

You see, the main thing is, I think, that when I use ticks, the number is almost always far to big for the SDF. I'm trying to find a way to reduce the amount of ticks, without recking the whole scenario, but that it does fit in the SDF. If there are any suggestion, please! I';m running low on energy.
You can try using multiple SDFs, use one to store thousands, one to store hundreds, etc. You would need to use both the / and the % operators to prevent losing ticks. It would be a cumbersome method, but would be less of a kludge than the other idea I had - don't ask about it, I've actually already forgotten it.

quote:
Originally written by Thralni, chicken god prophet:

...How about longs?
Are you mad? It's summer! Oh, wait, you're one of them northern hemisphere types, ain't ya?

--------------------
Microsoft Patents Ones, Zeroes (March 25, 1998)
"Asians are good at Starcraft because they're always squinting, thus they can see things sharply. Remember to always squint in war." ~ Sun-Tzu
Posts: 215 | Registered: Sunday, April 7 2002 08:00
Master
Member # 5977
Profile Homepage #10
So what does % actually do? I know what the "remainder" is in normal language (Like the remainder of the people), but what exactly is it in numbers? In the doc it says: 15 % 5 = 0. huh? and 8 % 3 = 2. huh? i think you understand very well now that I have no idea whatsoever what it exactly does. I know, I'm a pain, but could you explain it please?

I was thinking to about multiple SDF's, like a sort of binary code (or whatever its called in English). I'll try that, but I'll have to think about for some time before I start doing anythin about it.

And yes, its winter in Holland. I suppose you are am Aussi/African/South American?

--------------------
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
Post Navel Trauma ^_^
Member # 67
Profile Homepage #11
You could split them up, like so:
tick1 = get_current_tick();
set_flag(250,1, tick1 / 256);
set_flag(250,2, tick1 % 256);
and read them back with:
tick1 = get_flag(250,1) * 256 + get_flag(250,2);

--------------------
Barcoorah: I even did it to a big dorset ram.

New Mac BoE
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Master
Member # 5977
Profile Homepage #12
Thanks, Khoth! I'll try it immeditaly.

okay, i think I'm starting to understand the "%" thing. Correct me if I'm wrong:

18 % 6 = 0 right?

18 % 4 = 4 right?

So what happens is, that the program devides, but stops devidinbg when he won't get an even number. Instead it stops and checks the remainder and returns it. Am I right?

--------------------
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
Post Navel Trauma ^_^
Member # 67
Profile Homepage #13
18 % 4 = 2
x % y = the remainder if you divide x by y

--------------------
Barcoorah: I even did it to a big dorset ram.

New Mac BoE
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Shock Trooper
Member # 932
Profile #14
Late again. And Khoth said it better too.

[ Wednesday, January 04, 2006 10:42: Message edited by: CPeters ]
Posts: 215 | Registered: Sunday, April 7 2002 08:00
Master
Member # 5977
Profile Homepage #15
Khoth, thanks a bunch. It works. thanks to both of you, Khoth and Cpeters. Thanks a lot.

18 % 4 = 2, yes, of course. don't know why I typed 4, probably because it was getting late. To make sure I understand the principal:

24 % 7 = 3, right?

--------------------
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
Shock Trooper
Member # 932
Profile #16
Yup.

--------------------
Microsoft Patents Ones, Zeroes (March 25, 1998)
"Asians are good at Starcraft because they're always squinting, thus they can see things sharply. Remember to always squint in war." ~ Sun-Tzu
Posts: 215 | Registered: Sunday, April 7 2002 08:00
Master
Member # 5977
Profile Homepage #17
Thanks, another problem tackled. See you later with the next question (that's in an hour, probably).

--------------------
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
...b10010b...
Member # 869
Profile Homepage #18
Anything % 10 is just the last digit of the number, and anything % 100 is the last two digits.

(i - (i % 100)) is i rounded down to a multiple of 100. Should come in handy if you're doing what I think you're doing (although actually, I think BoA always rounds down when doing division, so it isn't necessary to round manually if you're then going to be dividing by 100 anyway).

[ Wednesday, January 04, 2006 23:50: Message edited by: Thuryl ]

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Master
Member # 5977
Profile Homepage #19
I'm struggling to understand what exactly you mean here. what I understand from what you say, its this:

569 % 10 = 9?

--------------------
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
...b10010b...
Member # 869
Profile Homepage #20
Exactly. Because if you divide 569 by 10, it divides 56 times and the remainder is 9. So 569 % 10 = 9.

(And 569 % 100 = 69.)

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Master
Member # 5977
Profile Homepage #21
Okay. Thanks for that advice. Now that I look at iy a second, time, it's actually quite logical. Funny I didn't see it quicker.

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