Panneau de contrôle du modérateur ]

Maniascript strange behaviours

Modérateurs: Yrp360, tcq, eyebo, seeba, NADEO

Maniascript strange behaviours

Messagepar drmaxkurt » 30 Mai 2012, 16:34

Here are three minor cases that result in unexpected behaviours :

- Implicit static Libs variable initialisation problem
Let "LibB.Script.txt" be
Code: Tout sélectionner
declare Integer MyStaticVar;
Void Init() { MyStaticVar = 0; }


And "LibA.Script.txt" be
Code: Tout sélectionner
#Include "LibB.Script.txt" as LibB
Void Init() { LibB::Init(); }


Then, the following is OK :
Code: Tout sélectionner
#Include "LibB.Script.txt" as LibB
main() {   
   LibB::Init();
}

This is also OK :
Code: Tout sélectionner
#Include "LibB.Script.txt" as LibB
#Include "LibA.Script.txt" as LibA
main() {   
   LibA::Init();
}

But this is KO :
Code: Tout sélectionner
#Include "LibA.Script.txt" as LibA
main() {   
   LibA::Init();
}


- TextLib library limitation
Code: Tout sélectionner
log(TextLib::Compose("Hello $<%1$>", "World !"));

Console Output:
_Hello $<%1$>_World !

Where "_" are seemingly unprintable characters.

However there seems to be no problem when storing the result of the call in an API variable, e.g. UIManager.UIAll.BigMessage.

- Empty function quibbling
OK :
Code: Tout sélectionner
Void foo() {}

OK :
Code: Tout sélectionner
Void foo(Integer i) { return; }

KO :
Code: Tout sélectionner
Void foo(Integer i) {}
drmaxkurt
 
Messages: 23
Inscrit le: 14 Mai 2012, 13:17

Re: Maniascript strange behaviours

Messagepar Gugli » 01 Juin 2012, 12:44

Concerning the Text "Compose" function, it's a feature, allowing client-side translations :

When the server Mode script do something such as :
Code: Tout sélectionner
UIManager.UIAll.BigMessage = "Hello !";

Basically, the text "Hello !" will be sent to every player. The client can then translate it. to "Salut !" for exemple.

When you use
Code: Tout sélectionner
UIManager.UIAll.BigMessage = "Hello "^Player.Login^"!";

the text "Hello Gugli!" will be sent to every player : this text is unknown, and can not be translated T_T

To allow text translation, you can use compose :
Code: Tout sélectionner
UIManager.UIAll.BigMessage = TextLib::Compose("Hello $<%1$>!", Player.Login);

The text "_Hello $<%1$> !_World" will be sent ( _ is in fact a weird unicode character ). The client will attempt to translate "Hello $<%1$> !", it will find "Salut $<%1$> !", and then replace the "%1". The client will then show : "Salut Gugli !".

Yay ! Client-side composed translations !

I take good note of the other issues & will investigate further as soon as I have some time (but there are more urgent bugs/crashes to fix first, so it may take a little while).

Thanks for the report.
--
(>~_~)> ═╦═ ╔╦╗ <(~_~<)
Avatar de l’utilisateur
Gugli
Nadeo
Nadeo
 
Messages: 169
Inscrit le: 14 Juin 2010, 17:35
Localisation: Mon PC est à Paris, mais mon coeur rode dans les forêts de Lozère

Re: Maniascript strange behaviours

Messagepar drmaxkurt » 01 Juin 2012, 13:06

Ok thanks for the explanations !

But shouldn't the underscore + round brackets _(...) be used for translations ?
drmaxkurt
 
Messages: 23
Inscrit le: 14 Mai 2012, 13:17

Re: Maniascript strange behaviours

Messagepar m4rcel » 06 Juin 2012, 20:18

[Original Report by Macximilian, he came across the same problem and analyzed it a bit deeper.]

Hey

I have a problem with global variables which are in an included script with "inclusion depth" of more than 1.
If you want to set them the first time, the script crashes at runtime with the error "Variable ... has been undefinied since declaration." It's clear that the variable has not been definied because global variables cannot be defined at declaration. This only happens in scripts, which are included in a script, which is included in the script with the main method.

Example:

Script A (Main Script)
Code: Tout sélectionner
#RequireContext CSmMode
#Include "ScriptB" as B

// declare Boolean GlobalVariable;
// Void ExpendableMethod() {
// }

main() {
  B::DoStuff();
}


Script B
Code: Tout sélectionner
#Include "ScriptC" as C

Void DoStuff() {
  C::SetGlobalVariable();
}


Script C
Code: Tout sélectionner
declare Boolean GlobalVariable;

Void SetGlobalVariable() {
  GlobalVariable = False;
}


I found a strange fix to """solve""" this problem.
If you add a global variable with the same type and name in the script with the main method, the runtime error does not occur anymore. (see out-commented lines in ScriptA!)
You also have to add a stupid expendable method to avoid this error: viewtopic.php?f=373&t=9692 ;)

--
System Configuration
ImageImage
Image
Avatar de l’utilisateur
m4rcel
 
Messages: 525
Inscrit le: 15 Juin 2010, 11:12
Manialink: FunTrackers

Re: Maniascript strange behaviours

Messagepar drmaxkurt » 11 Juin 2012, 19:12

Another spotted singularity : a global variable "Id" seems to be defined (Unassigned) but doesn't appear in the generated documentation.
drmaxkurt
 
Messages: 23
Inscrit le: 14 Mai 2012, 13:17

Re: Maniascript strange behaviours

Messagepar m4rcel » 12 Juin 2012, 09:17

drmaxkurt a écrit:Another spotted singularity : a global variable "Id" seems to be defined (Unassigned) but doesn't appear in the generated documentation.


Macximilian a écrit:If there's the possibility to forward my post to the original thread which you can see in m4rcel's post one above this one - I just want to answer that the object "Id" is of course listed in the documentation - it's the class CSmMode. ;)

( viewtopic.php?f=392&t=10297#p101764 )
ImageImage
Image
Avatar de l’utilisateur
m4rcel
 
Messages: 525
Inscrit le: 15 Juin 2010, 11:12
Manialink: FunTrackers

Re: Maniascript strange behaviours

Messagepar drmaxkurt » 12 Juin 2012, 11:25

Ok, yeah, I got it, it's inherited from CMode, from its own parent CNod !
Thanks ;)
It could be (it was for me !) a trap if you use an innocent local variable Id somewhere... :roll:
drmaxkurt
 
Messages: 23
Inscrit le: 14 Mai 2012, 13:17


Retour vers ManiaScript

Qui est en ligne ?

Utilisateur(s) parcourant actuellement ce forum : Slig et 0 invité(s)