Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: including global after if  (Read 7152 times)

0 Members and 1 Guest are viewing this topic.

Drax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 78
  • This engine rocks!
    • View Profile
    • Ganja Joe - And the myth of the holy pot
including global after if
« on: January 08, 2004, 09:43:00 AM »

we want to make the language chooseable in our game.

now I began to test it with teh text="mainmenu" in the mainwindow.

i can change it in the mwinwindow.script by self.text="blabla";

and I hope so
var text1="blabla";
self.text=text1;

In the base.inc I declared a global language="de";
for german.

now I scripted in the game.script (base.inc is included):

if(language="de"){
#include "language\de\captions.inc"
}
later I can add other languages.

in the captions.inc :

global text1="Hauptmenu";

and int the mainwindow.script
global text1;
self.text=text1;

at first: It does not work. I think its because of the #include (just work on top of file without a ';' ? )
How can I make it run?
How can i script It in a way I dont have to inital the varables in the file i used it, or in base.inc

i mean that i can do it in the captions.inc at once.
global text1="blablabla"
 an then i can use it in my files without say
global text1;

For that i have to include it, but then I can't do the if(language="de" thing)

Does anybody understand what I mean. I hope someone can help me.

ThX DraX
« Last Edit: January 08, 2004, 09:46:07 AM by DraX »
Logged
I'm Lost!

Drax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 78
  • This engine rocks!
    • View Profile
    • Ganja Joe - And the myth of the holy pot
Re:including global after if
« Reply #1 on: January 08, 2004, 10:12:56 AM »

oh, I see. it should be solved with string objekts and attachscript funktions.
Logged
I'm Lost!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:including global after if
« Reply #2 on: January 08, 2004, 10:44:53 AM »

WME has a built-in support for localized strings, see this thread for details:

http://www.dead-code.org/forum/index.php?board=3;action=display;threadid=86

You can't chanhe the language from within the game, though, it would have to done by some game launcher, installer etc.

Using multiple packages for different languages you can also localize fonts/graphics/sounds...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Drax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 78
  • This engine rocks!
    • View Profile
    • Ganja Joe - And the myth of the holy pot
Re:including global after if
« Reply #3 on: January 08, 2004, 11:21:57 AM »

Hi Mnemonic,
thanks for the answer.

We developed a system, where you can change it in game also.

at first the global language=null.

while its null you can't start a game. It's only the first window on start. there ara flags (gfx) to choose a language.
Now the language is for example =1 (german)

in game_deamon theres this:
Code: [Select]
if(language==1&&languagechange==true){
self.AttachScript("language\de\Captions.script");
self.AttachScript("language\de\Sounds.script");
self.AttachScript("language\de\TalkStrings.script");
self.AttachScript("language\de\Dialoge.script");
self.AttachScript("language\de\ItemOnItem.script");
languagechange=false;
}
 if(language==2&&languagechange==true){
self.AttachScript("language\en\captions.script");
self.AttachScript("language\en\Sounds.script");
self.AttachScript("language\en\TalkStrings.script");
self.AttachScript("language\en\Dialoge.script");
self.AttachScript("language\en\ItemOnItem.script");
languagechange=false;
}

in the endeless while.

in base.inc is an include file that defines the globals (all var for text and sound files if you want to)
Code: [Select]
global v150101cpt;
global v150102cpt;
...

 in the xxxx.script files (see above) the globals are defined:
Code: [Select]
v150101cpt="mainmenu";

I haven'd coded it yet finally. but im working hart.

Isn't it a possibility to do that changing in game thing.

p.s.:I know about the unreadability of the script, but we  will make a visual basic application where we can type in our global var:
for exaple:

v 01 05 01 txt

and the output ist:

var.beach.lighter.take.txt

so we always know what the varable mean.

the only thing that dosen't work is to do it without the include file in the base, and istead defining in the xxxx.scripts.

global v150101cpt ="blabla";
and that ist my question. can I do this?

 :-\ (difficult stuff, I know)
   
Logged
I'm Lost!

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re:including global after if
« Reply #4 on: January 08, 2004, 03:18:36 PM »

Hi DraX,

at first - why do you go that difficult way ? Do your really need to change the language in the running game ? I don't see the necessarity and I'd just install the right language package while installing the game.

I don't know, how you plan to contribute your game, but the way you go now implicates, that you'll use one big package for both languages (and would almost double the necessary size).

Anyway - your choice  ;) and here some answers regarding your questions:

p.s.:I know about the unreadability of the script, but we  will make a visual basic application where we can type in our global var:

Well, the built-in system is much more readable and easier, indeed. But up to here, it would work.

But your main problem is the "#include" which is (Mnemonic, please correct me if I'm wrong) a preprocessive directive. Means: this directive is executed while compiling the script and before actually running it. It does NOT mean, that the include-command is executed at runtime, when the if-clause is true.

Defining global vars should work though, it's not very beauty though. ;)
Logged
Mooh!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:including global after if
« Reply #5 on: January 08, 2004, 04:21:06 PM »

Yes, exactly as Jerrot said, the #include directive is execudet before the script is compiled. It works just as if you'd paste the include file contents in.

If it helps, I'm planning the ability to reload the string table at runtime (as requested by MMR), IMHO it would be a cleaner solution (of course, only suitable for text localization, not fonts/gfx).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Drax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 78
  • This engine rocks!
    • View Profile
    • Ganja Joe - And the myth of the holy pot
Re:including global after if
« Reply #6 on: January 08, 2004, 05:21:20 PM »

that sounds good. If it will be possible to do that, all my problems are solved. i think.

You'r right. That are very very big files if i define all the strings just for changing in game. I think we have to discuss that (me and my crew).

But it's so sad, to delete all the skripting i've made. It was so much work!

(The mainmenu strings are completely loaded from my vars now.
 :'(

Next time, I stop scripting immediatly, if one of you guys saying that there are other solutions.


 
Logged
I'm Lost!

MMR

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 349
  • http://mmrdeveloper.wordpress.com/
    • View Profile
    • TinyWME
Re:including global after if
« Reply #7 on: January 08, 2004, 07:07:59 PM »

Quote
Next time, I stop scripting immediatly, if one of you guys saying that there are other solutions

Test & Fail is the best way of learning. I bet you know now more than before you programmed the script ;)
« Last Edit: January 08, 2004, 07:08:22 PM by MMR »
Logged

Drax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 78
  • This engine rocks!
    • View Profile
    • Ganja Joe - And the myth of the holy pot
Re:including global after if
« Reply #8 on: January 09, 2004, 12:50:52 PM »

we decided to use our system instead of using the string.tab.

I've just one main problem, doing it.

The Problem:

I got 'null' instead of the definied texts.

How i made it:

the global var for the txt is declared in the base.inc.
for example:

Code: [Select]
global Scene;
....
global txt;

And in the Game.script is defined:

Code: [Select]
self.AttachScript("define.script");

define.script:
Code: [Select]
#include  "base.inc"

txt="bla";

in scene_init.script:
Code: [Select]
actor.Talk(txt);

now it says 'null' instead of bla.

I think its because of the define.script is executed later than the scene_init.script.

the same problem (items caption) :
item.script
 but it works fine for the TEXT= of the mainmenu.

Where i have to place the definition of the global txt?

I hope it stresses not to much that I ask questions to a problem that everybody of you would'nt have because of the string.tab. :-\



Logged
I'm Lost!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:including global after if
« Reply #9 on: January 09, 2004, 01:01:59 PM »

Try adding Sleep(0); after the Game.AttachScript and before the Game.ChangeScene. The Sleep command will interrupt the current script and it will give a chance to the others to run. This way your newly attached script will be executed before the scene is loaded.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Drax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 78
  • This engine rocks!
    • View Profile
    • Ganja Joe - And the myth of the holy pot
Re:including global after if
« Reply #10 on: January 09, 2004, 01:31:04 PM »

thanks. now it works fine.
Logged
I'm Lost!
 

Page created in 0.049 seconds with 24 queries.