Digits() error

Posted By: Knuckles

Digits() error - 08/08/07 21:46

What am I doing wrong here? I'm trying to display a player's HP and SP on the screen using digits():

Code:
var HP = 0;
var SP = 1;

var playerstats[2];
var playerstats_level_01[2] = 40, 20;

playerstats[HP] = playerstats_level_01[HP];
playerstats[SP] = playerstats_level_01[SP];


panel player_stats_window
{
layer = 1;
bmap = stats_bg;
pos_x = 15;
pos_y = 500;
digits = 150,55,1,standard_font,1,playerstats[1];
flags = refresh,d3d;

}



string player_stats_string = "HP \n\nSP \n";

text player_stats_text
{
layer = 2;
pos_x = 75;
pos_y = 550;
font = standard_font;
strings = 1;
string = player_stats_string;
}

player_stats_window.visible = on;
player_stats_text.visible = on;




When I try to run the program I get an error that says there's "Too many parameters" for the line that has: digits = 120,48,1,standard_font,1,playerstats[1]; The arrow is pointing to the [1] in playerstats. I'm not sure why...
Posted By: LogantheHogan

Re: Digits() error - 08/09/07 01:11

Hmm... I don't see anything about digits in the code you posted. Maybe you left that part of the code out? Where are you defining the digits, anyway? Inside the player_stats_window definition? Because they're not there... ?
Posted By: Knuckles

Re: Digits() error - 08/09/07 01:39

player_stats_window is just the background image in which the text is written on
Posted By: LogantheHogan

Re: Digits() error - 08/09/07 02:05

Well, then, where are your digits definitions? The digits definitions should be inside the panel definition that they are attached to. Are you defining the digits inside a panel at all?
Posted By: Knuckles

Re: Digits() error - 08/09/07 02:33

Yes I did... sorry I edited the post above, it got deleted out for some reason. The digits() is in the player_stats_window panel
Posted By: LogantheHogan

Re: Digits() error - 08/09/07 04:26

Hmm. My only thought would be to reorganize the digits definition into proper syntax, i.e. digits(120,48,1,standard_font,1,playerstats[1]);. Let me know if that works, if not tell me and I'll switch my brain to high powered debugging mode and take another look.

also, you don't have to display a separate text as well as the panel. Look in the manual for info on how to display text inside a digits element.
Posted By: Knuckles

Re: Digits() error - 08/09/07 04:50

using parentheses in the digits() didn't work. I still get the same error. If I take the [1] off of playerstats, then the program works fine. But why can't I use the brackets? It keeps saying too many parameters. But I want it to get data from the playerstats[] array. Is there another way I will need to do this rather than use digits() ?
Posted By: LogantheHogan

Re: Digits() error - 08/09/07 05:03

According to the manual, under "Digits":

"Only var variables can be displayed (no int, float, or other types of variables). The var can be part of a struct or of an array, but not of a multidimensional array. "

So, your code should work. And it doesn't. You may have discovered a bug? Try the Ask Conitec or Bug Hunt forum, I guess.
Posted By: demiGod

Re: Digits() error - 08/09/07 08:41

There is no bug.

Try this:

digits(150,55,"PlayerStats: %.3f",*,1,playerstats[1]);
Posted By: Knuckles

Re: Digits() error - 08/09/07 21:58

It's still saying 'too many parameters' and pointing to the '1' in [1]
Posted By: demiGod

Re: Digits() error - 08/09/07 22:37

Please, just do it like i told you, it works, ok ?

Code:

var HP = 0;
var SP = 1;
var playerstats[2];
var playerstats_level_01[2] = 40, 20;

// in function main put this:
playerstats[HP] = playerstats_level_01[HP];
playerstats[SP] = playerstats_level_01[SP];

// and now the panel
panel player_stats_window
{
layer = 1;
bmap = stats_bg;
pos_x = 15;
pos_y = 500;
digits(150,55,"PlayerStats: %.3f",*,1,playerstats[1]);
flags = refresh,d3d,visible;
}


Posted By: Knuckles

Re: Digits() error - 08/10/07 00:03


Posted By: Knuckles

Re: Digits() error - 08/10/07 04:36

okay, now it's getting even weirder...

I've been at this for hours now trying to figure it out. I deleted the playerstats[1] in the digits() function and replaced it with 'asdf' and the program ran! but there was just a zero there. The weird thing is that I did not define anything named 'asdf' anywhere in my program yet it still ran!

Code:
digits(30,30,"HP  %.0f",standard_font,1,asdf);



That's what I put and the program ran without me even having to define 'asdf.' Is this a bug or something? how is it that I don't get errors with something undefined, yet, I get errors with the playerstats[1] array?
Posted By: demiGod

Re: Digits() error - 08/10/07 11:27

You are doing something wrong man, i tested the code and it works.

Dont forget to put:

playerstats[HP] = playerstats_level_01[HP];
playerstats[SP] = playerstats_level_01[SP];

in a function, like main for instance.

In your first code you had those instructions outside of function, if you know what i mean..

Hope it helps
Posted By: Knuckles

Re: Digits() error - 08/11/07 03:42

Thank you! It wasn't in a function. What I had to do was to make a separate function called player_stats() and put all those declarations in there then call the function in the main() function. It's wokring now. Thanks so much!
© 2023 lite-C Forums