3 registered members (TipmyPip, AndrewAMD, dBc),
18,430
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
showing part of an array in digit
#377322
07/12/11 08:02
07/12/11 08:02
|
Joined: May 2011
Posts: 46 kleines Kaff irgendwo in Hesse...
Kitsu
OP
Newbie
|
OP
Newbie
Joined: May 2011
Posts: 46
kleines Kaff irgendwo in Hesse...
|
Hi, i have a little problem with showing a part of an array in a digit. while definination and declaration seems to work
STRING * res[6];
res[0] = "640 x 480";
res[1] = "800 x 600";
res[2] = "1024 x 768";
but as i want to show it via
digits(0, 0, " %s", "Arial#16", 1, res[1]);
it shows only "(null)" also unfortunately
str_cpy(resolution, res[num]);
gives me an malfunction says: "Empty pointer in set_res" (set_res is the function called by the button from the panel with the digits above) what i have to do to use the part of the array in the digits and iin other functions without exactly know thwat the player wants and witout writing a new function for each possibility? i hope you can help me with it  greetings ~kitsu
fogman: "Hint: It´s useful to learn to read before you try to write games."
|
|
|
Re: showing part of an array in digit
[Re: Kitsu]
#377326
07/12/11 09:32
07/12/11 09:32
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
STRING * res[6]; //Ok res[0] = "640 x 480"; //No res[1] = "800 x 600"; //No res[2] = "1024 x 768";//No You need to make a function that inits the strings: res[0] = str_create("640 x 480"); res[1] = str_create(..); .. Then, the digits will work 
|
|
|
Re: showing part of an array in digit
[Re: Rei_Ayanami]
#377328
07/12/11 10:07
07/12/11 10:07
|
Joined: May 2011
Posts: 46 kleines Kaff irgendwo in Hesse...
Kitsu
OP
Newbie
|
OP
Newbie
Joined: May 2011
Posts: 46
kleines Kaff irgendwo in Hesse...
|
hmm anyhow the global declared string array isn't grey as the other global strings (and not shown in the code jumper on the right side) also str_create isn't highlighted (?) and if i now call the function which shows the panel containing the digits the engine crashes (also it crahes instantly if the panel is shown at the beginning)
Last edited by Kitsu; 07/12/11 10:08.
fogman: "Hint: It´s useful to learn to read before you try to write games."
|
|
|
Re: showing part of an array in digit
[Re: Kitsu]
#377337
07/12/11 11:46
07/12/11 11:46
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
FONT* fnt_test = "arial#20";
STRING* str_res[6];
PANEL* pnl_res = {
// digits(10, 10, "%s", *, 1, str_res[0]); //wont' work, string is not yet initialised!
flags = SHOW;
}
void main(){
str_res[0]= str_create("600x480");
str_res[1]= str_create("800x600");
pan_setstring(pnl_res, 0, 10, 10, fnt_test, str_res[0]);
pan_setstring(pnl_res, 0, 10, 30, fnt_test, str_res[1]);
}
though you'd be better off using TEXT instead of PANEL
TEXT* txt_res = {
font = fnt_test;
pos_x = 300;
strings = 6;
string("600x480", "800x600", "1024x768");
flags = SHOW;
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|