Translate only hotspot, why?

Started by Tequila144, Tue 08/04/2008 19:18:33

Previous topic - Next topic

Tequila144

I use a GUI simil-scumm.. 
For translate my game (it's in italian) I have used the script:
Code: ags
if (Game.TranslationFilename == "English") { }  

It works but the text of the GUI is translated only on a Hotspot, while on an object or character is in original language. 
Why?

Khris

You don't have to translate your game that way.
Look up "Translations" in the manual, or read it online.

Basically, AGS creates a text file with every line and name from the game, the author (or somebody else) writes the translations in the empty lines in between, then the author creates a translation file from the text file.

Tequila144

#2
The translation is complete. All the file txt is translate. 
The script  changes also the Gui's button when it started with the file English.tra. 
But the game not translate  the actions (gui text) on objects and characters and the actions on hotspot.

Khris

Ah, sorry, I see.
How does the action text end up in the GUI label?
We need to see the code since it seems to be a script-related problem.

Tequila144

#4
In Global Script:
Code: ags
 
function game_start()
  
if (Game.TranslationFilename == "English") {  
 take.NormalGraphic = 71;
 take.MouseOverGraphic = 93;
 examine.NormalGraphic = 19;
 examine.MouseOverGraphic = 70;
 talk.NormalGraphic = 113;
 talk.MouseOverGraphic = 115;
 use.NormalGraphic = 188;
 use.MouseOverGraphic =189;
} 


It's ok. When use the english.tra the gui's buttons change!

Then:
Code: ags

function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  string buffer;
  string madetext;
  int cur_mode;
  // Initialize the status line to display the score
  StrCopy (madetext, "");
  // Now, add text depending on the mode
  cur_mode = GetCursorMode();
  if (cur_mode == MODE_WALK)
    StrCat(madetext,"Vai verso ");
  else if (cur_mode == MODE_LOOK)
    StrCat (madetext,"Esamina ");
  else if (cur_mode == MODE_USE)
    StrCat(madetext,"Usa ");
  else if (cur_mode == MODE_TALK)
    StrCat(madetext,"Parla con ");
  else if (cur_mode == 5)
    StrCat(madetext,"Raccogli ");
  else if (cur_mode == 4) {
    StrCat(madetext,"Usa ");
    GetInvName (player.activeinv, buffer);
    StrCat(madetext,buffer);
    StrCat(madetext," con ");
    }

Where the madetext ara all translate in english.txt.

When i click on GuiButton (for example Talk To), the action on GUI (scumm) is "Talk to"..
but when i move the cursor on hotspot, characters or objetc the action became "Parla (italian translate of Talk) english name of hotspot/object/character"
Why?


SSH

Becuase you don't have a translation of:

"Talk to Fred"
"Talk to Wilma"

you have to manually translate the two parts with the GetTranslation function
12

Tequila144

Quote from: SSH on Wed 09/04/2008 08:20:51
Becuase you don't have a translation of:

"Talk to Fred"
"Talk to Wilma"

you have to manually translate the two parts with the GetTranslation function

I read the AGS manual but i not understand how i use this "GetTranslation function" in this case.

SSH

Assuming you're using 2.72 or later:

Code: ags

function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  String madetext;
  int cur_mode;
  // Now, add text depending on the mode
  cur_mode = GetCursorMode();
  if (cur_mode == MODE_WALK)
    madetext = "Vai verso ";
  else if (cur_mode == MODE_LOOK)
    madetext = "Esamina ";
  else if (cur_mode == MODE_USE)
    madetext = "Usa ";
  else if (cur_mode == MODE_TALK)
    madetext = "Parla con ";
  else if (cur_mode == 5)
    madetext = "Raccogli ";
  else if (cur_mode == 4) {
    madetext=GetTranslation("Usa ");
    madetext=madetext.Append(GetTranslation(player.ActiveInventory.Name));
    madetext=madetext.Append(GetTranslation(" con "));
    }
12

Tequila144

Well.. the script don't work.

This is my original script:
Code: ags

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  string buffer;
  string madetext;
  int cur_mode;
  // Initialize the status line to display the score
  StrCopy (madetext, "");
  // Now, add text depending on the mode
  cur_mode = GetCursorMode();
  if (cur_mode == MODE_WALK)
    StrCat(madetext,"Vai verso ");
  else if (cur_mode == MODE_LOOK)
    StrCat (madetext,"Esamina ");
  else if (cur_mode == MODE_USE)
    StrCat(madetext,"Usa ");
  else if (cur_mode == MODE_TALK)
    StrCat(madetext,"Parla con ");
  else if (cur_mode == 5)
    StrCat(madetext,"Raccogli ");
  else if (cur_mode == 4) {
    StrCat(madetext,"Usa ");
    GetInvName (player.activeinv, buffer);
    StrCat(madetext,buffer);
    StrCat(madetext," con ");
    }
 

  // Find out what's under the cursor, and add it to the status line
  GetLocationName(mouse.x,mouse.y,buffer);
  StrCat(madetext,buffer);
  SetLabelText ( 0, 7, madetext);
}


This is the script (modified with SSH'code):
Code: ags

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  String buffer;
  String madetext;
  int cur_mode;
  // Now, add text depending on the mode
  cur_mode = GetCursorMode();
  if (cur_mode == MODE_WALK)
    madetext = "Vai verso ";
  else if (cur_mode == MODE_LOOK)
    madetext = "Esamina ";
  else if (cur_mode == MODE_USE)
    madetext = "Usa ";
  else if (cur_mode == MODE_TALK)
    madetext = "Parla con ";
  else if (cur_mode == 5)
    madetext = "Raccogli ";
  else if (cur_mode == 4) {
    madetext=GetTranslation("Usa ");
    madetext=madetext.Append(GetTranslation(player.ActiveInventory.Name));
    madetext=madetext.Append(GetTranslation(" con "));
    }
 

  // Find out what's under the cursor, and add it to the status line
  GetLocationName(mouse.x,mouse.y,buffer);
  StrCat(madetext,buffer);
  SetLabelText ( 0, 7, madetext);

 

  }


The error is: "Type mismatch: cannot convert 'String*' to 'string'" (the error is situated on line of "GetLocationName(mouse.x,mouse.y,buffer);"

I've tried to delete "String buffer"  but, logically, the error is: "undefined symbol buffer"


Gilbert

Change that to:

buffer = Game.GetLocationName(mouse.x, mouse.y);

The old GetlocationName(x,y,string) method is obsolete now.

Tequila144

Quote from: Gilbot V7000a on Fri 11/04/2008 09:36:36
Change that to:

buffer = Game.GetLocationName(mouse.x, mouse.y);

The old GetlocationName(x,y,string) method is obsolete now.

Ok.. but don't work.

SSH

What error message do you get?

You'll need to put this code at the end of the function:

Code: ags

buffer = Game.GetLocationName(mouse.x, mouse.y);
madetext=madetext.Append(buffer);
gui[0].Controls[7].AsLabel.Text=madetext;


12

Tequila144

Quote from: SSH on Fri 11/04/2008 10:47:07
What error message do you get?

You'll need to put this code at the end of the function:

Code: ags

buffer = Game.GetLocationName(mouse.x, mouse.y);
madetext=madetext.Append(buffer);
gui[0].Controls[7].AsLabel.Text=madetext;




Ok. works! 
But as I do insert the translation of other actions (examine, talk, take)? 
 
Sorry... but I have not understood this function.

SSH

Translations should be done with the translation file mechanism.
12

Tequila144

Quote from: SSH on Fri 11/04/2008 11:09:56
Translations should be done with the translation file mechanism.

they are translated in the file, but in the game works alone the action "Use with"..   
The other actions are not translated when the cursor is on a hotspot o character.

SSH

#15
That is still true with the new code?

Ooops, yes, add this line after all the ifs but before the other code:

Code: ags

madetext=GetTranslation(madetext);

12

Tequila144

No. But it doesn't work. 
Now the actions are translated, but if the game is in original language (Italian), they are translated (English)..

SSH

The GetTranslation should do nothing if the game is in default langauge. Are you sure it is set back to Italian? But, you can just put this in, instead,  if it still doesn't work:

Code: ags

if (IsTranslationAvailable()) madetext=GetTranslation(madetext);

12

Tequila144

Ok.
Now i use this code:
Code: ags

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  String buffer;
  String madetext;
  int cur_mode;
  
  // Now, add text depending on the mode
  cur_mode = GetCursorMode();
  if (cur_mode == MODE_WALK) {
    madetext = "Vai verso "; 
}
  else if (cur_mode == MODE_LOOK) {
    madetext = "Esamina ";
}
  else if (cur_mode == MODE_USE) {
    madetext = "Usa ";
 }
  else if (cur_mode == MODE_TALK){
    madetext = "Parla con ";
}
  else if (cur_mode == 5){
    madetext = "Raccogli ";
}
  madetext=GetTranslation(madetext );

   if (cur_mode == 4) {
    madetext=GetTranslation("Usa ");
    madetext=madetext.Append(GetTranslation(player.ActiveInventory.Name));
    madetext=madetext.Append(GetTranslation(" con "));
    }
    

  
  // Find out what's under the cursor, and add it to the status line
  buffer = Game.GetLocationName(mouse.x, mouse.y);
madetext=madetext.Append(buffer);
gui[0].Controls[7].AsLabel.Text=madetext;

 

  }


The translate works, but when i use an inventory item (when i click on "Use" then on object), the game crash!

The error is on line  "madetext=GetTranslation(madetext );", it says "null string referencs".
All other actions works good (for the translate).

SSH

Ah, OK, you probably only want to run that code when you're not using the cursor mode Use, so stick an if around it to that effect.
12

SMF spam blocked by CleanTalk