Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dpn), 1,328 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Need help with idea for text window in rpg game. #337956
08/14/10 19:51
08/14/10 19:51
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline OP
Member
paracharlie  Offline OP
Member
P

Joined: Mar 2009
Posts: 146
USA
I need help with an idea for creating a text window in my rpg. Lets say you right click on a npc in the game.
1)The text panel will pop up, where you will interact with the npc and the strings of text will show up.
2)each line of text will appear consecutively one after the other until there is 10 lines total, newest line always being below the previous.
3)the eleventh line will reset the first line and the eleventh line will become the 10th line, etc... the eleventh line will always become the 10 th line and the text window will always have 10 lines of text so that the player can review the last 10 lines of chat. The 10 th line will always be the latest line of text. does anyone have an idea how to start doing something like this? Sure could use some professional help here, please. Here is pic of my text window in game.
my home page
I'm currently working on some ideas and when I have more to show I will post some code and hopefully get help while trying to figure it out.

Last edited by paracharlie; 08/15/10 02:52.

A8 Commercial
Re: Need help with idea for text window in rpg game. [Re: paracharlie] #338131
08/16/10 01:34
08/16/10 01:34
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline OP
Member
paracharlie  Offline OP
Member
P

Joined: Mar 2009
Posts: 146
USA
Here is the code that I have been needing help with. What I wanted to do is fill string1 first, then string2, then string3 etc... Then when string5 is reached, all new chat is filled into string5 and then string5 becomes string4, string4 becomes string3 etc... so that it scrolls up and the new line of text is always at string5. Right now its always filling string5 and then scrolling up. I would like the player to be able to review the last 10 or whatever lines of text. This code is ready to run as is. Hopefully you understand what I want to do.


Code:
#include <acknex.h>
#include <default.c>


var i;
var yes;
var no;
var string1;
var string2;
var string3;
var string4;
var string5;
STRING* string_one = "";
STRING* string_two = "";
STRING* string_three = "";
STRING* string_four = "";
STRING* string_five = "";
STRING* npc_message = "";
BMAP* message_window = "message_window.tga";

PANEL* main_pan =
{	
	
	digits(30,20, "String1: %s","Arial#14",1,string_one);	
	digits(30,30, "String2: %s","Arial#14",1,string_two);
	digits(30,40, "String3: %s","Arial#14",1,string_three);
	digits(30,50, "String4: %s","Arial#14",1,string_four);
	digits(30,60, "String5: %s","Arial#14",1,string_five);
	layer = 10;
	flags = SHOW;	
}
	

function message_win()
{
	i = 1;
		 
	
	while((i > 0)&&(i <= 6))
	{
		if(i == 1)
		{
			str_cpy(string_one,npc_message);  string1 = yes; i += 1;
		}
		if((i == 2))
		{
			str_cpy(string_two,npc_message);  string2 = yes; i += 1;
		} 
		if((i == 3))
		{
			str_cpy(string_three,npc_message); string3 = yes; i += 1;
		}
		if((i == 4))
		{
			str_cpy(string_four,npc_message); string4 = yes; i += 1;
		}
		if((i == 5))
		{
			str_cpy(string_five,npc_message); string5 = yes; i += 1;
		}
		if((i == 6)&&(string5 == yes)&&(string4 == yes)&&(string3 == yes)&&(string2 == yes)&&(string1 == yes))
		{	
			 str_cpy(string_five, npc_message);
		}
		wait(1);
	}
 i = 1;
 	

}

function npc_chat()
{
   var choice;
	random_seed(0);
	choice = integer(random(5));clamp(choice, 1, 3);
	if(choice == 1)str_cpy(npc_message, "This is choice 1");
	if(choice == 2)str_cpy(npc_message, "This is choice 2");
	if(choice >= 3)str_cpy(npc_message, "This is choice 3");
	str_cpy(string_one, string_two);
		str_cpy(string_two, string_three);
		   str_cpy(string_three, string_four);
			   str_cpy(string_four, string_five);
   
}
	
function main()
{
  screen_size.x = 1024;
  screen_size.y = 768;
  screen_color.blue = 50;
  main_pan.pos_x = (screen_size.x - bmap_width(message_window))/2;
	main_pan.pos_y = (screen_size.y - bmap_height(message_window)-10);
  message_win();
  on_m = npc_chat;
  
  
}




A8 Commercial
Re: Need help with idea for text window in rpg game. [Re: paracharlie] #338141
08/16/10 07:02
08/16/10 07:02
Joined: Jul 2010
Posts: 127
Germany, Herford
Ditje Offline
Member
Ditje  Offline
Member

Joined: Jul 2010
Posts: 127
Germany, Herford
How many lines can there be? Endless? What should happen with text 1 when it got replaced by 11. Do you still need it or can it be deleted / overwritten?

I would suggest to do a for loop an used arrays. Although array functions are not supported.

Here is a suggestion. You need a function to fill your npc_text array. But if I understand it right, you have it already.


Code:
var npc_text[n][10]; // [n = ammount of string sets][0-10 lines => 1 to 10 shown + 0 for new] 

// Your text function should fill array like this
STRING* npc_text[n][0] = "text for 11th (=new) text"; // repace n!!!
STRING* npc_text[n][1] = "text for first text";
...


// check which string set is needed
var check_npc; // use this to check which npc is right clicked or use me
var npc_ypos; // set y Position of text elements

// Here you have to set new chat entry to npc_text[n][0]

function 

// check if there is a new entry in npc_text[n][0]


if(!str_cmp(npc_text[n][0],""))
{
   npc_text[n][0] = "New Text"
   // Switch all "old" text to number before.
   for(i=10;i<=1;i--)
   {
     npc_text[n][i] =  npc_text[n][i-1];
     str_npc_ypos = 300-i*15;
     digits(30,npc_ypos, "String%i: %s","Arial#14",1,npc_text[check_npc][i]);
   }
   // After that clear npc_text[n][0] for next entry check
   npc_text[n][0] = "";
}
else 
{
   // if there are less than 10 entries
   for(i=1;i<=10;i++)
   {
      str_ypos = 30+i*15;
      if(!str_cmp(npc_text[n][i],"")) digits(30,str_ypos, "String%i: %s","Arial#14",1,npc_text[check_npc][i]);
   }
}



Last edited by Ditje; 08/16/10 07:31.
Re: Need help with idea for text window in rpg game. [Re: Ditje] #338172
08/16/10 12:18
08/16/10 12:18
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline OP
Member
paracharlie  Offline OP
Member
P

Joined: Mar 2009
Posts: 146
USA
There will be 10 lines. Its not endless. Line one will appear first then line two under line one then line 3 etc... Until 10 lines appear, then line 10 continues to be filled with the new text and all subsequent text scrolls up. Basically its just scrolling text like you would see in any mmorpg out there. Except the only difference is my window wont have a scroll bar. I would like there to be 10 lines of text just so the player can review what has happened in the last 10 lines. Once line 10 scrolls up to line 1 and essentially is lost for good.
Could you possible give me a working example like I did above so that I can pick through it? I'm not always able to understand other peoples ideas. I do understand yours for the most part with using arrays and for loops just not totally sure how to implement the idea.

Last edited by paracharlie; 08/16/10 12:29.

A8 Commercial
Re: Need help with idea for text window in rpg game. [Re: paracharlie] #338177
08/16/10 12:56
08/16/10 12:56
Joined: Jul 2010
Posts: 127
Germany, Herford
Ditje Offline
Member
Ditje  Offline
Member

Joined: Jul 2010
Posts: 127
Germany, Herford
ok - I am working on, but give me a few hours, because I`ve another job on the screen laugh

Edit: Oh I am sorry. I haven`t worked with Strings like this, before and haven`t expected, that I can`t work strings like usual variables. So I would have to study tutorial about strings first.

I hope anyone else can help you faster laugh

Last edited by Ditje; 08/16/10 13:36.
Re: Need help with idea for text window in rpg game. [Re: Ditje] #338179
08/16/10 13:05
08/16/10 13:05
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline OP
Member
paracharlie  Offline OP
Member
P

Joined: Mar 2009
Posts: 146
USA
Oh no problem, thank you for taking the time to help me.


A8 Commercial
Re: Need help with idea for text window in rpg game. [Re: paracharlie] #338184
08/16/10 13:28
08/16/10 13:28
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
try this, (standalone for testing)
Code:
#include <acknex.h>
#include <default.c>

TEXT* txt_log = {
	layer = 10;
	strings = 10;
	flags = SHOW;
}

void logger(STRING* str){

	int i = 0;
	str_cpy((txt_log.pstring)[0], str);
	
	for(i = 0; i < txt_log.strings-1; i++){
		str_cpy((txt_log.pstring)[i],(txt_log.pstring)[i+1]);
	}
	
	if(str){
		str_cpy((txt_log.pstring)[txt_log.strings-1],str);
	}else{
		str_cpy((txt_log.pstring)[0],"");
	}
}

#define waiter -0.5
void logger_startup(){
	
	int i;
	for(i = 0; i < txt_log.strings; i++){
		(txt_log.pstring)[i] = str_create("");
	}
	
	wait(waiter);
	logger("THIS");
	wait(waiter);
	logger("IS");
	wait(waiter);
	logger("HOW");
	wait(waiter);
	logger("IT");
	wait(waiter);
	logger("WORKS");
	wait(waiter);
	
	logger("JUST");
	wait(waiter);
	logger("KEEP");
	wait(waiter);
	logger("SENDING");
	wait(waiter);
	logger("logger(\"input\")");
	wait(waiter);
	logger("UNTIL");
	wait(waiter);
	logger("YOU");
	wait(waiter);
	logger("GET");
	wait(waiter);
	logger("BORED");
	wait(waiter);
	logger(":)");
	wait(waiter);
}


hope this helps

Re: Need help with idea for text window in rpg game. [Re: MrGuest] #338186
08/16/10 13:50
08/16/10 13:50
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline OP
Member
paracharlie  Offline OP
Member
P

Joined: Mar 2009
Posts: 146
USA
Thats how I want it to scroll up but here is what should happen. You walk up to an npc_merchant to buy some of your favorite pumpkin flavored gatorade. You right click on the npc and your first line of text will start at lets say y = 10. then the next line y = 20 and the next line y = 30 and so forth. Then when line 10 is reached, then ONLY line 10 will be filled with the new text and all previous text will continue to scroll up with every new line of text in line 10. So for any line of text in line1 will essentially just disappear and be lost for good. This is just a text encounter window for npc's and maybe combat too. After you purchase that yummy drink you walk away window closes and all text is lost for good.


A8 Commercial
Re: Need help with idea for text window in rpg game. [Re: paracharlie] #338193
08/16/10 15:22
08/16/10 15:22
Joined: Jul 2010
Posts: 127
Germany, Herford
Ditje Offline
Member
Ditje  Offline
Member

Joined: Jul 2010
Posts: 127
Germany, Herford
Oh I guess that`s what you want and quite similar to what I wanted to do laugh Test the script without wait(waiter). Delelte them all.

Run and check what`s on the screen. Only the last 10. Add one and again only the last ten get displayed.

So you just need to fill new entries with the logger function.

Re: Need help with idea for text window in rpg game. [Re: Ditje] #338254
08/16/10 19:19
08/16/10 19:19
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline OP
Member
paracharlie  Offline OP
Member
P

Joined: Mar 2009
Posts: 146
USA
Its close, but this one starts at line 10 and then scrolls up.


A8 Commercial
Page 1 of 2 1 2

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