Working on scrollin log

Posted By: MaximilianPs

Working on scrollin log - 05/21/09 17:16

this things drive me crazy, 'cause i suppose that the langue was a C/C++ based but it isn't so easy :P

STRING myLog = "here we start";
myLog += "\n this isn't a new piece of the string ?";

and also, if i need to attach a value ?

myLog = "Hey you got an healbottle ! ("+ my.skill1 +" of Energy)";

i think that's a realy basic stuff to learn, but i'ven't found any reference about that (maybe i'm searching the worng stuff)
but what i' need to do is a scrolling text with a sort of log that explane what is happening to the player while the game is running, and i'm stucked on this thing from a pair of days.. frown
Posted By: Quad

Re: Lost with string filling dumb - 05/21/09 17:22

what you are trying to is possible in c# i think but not in C.

STRING* mystr = "asdasd";
str_cat(mystr," string to append");

or

str_cpy(mystr," string to replace");

or

char mystr[500];
sprintf(mystr,"Hey you got an healbottle ! %d of Energy",_INT(my.skill1));
Posted By: MaximilianPs

Re: Lost with string filling dumb - 05/21/09 18:15

i was wondering if there is any easy way to made the text inside the TEXT*
to scroll up.

[code]
TEXT* scoll_txt =
{
layer = 999;
pos_x = 19;
pos_y = 729;

size_x = 987;
size_y = 36;

font = "Tahoma#12";
string(txtLog);
flags = OUTLINE | SHOW;
}
[code]

did you remember eye of beholder?

on the bottom of the screen the text scroll up...
that's exactly what i'm trying to do.

so my wish is to have the text on the variable txtLog but to show just a some lines.
Posted By: MaximilianPs

Re: Lost with string filling dumb - 05/22/09 07:57

ok, what i shoul do is:
read the variable, look for \n cause that will identfy the new line, so once i know how many lines there are on my variable, i should remove every hidden lines, and leave just the last 3. this can be a solution.

the best way could be using an Array but i didn't see anything about it on the manual. so i suppose that i can't store each line on an array ?

any other suggestion ?

Posted By: Phonech

Re: Lost with string filling dumb - 05/22/09 10:36

Take a look at the code below. You can scroll the text by using the arrow keys.

Code:
///////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////////////////////////////////////
FONT* arial_font = "Arial#14";
FONT* arial_font2 = "Arial#50";
///////////////////////////////////////////////////////////////
STRING* text_str = "#40"; 
STRING* temp_str = "#40"; 
///////////////////////////////////////////////////////////////
var filehandle;
var i = 0;
var counter;
var k = 0;
///////////////////////////////////////////////////////////////
typedef struct 
{	
	STRING* text;
} AGENTS;
///////////////////////////////////////////////////////////////
AGENTS taskforces[10000];
///////////////////////////////////////////////////////////////
function read_data(); //loads the TextLog
function info_startup(); 
///////////////////////////////////////////////////////////////

PANEL* output_pan =
{	
	digits (6, -3, 1, arial_font, 1, text_str);
	flags = VISIBLE;
	layer = 10;
	red=0;blue=0;green=0;
}

function read_data()
{
	filehandle = file_open_read("text_sample.txt");
	while (i < 10000)
	{
		taskforces[i].text = str_create("");
		if (file_str_read(filehandle, taskforces[i].text) == -1) // reached the end?
		{
			break;
		}
		else
		{
			i++;
		}
	}
	file_close(filehandle);
}


void main()
{
	video_switch(0,0,2);
	vec_set(screen_color,vector(255,255,255));
	read_data(); 
	wait (1); 
}

function info_startup()
{
	wait (-1); // wait until all the data is loaded
	while (1)
	{
		if (key_cud)
		{
			while (key_cud) {wait (1);}
			counter++;
			k = 0;
		}
		if (key_cuu)
		{
			while (key_cuu) {wait (1);}
			counter--;
			k = 0;
		}
		counter = clamp(counter, 0, i-1);
		str_cpy(text_str, taskforces[counter].text);
		wait (1);
	}
}


Don't forget to create the text file named text_sample.txt wich could look like this:

Quote:
Alvssa casts melf's acid arrow.
Bla bla bla bla.
Show me your moves!
It's over 9000!


I hope that helps.
Posted By: MaximilianPs

Re: Lost with string filling dumb - 05/22/09 14:57

thnx a alto smile
i wish to update the screen first, and in a second step i will write the log on a text file, btw, this clear my mind a bit smile
Posted By: Carlos3DGS

Scrolling Log - 06/16/09 00:09

Thanks for the info
© 2024 lite-C Forums