Arrays
by Hardi Bhatt · in Technical Issues · 02/06/2007 (11:14 am) · 3 replies
Hello everyone. I am very new to Torque script but am very familiar with C++ so programming in Torque Script is not necessarily new to me. I am currently in college and taking a 3D gaming class that uses Torque script. I was suggested by my professor to work on modifying Torque Script to implement Array usage as my senior project. You must all know already that there are no such things as Arrays in Torque Script even though you are allowed to use it for usage purposes. So I was wondering if you had any suggestion on what I should look into or where I should concentrate on or even if you have any suggestions what so ever it would be really helpful. I have looked into the Script Array Upgrade article by Daniel Neilsen and found it to be very similar to a Hash Table rather then an array but this was still a very good reference. I would like to know more however, like how I can view the symbol table so that I will be able to modify it or even what type of features you all would like to have so that I can include that in my modification. I am using the TorqueGameEngineSDK-1-4.exe application to do all my modification so please get back to me on this of you can
Thank you
Thank you
About the author
#2
02/07/2007 (1:22 pm)
Yes that is precisely it. He wants arrays as an abstract data type, not a string replacement solution. Because you can sometimes accidentally cross reference the string replacement's and messes up what you are trying to do. And not only that you can not pass arrays between functions you can only pass string replacements on at a time which is very expensive if you want to do complicated procedures within you program, and finally you have no idea of what length this array's string replacement is so you do not know how many time you will need to loop in order to extract all the information you will need for you program. I will definitely look into the SimObject, SimSet and Vector class but if you have any other examples that I can take a look at. It would be a big help, also if you have any suggestions on what I should look into or focus on that would very helpful also. Thank you very much for your help and I look forward to reading you responses.
#3
Once you get your abstract data type defined, and then come up with a reference implementation in c++, your last step will be creating a new class to implement the reference implementation, and expose it to script.
I will let you know that it's going to be a bit tricky, since the main reason that the Vector class isn't exposed in the first place is because to be exposed to script, it needs to either be a class that is a child of SimObject, or written as global functions (operators, basically). That's a mix of what you'd normally expect, so will require some research into how the console and byte code compiler works.
If you wouldn't mind, could you and/or your instructor email me? I don't in any way plan on trying to talk him out of assigning this task, but I do want to make sure he realizes it's not as trivial as it appears on the surface, either.
02/07/2007 (9:56 pm)
SimSet honestly is your best plan. It's not going to show you how to implement a dynamic array (which you're going to want to do), but it will show you exactly how to expose an implementation of an abstract data type via ConsoleMethods.Once you get your abstract data type defined, and then come up with a reference implementation in c++, your last step will be creating a new class to implement the reference implementation, and expose it to script.
I will let you know that it's going to be a bit tricky, since the main reason that the Vector class isn't exposed in the first place is because to be exposed to script, it needs to either be a class that is a child of SimObject, or written as global functions (operators, basically). That's a mix of what you'd normally expect, so will require some research into how the console and byte code compiler works.
If you wouldn't mind, could you and/or your instructor email me? I don't in any way plan on trying to talk him out of assigning this task, but I do want to make sure he realizes it's not as trivial as it appears on the surface, either.
Torque 3D Owner Stephen Zepp
Personally, I would focus on studying the SimObject, and then the SimSet implementation. SimObject gives the internals of how objects inter-relate, and SimSet is in fact an abstract data type that is very capable.
Additionally, you may want to take a look at the Vector class--it's almost what your instructor is asking for, but it isn't exposed to the scripting language, since there are certainly some pitfalls that need to be protected against for a true abstract data type implementation.