Jump to content

variables and SDF's


Thralni

Recommended Posts

Now, I found a way to let the game remember a certain variable value for always, even when quitting the game.

 

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

 

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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