Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Help!
Help!
2001-09-30, 7:58 AM #1
Normally I wouldnt post a question, but for the life of me I cannot figure this out.

I have a rudimentary scoring cog, and I want to display the score in mats on a wall. The problem is turning a number that can be up to 4 digits into 4 separate numbers for the mat cels. Any expirance anyone has in this area would be appreciated.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-02, 9:29 AM #2
???
And when the moment is right, I'm gonna fly a kite.
2001-10-02, 1:20 PM #3
If I got that right, that'd be pretty easy, given that your score is stored in an INT to trace the score, which I guess. That's the way I'd do it :
Code:
mat1_value=current_score/1000;
mat2_value=(current_score-mat1_value*1000)/100;
mat3_value=(current_score-mat1_value*1000-mat2_value*100)/10;
mat4_value=current_score-mat1_value*1000-mat2_value*100-mat3_value*10;

That'd split up the score in 4 INTs, so you'll get away with 40 IFs, instead of 9999. Hope this does give you the idea.
Maverick
2001-10-02, 1:56 PM #4
Thanks for the code, maby I have a chance after all. About the IFs, I could always run 9999, inside a FOR loop. Hmmmmmm...

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-02, 3:29 PM #5
You could easily use an array to do it, in a very small amount of code.
2001-10-02, 3:30 PM #6
So I thought... Ive been at it for weeks, I still cant get it.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-02, 4:05 PM #7
This is my current method:

Mat3 = Score/1000;
Mat2 = Score-(Mat3*1000)/100;
Mat1 = Score-((Mat2*100)+(Mat3*1000))/10;
Mat0 = Score-((Mat1*10)+(Mat2*100)+(Mat3*1000));

Only "Mat3" is working, the rest do not. If there is something Im missing, I still dont get it. Im thrashing my head against the wall here, if anyone can help...

[Edit: This is assuming a 4 digit number...]

------------------
Success is the inverse relationship between effort, gain, and loss.

[This message has been edited by GBK (edited October 02, 2001).]
And when the moment is right, I'm gonna fly a kite.
2001-10-02, 5:20 PM #8
What the heck are all those brackets in there for !
2001-10-02, 5:26 PM #9
To seperate the math out... Ive tried it all ways.

I still dont get it. There has to be someone out there with expiriance in this. Why do you not assist? I am begging!
Please!
And when the moment is right, I'm gonna fly a kite.
2001-10-02, 5:55 PM #10
SUCCESS!

My new method:

Mat3 = Score/1000;
Mat2 = (Score % 1000) /100;
Mat1 = (Score % 100) /10;
Mat0 = (Score % 10);


It works. But only for 4 digit numbers. I need to refine it for smaller numbers. Why does the JKspecs not list the % operator?

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-03, 12:59 AM #11
Didn't know that could be done that way. But not totally, huh? Well, let me give you a little hint for your maths. Your code mentioned above :
Code:
Mat3 = Score/1000;
Mat2 = Score-(Mat3*1000)/100;
Mat1 = Score-((Mat2*100)+(Mat3*1000))/10;
Mat0 = Score-((Mat1*10)+(Mat2*100)+(Mat3*1000));

That's wrong... very wrong, would've earned a five in maths. This would've been the right way:
Code:
Mat3 = Score/1000;
Mat2 = (Score-(Mat3*1000))/100;
Mat1 = (Score-(Mat2*100)-(Mat3*1000))/10;
Mat0 = Score-(Mat1*10)-(Mat2*100)-(Mat3*1000);

See the what a diffrence brackets at the wrong positions can do? Brackets do very much matter if you want to subtract before dividing... basic mathematics, just keep them in mind when doing something like that.

[This message has been edited by Maverick (edited October 03, 2001).]
Maverick
2001-10-03, 5:04 AM #12
This code works, for ANY number, up to and including 9999:

Mat3 = Score % 10000 / 1000;
Mat2 = Score % 1000 / 100;
Mat1 = Score % 100 / 10;
Mat0 = Score % 10;

Thanks for the help!

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-04, 3:38 AM #13
How would you use an array to do that?
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-10-04, 5:42 AM #14
Might be I'm wrong, but I think I remember reading somewhere around here that you have to define each entry of the array seperatly.
Code:
int mat[0]
int mat[1]
int mat[2]
...

Can somebody please confirm this?

And how'd you do it with that? Well... exactly the same way as above I'd guess.

[This message has been edited by Maverick (edited October 04, 2001).]
Maverick
2001-10-04, 5:59 AM #15
Define arrays like this:
Code:
int     integer     local
int     integer1    local
int     integer2    local

And use: integer[int]

You can also do:
Code:
int     integer0    local
int     integer1    local
int     integer2    local


And then use: integer0[int]

------------------
Fiction must be more realistic than truth or no one will believe it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-10-04, 9:04 AM #16
This is my method:


Symbols
Message Any
Surface Wall0
Surface Wall1
Surface Wall2
Surface Wall3
Int Mat0=0
Int Mat1=0
Int Mat2=0
Int Mat3=0
Int Score
Int I=0
End
Code


//Some message...

Mat3 = Score % 10000 / 1000;
Mat2 = Score % 1000 / 100;
Mat1 = Score % 100 / 10;
Mat0 = Score % 10;
For(I=0;I<=4;I=I+1) { Setwallcel(Wall0, Mat0); }
End


And it works. Im sure there are other ways, but this one works fine for me...

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-05, 4:30 AM #17
Seifer, help or stop disturbing...

------------------
http://millennium.massassi.net/ - Millennium
2001-10-05, 11:24 PM #18
Quote:
<font face="Verdana, Arial" size="2">Seifer, help or stop disturbing...</font>


Hmmm ??? , I was bearly asking what the brackets were there for, I didnt really know , I thought you could do the same thing without them, oh well.

[EDIT: Opps I see what you mean, I must of put the wrong sign in, sorry /EDIT]

[This message has been edited by *_Seifer_* (edited October 06, 2001).]

↑ Up to the top!