ROM Hack PAlib Help

ThomasWii

Active Member
OP
Member
Joined
Mar 8, 2008
Messages
41
Trophies
1
Age
28
Location
England
XP
1,612
Country
United Kingdom
Hi, just to let you know I'm new and dint know much, I have a problem with this code, I'm trying to make it so when i type "hi" into the palib keyboard, it Say's hello. I put in what it might be, build successful and when i run it, it dose not work! Here's the code CODE#include

char text[200];


int main()
{
ÂÂÂÂPA_Init();
ÂÂÂÂPA_InitVBL();

ÂÂÂÂPA_InitText(1, 0);
ÂÂÂÂPA_InitKeyboard(2);
ÂÂÂÂPA_KeyboardIn(20, 95);
ÂÂÂÂs32 nletter = 0;
ÂÂÂÂchar letter = 0;

ÂÂÂÂwhile (1)
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂletter = PA_CheckKeyboard();
ÂÂÂÂÂÂÂÂ
ÂÂÂÂÂÂÂÂif (letter > 31) {
ÂÂÂÂÂÂÂÂÂÂÂÂtext[nletter] = letter;
ÂÂÂÂÂÂÂÂÂÂÂÂnletter++;
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂelse if(letter == PA_TAB){
ÂÂÂÂÂÂÂÂÂÂÂÂu8 i;
ÂÂÂÂÂÂÂÂÂÂÂÂfor (i = 0; i < 4; i++){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂtext[nletter] = ' ';
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂnletter++;
ÂÂÂÂÂÂÂÂÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂelse if ((letter == PA_BACKSPACE)&&nletter) {
ÂÂÂÂÂÂÂÂÂÂÂÂnletter--;
ÂÂÂÂÂÂÂÂÂÂÂÂtext[nletter] = ' ';
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂelse if (letter == '\n'){
ÂÂÂÂÂÂÂÂÂÂÂÂif(text=="hi"){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPA_OutputSimpleText(1,1,10,"Hello!");
ÂÂÂÂÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂ
ÂÂÂÂÂÂÂÂPA_OutputText(1, 1, 1,"Text: %s",text);

ÂÂÂÂÂÂÂÂPA_WaitForVBL();
ÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂreturn 0;
}

Any help will be appreciated!

Thanks in advance
Thomas
 

ICEM4N

Member
Newcomer
Joined
Feb 29, 2008
Messages
13
Trophies
0
Website
www.theninjabunny.com
XP
342
Country
Austria
if(text=="hi"){

"text" isn't a String, is a vector (or array) of chars, You can not compare vectors or chars with strings.

You may do

if(text[0]=="h" && text[1]=="i") {


But i thought PALib has a function like PA_CompareText or something similar.
 

keeganator

Well-Known Member
Newcomer
Joined
Jul 4, 2007
Messages
55
Trophies
0
XP
352
Country
Australia
ICEM4N said:
if(text=="hi"){

"text" isn't a String, is a vector (or array) of chars, You can not compare vectors or chars with strings.

You may do

if(text[0]=="h" && text[1]=="i") {


But i thought PALib has a function like PA_CompareText or something similar.

Wrong. When you compile your code, it will do that for you.

And ThomasWii, can you specify what actually happens when you load the game.
 

ThomasWii

Active Member
OP
Member
Joined
Mar 8, 2008
Messages
41
Trophies
1
Age
28
Location
England
XP
1,612
Country
United Kingdom
I run the game, and at the top it says "Text: " then i put in hi so it becomes "Text: hi" then press enter, and dose nothing.

Thanks in advance.
Thomas
 

snakerdlk

New Member
Newbie
Joined
Mar 13, 2008
Messages
3
Trophies
0
XP
72
Country
Brazil
dont believe just one person here knows the strcmp function

well...
better would be to

CODE#include

at the top of the code

and to use

Code:
if(!strcmp(text, "hi"))

its more elegant and it should theoretically run faster...
 

ThomasWii

Active Member
OP
Member
Joined
Mar 8, 2008
Messages
41
Trophies
1
Age
28
Location
England
XP
1,612
Country
United Kingdom
after all this time i found out the main point why it was not coming up,
Code:
PA_OutputSimpleText(0,1,10,"Hello!");
should have been
Code:
PA_OutputSimpleText(1,1,10,"Hello!");

Thanks for all your help, got it fixed now
smile.gif
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Let me finish do the harder drugs