iT2D 1.5 - console debug, script variables scope BROKEN (ITGB-292)
by Petr Vodak · in iTorque 2D · 10/23/2011 (4:39 am) · 10 replies
Build: 1.5
Platform: Mac OS X 10.6.8 and iPad 1.1 (iOS 4.3)
Target: Stand alone and device
Issues:
1) Unable to send command to game debug console (debug version of app) via telnet. Connection is ok, but sending any command causes application to crash.
2) BIG issue, NOT SOLVED!
There is different and really strange behavior of local variables (%) in 1.5 iTorque in contrast to 1.7.5 and older TGB engines.
Open www.garagegames.com/community/forums/viewthread/128242 and pls answer there or here. That thread should explain what is happening with local variables with same name used in different functions in 1.5 iTorque. Maybe I am totally confused and we are doing something really wrong, but to be honest, Im 99% sure, there is huge bug with scope of local variables.
Fix for 1:
In engine/source/game/main.cc
Lines 719, 720:
Change code from:
To:
Platform: Mac OS X 10.6.8 and iPad 1.1 (iOS 4.3)
Target: Stand alone and device
Issues:
1) Unable to send command to game debug console (debug version of app) via telnet. Connection is ok, but sending any command causes application to crash.
2) BIG issue, NOT SOLVED!
There is different and really strange behavior of local variables (%) in 1.5 iTorque in contrast to 1.7.5 and older TGB engines.
Open www.garagegames.com/community/forums/viewthread/128242 and pls answer there or here. That thread should explain what is happening with local variables with same name used in different functions in 1.5 iTorque. Maybe I am totally confused and we are doing something really wrong, but to be honest, Im 99% sure, there is huge bug with scope of local variables.
Fix for 1:
In engine/source/game/main.cc
Lines 719, 720:
Change code from:
sprintf(argv[0], "eval"); //argv[0] = "eval";
To:
//sprintf(argv[0], "eval"); argv[0] = "eval";
About the author
www.about-fun.com
Recent Threads
#2
I too have experienced a local variable that did not respect scope...
11/21/2011 (6:41 pm)
Which of his two bugs is Logged as ITGB-292I too have experienced a local variable that did not respect scope...
#3
Not sure if it's a iTorque 1.5 issue, I think it may also happened in 1.4.1.
but it happens now
system: windows
product: itorque 1.5
code sample
above the first assignment of %url is an empty string; oddly not the second.
the only way I got this piece of code working was with a global variable
I can repost this as a new thread if not the same issue
11/21/2011 (8:40 pm)
I too have noticed problems with local variables.Not sure if it's a iTorque 1.5 issue, I think it may also happened in 1.4.1.
but it happens now
system: windows
product: itorque 1.5
code sample
function WordyButtonDictionary::onTouchDown( %this, %modifier, %worldPosition, %clicks )
{
%url = "http://dictionary.reference.com/browse/";
%url = %url @ WordySceneGraph.word;
echo ( %url );
gotowebpage( %url );
}above the first assignment of %url is an empty string; oddly not the second.
the only way I got this piece of code working was with a global variable
function WordyButtonDictionary::onTouchDown( %this, %modifier, %worldPosition, %clicks )
{
$url = "http://dictionary.reference.com/browse/";
$url = $url @ WordySceneGraph.word;
echo ( $url );
gotowebpage( $url );
} I can repost this as a new thread if not the same issue
#4
@Pedro since you have it posted here, whoever looks at the ticket should see that posted since the forum link is attached to the ticket
11/23/2011 (9:12 am)
i logged them both under the same ticket, for what reason, i dont remember :P@Pedro since you have it posted here, whoever looks at the ticket should see that posted since the forum link is attached to the ticket
#5
Please ignore my bug report.
My code above has an error; so, I am in the process of migrating from iTorque 1.4.1 to 1.5, and the input system changed; that code was from my previous 1.4.1 OnMouse event, that I converted to OnTouch event just by replacing the function name.
The correct function signature is
Like this the local variable is correctly affected.
11/24/2011 (9:41 pm)
@JonathanPlease ignore my bug report.
My code above has an error; so, I am in the process of migrating from iTorque 1.4.1 to 1.5, and the input system changed; that code was from my previous 1.4.1 OnMouse event, that I converted to OnTouch event just by replacing the function name.
The correct function signature is
function WordyButtonDictionary::onTouchDown( %this, %touchID, %worldPos )
{
%url = "http://dictionary.reference.com/browse/";
%url = %url @ WordySceneGraph.word;
echo ( %url );
gotowebpage( %url );
}Like this the local variable is correctly affected.
#6
I have the following code (right at the beginning of main.cs)
which outputs
@@--- test start
var is 3 (not from eval)
%var is 3 and par is run1
var is 17 (not from eval)
%var is 17 and par is run1
test end
@@--- test start
var is 3 (not from eval)
%var is 3 and par is run2
var is 17 (not from eval)
%var is 17 and par is run2
test end
@@--- test start
var is 3 (not from eval)
%var is 10 and par is run3
var is 3 (not from eval)
%var is 17 and par is run3
test end
@@--- test start
var is 3 (not from eval)
%var is 17 and par is run4
var is 3 (not from eval)
%var is 17 and par is run4
test end
var is 17 (in GLOBAL scope)
Run 1 and 2 is just fine. Then I define a global variable %var having the same name as the local one in my function. After that, eval in the body of the function seems to access it that global one and it goes wrong...
Can anyone see if I am doing something wrong or is there a problem with iTorque 1.5 ? Any help is appreciated.
12/03/2011 (12:30 pm)
I have experienced very similar behaviour with iTorque 1.5 (both Win and Mac). Local/global scope + eval function produces very strange result.I have the following code (right at the beginning of main.cs)
function test_start(%par)
{
echo("@@--- test start");
%var = 3;
echo("var is" SPC %var SPC "(not from eval)");
eval("echo("%var is" SPC %var SPC "and par is" SPC %par);");
eval("%var = 17;");
echo("var is" SPC %var SPC "(not from eval)");
eval("echo("%var is" SPC %var SPC "and par is" SPC %par);");
echo("test end");
}
test_start("run1");
test_start("run2");
%var = 10;
test_start("run3");
test_start("run4");
echo("var is" SPC %var SPC "(in GLOBAL scope)");which outputs
@@--- test start
var is 3 (not from eval)
%var is 3 and par is run1
var is 17 (not from eval)
%var is 17 and par is run1
test end
@@--- test start
var is 3 (not from eval)
%var is 3 and par is run2
var is 17 (not from eval)
%var is 17 and par is run2
test end
@@--- test start
var is 3 (not from eval)
%var is 10 and par is run3
var is 3 (not from eval)
%var is 17 and par is run3
test end
@@--- test start
var is 3 (not from eval)
%var is 17 and par is run4
var is 3 (not from eval)
%var is 17 and par is run4
test end
var is 17 (in GLOBAL scope)
Run 1 and 2 is just fine. Then I define a global variable %var having the same name as the local one in my function. After that, eval in the body of the function seems to access it that global one and it goes wrong...
Can anyone see if I am doing something wrong or is there a problem with iTorque 1.5 ? Any help is appreciated.
#7
01/06/2012 (5:03 pm)
Huh, anyone? This is really frustrating... :(
#8
03/01/2012 (1:41 pm)
More than 3 month from the first bug report and nothing happened since then. Interesting support...
#10
I posted a fix for this here:
http://www.garagegames.com/community/resources/view/21806
Please let me know if it works for you.
Best of luck!
08/01/2012 (7:43 pm)
Hey guys,I posted a fix for this here:
http://www.garagegames.com/community/resources/view/21806
Please let me know if it works for you.
Best of luck!
Associate redmasqu3rad3
GarageGames