Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, howardR), 472 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Three more questions #444826
08/19/14 16:09
08/19/14 16:09
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
As I continue developing my small project farther, I've faced some questions answers for which I couldn't find at all.

FIRST QUESTION is about mouse events... EVENT_TOUCH, EVENT_RELEASE and EVENT_CLICK. Well everything works and almost everything is clear, but I would like to know, how to make mouse ignore specific entities? I couldn't find anything about this in the manual (maybe I've searched bad/wrong), and I really hope that this is possible. The thing that I need this for (as an example). We have a house, that is covered with the roof. Player walks inside of the house, so the roof gets translucent and we can click on objects inside of the house, but problem is, that even if the roof model has PASSABLE flag on, mouse can't detect objects below..

SECOND QUESTION is about text and probably about max. size of the string (maybe set by default?). The thing is, that I'm working on some kind of a journal (diary?) so all picked up notes are stored in it. It open ups a .txt file, fins the text (by it's ID and page) that we need to display. But so far I've noticed that only about 300 letters are displayed.. Why? I've set 'size_x' and 'size_y' for the TEXT, and it has only one string to be displayed. Why this happens?

THIRD QUESTION is still about TEXT stuff.. and this time about '\n' thing.. As far as I know thing THING splits the string so the rest of it (till end, or delimiter or next THING) starts from the next line (below). But I've found out, that when I read text from a .txt file into the string, this THING doesn't work.. I wonder why? I've set delimiter to ';', could that cause any trouble?



Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444829
08/19/14 16:28
08/19/14 16:28
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
For the first question: You can set the entities UNTOUCHABLE flag.

The second question: Please post your code.

Third question: the delimiter is just a character that causes the file_read_string instruction to stop at that specific character. What exactly is the problem? Is it ignored?


Always learn from history, to be sure you make the same mistakes again...
Re: Three more questions [Re: 3run] #444832
08/19/14 16:29
08/19/14 16:29
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
1: flags2 + UNTOUCHABLE
2: Try using WWRAP to wrap text lines (txt_load loads line by line)
3: \n is an escape code. It is just a "new line" as long long as you are in c-code
The compiler translates \n to 0x0A in the string AT compile time).
If you load \n from a text file, you load the actual \n string which is 0x2F 0x6E
So you need to parse your loaded string for "\\n" and replace every single one with " \n" (space at line end does not do anything at all, but has the same size so you can run the code in-place)


Visit my site: www.masterq32.de
Re: Three more questions [Re: Uhrwerk] #444833
08/19/14 16:38
08/19/14 16:38
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: Uhrwerk
For the first question: You can set the entities UNTOUCHABLE flag.

The second question: Please post your code.

Third question: the delimiter is just a character that causes the file_read_string instruction to stop at that specific character. What exactly is the problem? Is it ignored?
Of man, the answer for the first question was so easy... dumb me :<
About the code, I can't post it right here, cause I don't have access to it from this place.
The problem is, that '\n' doesn't work if you read text from file.
Originally Posted By: MasterQ32
1: flags2 + UNTOUCHABLE
2: Try using WWRAP to wrap text lines (txt_load loads line by line)
3: \n is an escape code. It is just a "new line" as long long as you are in c-code
The compiler translates \n to 0x0A in the string AT compile time).
If you load \n from a text file, you load the actual \n string which is 0x2F 0x6E
So you need to parse your loaded string for "\\n" and replace every single one with " \n" (space at line end does not do anything at all, but has the same size so you can run the code in-place)
2. I do use WWRAP, as I've said above I've set 'size_x' and 'size_y' to make my text feet the background image, and this part works great. But the thing is, that only about 300 character of the whole text are visible.. I still wonder why :<
3. so I need to cycle throw the string, find '\\n' and replace every single one I've found with '\n' ?


Thank you guys, for such a quick replies! laugh

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444836
08/19/14 17:11
08/19/14 17:11
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
for the THIRD problem I used 'str_replaceall', and replaced all '\\n' with '\n' and it works! But it leaves one '\' right before jumping to the next line... why?

for the FIRST problem UNTOUCHABLE flag2 was used and it's works perfectly fine.

and SECOND problem still there, waiting for a mighty community member to fix it grin


edit: I've found out that actually changing '\\n' to (f.e.) '\m' still leaves '\' right before splitting the string to next line..

Last edited by 3run; 08/19/14 17:23. Reason: ...

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444856
08/20/14 00:19
08/20/14 00:19
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
\ is also an escape character needs to be escaped so in your context \\ means single slash so "\\n" in fact matches \n leaving the first slash, to match them both you have to replace "\\\\n".

Last edited by Quad; 08/20/14 00:19.

3333333333
Re: Three more questions [Re: Quad] #444863
08/20/14 07:14
08/20/14 07:14
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Salam Aleikum, Quad laugh
Thank you for responce, it actually worked with your help!


SECOND PROBLEM is still there.. but I've found out that problem is in the code (where I read the string into the text).
I'm trying to figure out, but still no luck.. I can't upload the whole thing here, I could share it with someone via PMs.

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444884
08/20/14 16:43
08/20/14 16:43
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
So, I've found out that SECOND problem comes from my script, but yet I can't find the problem.

I've ripped the text loading part from my diary, and here it is:
Code:
// include lib:
#include <acknex.h>
#include <default.c>
#include <strio.c>

// an empty string:
STRING* str_file = "#999";				// used to read the stuff from the file
// document strings:
STRING* document_str = "notes.txt";			// the name of the document file
STRING* document_page = "#999";				// same as above
STRING* text_str = "#999";				// used to display text

// documents stuff:
var document_id = 0;					// used to read document ID from external file

// background for the text:
PANEL* documentPan = {
	// set it's layer:
	layer = 1;
	// set it's bmap:
	bmap = "#340x450x24";
	// flags:
	flags = SHOW | UNTOUCHABLE;
}

// document description text:
TEXT* doc_desc_txt = {
	// no strings:
	strings = 0;
	// set layer:
	layer = 2;
	// set font:
	font = "Arial#18i";
	// set flags:
	flags = SHOW | LIGHT | WWRAP;
}

// document description text:
TEXT* doc_debug_txt = {
	// no strings:
	strings = 0;
	// set layer:
	layer = 2;
	// set font:
	font = "Arial#18i";
	// set flags:
	flags = SHOW | LIGHT | WWRAP;
}

// reads a string from file and puts it to global pointer:
function file_for_str(var fhandle){
	// read string from file, don't have to be comma separrated:
	var result = file_str_read(fhandle, str_file);
	// copy string into the debug text:
	str_cpy((doc_debug_txt.pstring)[0], str_file);
	// convert the string to right format:
	str_replaceall((doc_debug_txt.pstring)[0], "_", " ");
	str_replaceall((doc_debug_txt.pstring)[0], "\\\\n", "\n");
	// if we succeeded:
	if(result != -1){
		// if we were able to read data from the file, use var_for_name to pass the value to global pointer:
		var d = var_for_name(str_file);
		// if we weren't able to read data:
		if(d == 0){
			// write it down in diag:
			diag("\nUnkwon string or var given:");
			// write it down in diag:
			diag(_chr(str_file));
		}
	}
	// return result:
	return(result);
}

// laod document title, pages and maximum pages by ID
function loadDoc(var id){
	// open the document file:
	var fhandle = file_open_read(document_str);
	// if the file was null, safe return this function:
	if(fhandle == NULL){ return(0); }
	// variables:
	var i, a;
	// cycle throw all documents:
	for(a = 0; a < 1; a++){
		// get global string/variable from the file:
		i = file_for_str(fhandle);
		// if result was -1, we're at the end of the file:
		if(i == -1){ break; }
		// if the id fetched from the file matched the ID we're searching for:
		if(document_id == id){
			// load pages with maximum apge variable:
			for(i = 0; i < 1; i++){
				// load page of the document:
				file_for_str(fhandle);
				// convert the string to right format:
				str_replaceall(document_page, "_", " ");
				// convert the string to right format:
				str_replaceall(document_page, "\\\\n", "\n");
				// copy the currect page to the corresponding page array:
				str_cpy(text_str, document_page);
			}
			// break the loop:
			break;
		}
	}
	// close the document file:
	file_close(fhandle);
	// if we succeeded here, return 1:
	return(1);
}

// toggle the currect document:
function loadText(){
	// copy currect page:
	str_cpy((doc_desc_txt.pstring)[0], text_str);
	// make description visible:
	set(doc_desc_txt, SHOW);
}

// document's title is clicked in choice panel:
function titleClicked(){
	// load document with real value:
	loadDoc(1);
	// load text into the text (lol):
	loadText();
}

// main function:
void main(){
	// limit fps:
	fps_max = 60;
	// load empty level:
	level_load(NULL);
	// wait for while:
	wait(3);
	// set delemeter:
	str_cpy(delimit_str, ";");
	// load text from the .txt file:
	titleClicked();
	// loop:
	while(!key_esc){
		// show current documents ID:
		DEBUG_VAR(document_id, 10);
		// set notebook at the center of the screen:
		documentPan.pos_x = (screen_size.x / 2) - (bmap_width(documentPan.bmap) / 2) + 150;
		documentPan.pos_y = (screen_size.y / 2) - (bmap_height(documentPan.bmap) / 2);
		// set proper position for text itself:
		doc_desc_txt.pos_x = documentPan.pos_x + 15;
		doc_desc_txt.pos_y = documentPan.pos_y + 15;
		// set the size for the text (description) - used by WWRAP:
		doc_desc_txt.size_x = bmap_width(documentPan.bmap) - 25;
		doc_desc_txt.size_y = bmap_height(documentPan.bmap) - 25;
		// set debug text:
		doc_debug_txt.pos_x = 45;
		doc_debug_txt.pos_y = doc_desc_txt.pos_y;
		// set the size for the text (description) - used by WWRAP:
		doc_debug_txt.size_x = 300;
		doc_debug_txt.size_y = 500;
		// wait one frame:
		wait(1);
	}
	// exit:
	sys_exit("");
}


Here how the 'notes.txt' file looks like (can't be displayed here correctly):
Quote:
document_id = 1;
document_page = This_is_just_an_example_of_my_diary_system_I've_created_so_far!\\n\\nIt_works_pretty_nice_and_I'm_happy_with_the_results.\\n\\nBut_I've_found_out_that_only_about_300_characters_of_this_string_will_be_visible...\\n\\nHopefully_this_example_will_show_you_what_kind_of_a_problem_I'm_currently_facing_and_you'll_be_able_to_help_me_out_guys.;


Take a look at this screen:


If you want to give it a try, you may download ready to use demo:
Download link

What could cause the problem? It seems (at least to me) that everything should work fine!
The text on the left, displayed right after it was read from the .txt file by file_for_str.
Second one (the one with the background) is displayed after the string receives the text and get's edited.

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444916
08/21/14 17:48
08/21/14 17:48
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Really? No one can help me out with this? Even after I've posted a code?? frown


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444919
08/21/14 20:25
08/21/14 20:25
Joined: Nov 2011
Posts: 274
de
lemming Offline
Member
lemming  Offline
Member

Joined: Nov 2011
Posts: 274
de
I was seriously disappointed when in the main you only commented every second line.

I was quite unable to understand what you where trying to do, mainly because your comments killed your code. My favorite lines where:
Code:
// set it's layer:
layer = 1;

// no strings:
strings = 0;

// wait one frame:
wait(1);



So I came up with my own approach. Read the file until delimeter "#" then append it to TEXT, read next til "#" and so on. Then the order they are saved in represent ids.

I dunno what problems you had with \n and stuff.

Click to reveal..

Code:
// include lib:
#include <acknex.h>
#include <default.c>
#include <strio.c>

STRING* document_str = "notes2.txt";			// the name of the document file



STRING* strText = "";
STRING* strFile = "";



// document description text:
TEXT* doc_desc_txt = {
	strings = 0;
	layer = 2;
	font = "Arial#18i";
	flags = SHOW | LIGHT | WWRAP;
}



//STRING* strText = "";
//STRING* strFile = "";

STRING* strNumber = "";
/**
 * reads a Note from a File. Modifies doc_desc_txt as it appends strings to it.
 */
var read_notes(STRING* file)
{
	var fhandle = file_open_read(file);
	if (fhandle)
	{
		var num = 0;
		var eof = 0;
		do
		{
			eof = file_str_readto(fhandle, strFile, "#", 10000);
			if (eof != -1)
			{
				error(strFile);
				if (str_len(strFile) > 0)
				{
					txt_addstring(doc_desc_txt, strFile);
					num++;
				}
			}
		} while (eof != -1);
		return num;
	}
	return 0;
}

void cycle_notes(var from, var to)
{
	var waitTime = 0;
	var curr = from;
	while(1)
	{
		txt_setinvisible(doc_desc_txt, -1);
		txt_setvisible(doc_desc_txt, curr);
		waitTime += time_step;
		if (waitTime > 10)
		{
			waitTime = 0;
			curr = cycle(curr+1, from, to+1);
		}
		wait(1);
	}
}


// main function:
void main(){
	fps_max = 60;
	level_load(NULL);

	var msgs = read_notes("notes2.txt");
	cycle_notes(0, msgs-1);
	
	while(!key_esc){
		DEBUG_VAR(1, 0);
		DEBUG_VAR(msgs, 20);

		doc_desc_txt.pos_x = 15;
		doc_desc_txt.pos_y = 15;

		doc_desc_txt.size_x = 200;
		doc_desc_txt.size_y = 400;
		
		wait(1);
	}
	// exit:
	sys_exit("");
}


Code:
This is just an example of my diary system I've created so far!

It works pretty nice and I'm happy with the results.

But I've found out that only about 300 characters of this string will be visible...

Hopefully this example will show you what kind of a problem I'm currently facing and you'll be able to help me out guys.#
THIS IS MADNESS!#
Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet Lorem Ipsum Dolor sit amet



Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1