EditorGui.cs bug fix code
by Harley · in Torque Game Engine · 05/27/2005 (5:17 am) · 6 replies
Hi guys,
I got the following bug fix code for the EditorGui.cs script file from the link below and something is puzzling me: What is the difference between the values that are returned from obj.className and obj.getClassName? I would have though these would have been the same? I have tried using echo(%obj.className) and echo(%obj.getClassName) in the dataBlock::create function but both lines of code return an empty string.
Thanks for any assistance,
Harley.
resource link: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2730
bug fix code:
if( (%obj.className !$="") && (%obj.getClassName !$=%obj.className) )
%this.addItem(%grp, %obj.getName(), %obj.className @ "::create(" @ %obj.getName() @ ");");
else
%this.addItem(%grp, %obj.getName(), %obj.getClassName() @ "::create(" @ %obj.getName() @ ");");
I got the following bug fix code for the EditorGui.cs script file from the link below and something is puzzling me: What is the difference between the values that are returned from obj.className and obj.getClassName? I would have though these would have been the same? I have tried using echo(%obj.className) and echo(%obj.getClassName) in the dataBlock::create function but both lines of code return an empty string.
Thanks for any assistance,
Harley.
resource link: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2730
bug fix code:
if( (%obj.className !$="") && (%obj.getClassName !$=%obj.className) )
%this.addItem(%grp, %obj.getName(), %obj.className @ "::create(" @ %obj.getName() @ ");");
else
%this.addItem(%grp, %obj.getName(), %obj.getClassName() @ "::create(" @ %obj.getName() @ ");");
#2
05/27/2005 (2:00 pm)
I believe getClassName is the function call and className is just a variable (which may or may not be set depending on the object).
#3
Would return
Hope that clears it up for ya!
05/27/2005 (4:25 pm)
%obj.ClassName is the variable as it was declared in the datablock, and would be the same for all intances of that class. %obj.className is the className as it currently stands.datablock MyData(){
ClassName = MyWeapon;
}
%obj = new MyData();
%obj.className = MyToy;
echo %obj.getClassName();
echo %obj.ClassName;Would return
MyWeapon MyToy
Hope that clears it up for ya!
#4
@Justin Tolchin - thanks for that, I think I just copied the code from the resource, I didn't pick that up.
@Dreamer - yeh I think that clears it up: so getClassName() returns the original (for lack of a better word) datablock className value and className returns the instantiated datablocks className value? Seems a bit strange that getClassName() doesn't just return className though? I'm still pretty rusty on the scripting side of things so it will probably all make sense in time...
Thanks again,
Harley.
05/27/2005 (9:24 pm)
Thanks for the responses everyone.@Justin Tolchin - thanks for that, I think I just copied the code from the resource, I didn't pick that up.
@Dreamer - yeh I think that clears it up: so getClassName() returns the original (for lack of a better word) datablock className value and className returns the instantiated datablocks className value? Seems a bit strange that getClassName() doesn't just return className though? I'm still pretty rusty on the scripting side of things so it will probably all make sense in time...
Thanks again,
Harley.
#5
Another thing to note about TorqueScript is that it is case in-sensitive; thus "className", "ClassName" and "classname" all refer to the same variable instance.
05/28/2005 (12:55 am)
@Harley: The purpose to the function getClassName() is to return the actual code class of an object and is usable on any object, not just datablocks. Everything else are just variables and can be changed at any time. In the case of a datablock, the initial value of the variable is stored as it's "original object type". Different purposes for different jobs with the challange being the task of deciding "what's the right tool for the right job" to which I can only say "read more of other people's code". It's the best way to learn. Once you see a bit of code that doesn't make sense to you, search it out, research it, understand it and then move on. It's very much like something one of my english teachers once taught me when reading a new book... "don't skim over the words (or sentences) that you don't understand. Stop reading, pick up the dictionary and look up the word because if you don't then by the time you get to the end of the book you'll have totally missed the author's true intention for the story" (I'm sure my teacher didn't come up with this line or if he did he modified it as I've yet to find who originally said the quote).Another thing to note about TorqueScript is that it is case in-sensitive; thus "className", "ClassName" and "classname" all refer to the same variable instance.
#6
Thanks everyone for your help, muchly appreciated.
Harley.
05/28/2005 (2:17 am)
@OneST8 : ah that clears it up for me, thanks. In regards to the whole researching the code you dont understand - I totally agree and thats actually what I am doing at the moment. I have printed off the whole creator::init() function and am going through it (there are quite a few function calls I am not sure on). Thats how I came to ask this question. I just didn't really notice these particular lines of code until the other day.Thanks everyone for your help, muchly appreciated.
Harley.
Torque Owner Justin Tolchin
should be