ROM Hack PAlib Help

  • Thread starter Thread starter ThomasWii
  • Start date Start date
  • Views Views 2,703
  • Replies Replies 11

ThomasWii

Active Member
Member
Joined
Mar 8, 2008
Messages
41
Reaction score
23
Trophies
1
Location
England
XP
2,448
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
 
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.
 
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.
 
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
 
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...
 
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