Moving pieces of script into compiled code?
by Danner Jones · in Torque Game Engine · 01/24/2004 (7:25 pm) · 5 replies
I know people have asked about moving away from script before and purely to compiled code. Before you go on about the benefits of script - I agree! But, I'd like to know how I might move some of the script code into compiled code. Has anyone written a resource or a tutorial for this? I tried doing a number of keyword searches, but I either get no hits or FAR too many.
If this has NOT been done before, could someone offer up a pointer? Say I wanted to move out just crossbow.cs, or even just a part of it (one set of the particle effects)... I'm not quite sure of the relationship between the compiled code and how/when/where it calls into the scripts.
Thanks in advance,
Nerseus
If this has NOT been done before, could someone offer up a pointer? Say I wanted to move out just crossbow.cs, or even just a part of it (one set of the particle effects)... I'm not quite sure of the relationship between the compiled code and how/when/where it calls into the scripts.
Thanks in advance,
Nerseus
#2
For example, how to convert the crossbow object itself, of type datablock ItemData in script. Obviously ItemData is a C++ class that inherits from ShapeBaseData and I could create an object in C++ code that is of type ItemData. But, where would I put the code so that it would get created at the same time as a DataBlock would in script? How would I subscribe to the events that are called automatically in script (such as the CrossbowItems's onFire event)?
I realize it may be impossible to move some objects to code by themselves - since Crossbow inherits all the properties of the script class "weapon". I'd like to better understand how the script is getting called and how I might do the same thing via code.
-Nerseus
01/24/2004 (7:54 pm)
Actually, I know how to add new console commands and I've seen the macros for creating new datablock types. I was more interested in how I might move code away from the script into compiled code completely.For example, how to convert the crossbow object itself, of type datablock ItemData in script. Obviously ItemData is a C++ class that inherits from ShapeBaseData and I could create an object in C++ code that is of type ItemData. But, where would I put the code so that it would get created at the same time as a DataBlock would in script? How would I subscribe to the events that are called automatically in script (such as the CrossbowItems's onFire event)?
I realize it may be impossible to move some objects to code by themselves - since Crossbow inherits all the properties of the script class "weapon". I'd like to better understand how the script is getting called and how I might do the same thing via code.
-Nerseus
#3
01/25/2004 (5:19 am)
That would be a hard one. Wish you the best of luck.
#4
-Nerseus
01/25/2004 (6:53 am)
Let's assume it wasn't crossbow but something else - a new object of type ItemData with NO other script dependencies. Anyone have any ideas at least where to start looking?-Nerseus
#5
That said, read through the console/* files of the engine and you shall receive enlightenment.
01/25/2004 (1:23 pm)
You don't want to put datablocks into C++. If you're particularly concerned, you can just distribute the DSOs containing the data - it'll be about as secure as having it created semi-statically in C++.That said, read through the console/* files of the engine and you shall receive enlightenment.
Torque Owner Dan -
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5103
It shows how to create new commands that you can call from scripting. You could (and I have) used it to take multiple script functions and roll them into 1 new console command.
Not sure how you would replace and entire module. You would not only have to replace the script function but get hooked into the calls to the scripting language themselves.