Accessing native code from scripting and vice versa
by Rodrigo Furlan · in Torque Game Engine · 12/01/2001 (10:17 am) · 9 replies
Hi there,
I was wondering:
-> How can I make a scripted function available to be called from the in-game console?
-> How can I "publish" objects and methods from native code to be accessed by scripted code?
-> Is there anywhere a list of built-in Torque (not T2)objects/methods, functions and events available to the scripting engine?
-> Why can't we search the body of posts here in forums?
Thank you folks!
Cyq
I was wondering:
-> How can I make a scripted function available to be called from the in-game console?
-> How can I "publish" objects and methods from native code to be accessed by scripted code?
-> Is there anywhere a list of built-in Torque (not T2)objects/methods, functions and events available to the scripting engine?
-> Why can't we search the body of posts here in forums?
Thank you folks!
Cyq
About the author
#2
>basically if I hit tilda "~" to bring up the console I >then type:
>commandtoserver('addlaser');
I have a function called addbot and this is working for me too. But if I wouold like to make a function like kill(botid)?
>2)I have no idea what you mean . . publish?
For example, I go to the AIPlayer class code (in the source code), fix it and want to make a custom developed method like "pursuePlayer(%player)" available to the scripting subsystem, allowing me to script something like this:
%myEvilBot.pursuePlayer(%player)
>3)A complier like Visual Studio will have ALL the >methods from the whole source code arranged somewhere >there to access from.
But my problem is not with the source code :) I want to know what objects/methods and events are exposed to the scripting subsystem. Not all of them are :)
>4)If you buy the code from GG you will have full acess >to all the forums, otherwise . . . . . hmmmmmmmmm
I have the source code, but when I go to the advanced search options, the checkbox for searching the body of the messages is disabled :((( try it by yourself to see.
Thanks,
Cyq
12/01/2001 (11:17 am)
Hi Anthony!>basically if I hit tilda "~" to bring up the console I >then type:
>commandtoserver('addlaser');
I have a function called addbot and this is working for me too. But if I wouold like to make a function like kill(botid)?
>2)I have no idea what you mean . . publish?
For example, I go to the AIPlayer class code (in the source code), fix it and want to make a custom developed method like "pursuePlayer(%player)" available to the scripting subsystem, allowing me to script something like this:
%myEvilBot.pursuePlayer(%player)
>3)A complier like Visual Studio will have ALL the >methods from the whole source code arranged somewhere >there to access from.
But my problem is not with the source code :) I want to know what objects/methods and events are exposed to the scripting subsystem. Not all of them are :)
>4)If you buy the code from GG you will have full acess >to all the forums, otherwise . . . . . hmmmmmmmmm
I have the source code, but when I go to the advanced search options, the checkbox for searching the body of the messages is disabled :((( try it by yourself to see.
Thanks,
Cyq
#3
To create a global var:
con::addVariable(const char *name, S32, void *);
To write to a global var:
con::setVariable(const char *name, const char *value);
To remove a global var:
con::removeVariable(const char *name);
To read a global var's value:
con::getVariable(const char* name);
To read a local var:
con::getLocalVariable(const char* name);
To write to a local var:
con::setLocalVariable(const char *name, const char *value);
To publish a string-typed funcion/method:
con::addCommand(const char *name, StringCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a int-typed funcion/method:
con::addCommand(const char *name, IntCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a float-typed funcion/method:
con::addCommand(const char *name, FloatCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a void-typed funcion/method:
con::addCommand(const char *name, VoidCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a bool-typed funcion/method:
con::addCommand(const char *name, BoolCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped string-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,StringCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped int-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,IntCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped float-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,FloatCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped void-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,VoidCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped bool-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,BoolCallback, const char *usage, S32 minArgs, S32 maxArgs);
Good luck everyone :)
Cyq
12/01/2001 (4:28 pm)
I just figured out how to interface native code to scripting. GG staff, is this right?To create a global var:
con::addVariable(const char *name, S32, void *);
To write to a global var:
con::setVariable(const char *name, const char *value);
To remove a global var:
con::removeVariable(const char *name);
To read a global var's value:
con::getVariable(const char* name);
To read a local var:
con::getLocalVariable(const char* name);
To write to a local var:
con::setLocalVariable(const char *name, const char *value);
To publish a string-typed funcion/method:
con::addCommand(const char *name, StringCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a int-typed funcion/method:
con::addCommand(const char *name, IntCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a float-typed funcion/method:
con::addCommand(const char *name, FloatCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a void-typed funcion/method:
con::addCommand(const char *name, VoidCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a bool-typed funcion/method:
con::addCommand(const char *name, BoolCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped string-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,StringCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped int-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,IntCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped float-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,FloatCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped void-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,VoidCallback, const char *usage, S32 minArgs, S32 maxArgs);
To publish a scoped bool-typed funcion/method:
con::addCommand(const char *nameSpace, const char *name,BoolCallback, const char *usage, S32 minArgs, S32 maxArgs);
Good luck everyone :)
Cyq
#4
Built in classes available to the scripting subsystem:
-----------------------------------
AudioEnvironment;
AudioSampleEnvironment;
AudioDescription;
AudioProfile;
ScriptObject;
SimObject;
SimDataBlock;
SimSet;
SimGroup;
FileObject;
MaterialPropertyMap;
CreatorTree;
EditTSCtrl;
EditManager;
GuiTerrPreviewCtrl;
MissionAreaEditor;
Terraformer;
TerrainEditor;
WorldEditor;
AIConnection ;
AIPlayer ;
AudioEmitter;
ClientAudioEmitter;
AudioEmitterToEvent;
BanList;
CameraData;
Camera;
DebrisData;
Debris;
DebugView;
GameBaseData;
GameBase;
GameConnection;
SimDataBlockEvent;
Sim2DAudioEvent;
Sim3DAudioEvent;
SetMissionCRCEvent;
GameTSCtrl;
GuiNoMouseCtrl;
GuiPlayerView ;
ItemData;
Item;
MissionArea;
MissionMarkerData;
MissionMarker;
WayPoint;
SpawnSphere;
PhysicalZone;
PlayerData;
Player;
ProjectileData;
Projectile;
ScopeAlwaysShape;
ShapeBaseImageData;
ShapeBaseData;
ShapeBase;
ShowTSCtrl;
StaticShapeData;
StaticShape;
TriggerData;
Trigger;
TSStatic;
GuiClockHud ;
GuiCrossHairHud ;
GuiHealthBarHud ;
GuiShapeNameHud ;
ExplosionData;
Explosion;
LightningStrikeEvent;
LightningData;
Lightning;
ParticleEmissionDummyData;
ParticleEmissionDummy;
ParticleData;
ParticleEmitterData;
PrecipitationData;
Precipitation;
SplashData;
Splash;
HTTPObject;
RemoteCommandEvent;
SimpleMessageEvent;
SimpleNetObject;
TCPObject;
FlyingVehicleData;
FlyingVehicle;
HoverVehicleData;
HoverVehicle;
VehicleData;
Vehicle;
VehicleBlocker;
WheeledVehicleData;
WheeledVehicle;
GuiArrayCtrl;
GuiAviBitmapCtrl;
GuiAviBitmapCtrl;
GuiAviBitmapCtrl;
GuiBackgroundCtrl;
GuiBitmapCtrl;
GuiBubbleTextCtrl;
GuiButtonBaseCtrl;
GuiButtonCtrl;
GuiCanvas;
GuiCheckBoxCtrl;
GuiChunkedBitmapCtrl;
GuiConsole;
GuiConsoleEditCtrl;
GuiConsoleTextCtrl;
GuiControl;
GuiControlListPopUp;
DbgFileView;
GuiEditCtrl;
GuiFilterCtrl;
GuiFrameSetCtrl;
GuiInputCtrl;
GuiInspector;
GuiMLTextCtrl;
GuiMLTextEditCtrl;
GuiMenuBar;
GuiMessageVectorCtrl;
GuiMouseEventCtrl;
GuiPopUpMenuCtrl;
GuiProgressCtrl;
GuiRadioCtrl;
GuiScrollCtrl;
GuiSliderCtrl;
GuiTSCtrl;
GuiTextCtrl;
GuiTextEditCtrl;
GuiTextEditSliderCtrl;
GuiTextListCtrl;
GuiTreeViewCtrl;
GuiCursor;
GuiControlProfile;
GuiWindowCtrl;
MessageVector;
InteriorInstance;
MirrorSubObject;
ActionMap;
DecalData;
DecalManager;
NetStringEvent;
NetConnection;
GhostingMessageEvent;
GhostAlwaysObjectEvent;
NetObject;
PathManagerEvent;
SceneObject;
Path;
Marker;
Sky;
Sun;
TerrainBlock;
WaterBlock;
TSShapeConstructor;
Use the DECLARE_CONOBJECT macro like this:
DECLARE_CONOBJECT(yourClassNameHere);
To publish your own classes to be available to the scripting subsystem.
See you soon!
Cyq
12/02/2001 (1:07 pm)
More info about interfacing native code and scripted code, may help someone :)Built in classes available to the scripting subsystem:
-----------------------------------
AudioEnvironment;
AudioSampleEnvironment;
AudioDescription;
AudioProfile;
ScriptObject;
SimObject;
SimDataBlock;
SimSet;
SimGroup;
FileObject;
MaterialPropertyMap;
CreatorTree;
EditTSCtrl;
EditManager;
GuiTerrPreviewCtrl;
MissionAreaEditor;
Terraformer;
TerrainEditor;
WorldEditor;
AIConnection ;
AIPlayer ;
AudioEmitter;
ClientAudioEmitter;
AudioEmitterToEvent;
BanList;
CameraData;
Camera;
DebrisData;
Debris;
DebugView;
GameBaseData;
GameBase;
GameConnection;
SimDataBlockEvent;
Sim2DAudioEvent;
Sim3DAudioEvent;
SetMissionCRCEvent;
GameTSCtrl;
GuiNoMouseCtrl;
GuiPlayerView ;
ItemData;
Item;
MissionArea;
MissionMarkerData;
MissionMarker;
WayPoint;
SpawnSphere;
PhysicalZone;
PlayerData;
Player;
ProjectileData;
Projectile;
ScopeAlwaysShape;
ShapeBaseImageData;
ShapeBaseData;
ShapeBase;
ShowTSCtrl;
StaticShapeData;
StaticShape;
TriggerData;
Trigger;
TSStatic;
GuiClockHud ;
GuiCrossHairHud ;
GuiHealthBarHud ;
GuiShapeNameHud ;
ExplosionData;
Explosion;
LightningStrikeEvent;
LightningData;
Lightning;
ParticleEmissionDummyData;
ParticleEmissionDummy;
ParticleData;
ParticleEmitterData;
PrecipitationData;
Precipitation;
SplashData;
Splash;
HTTPObject;
RemoteCommandEvent;
SimpleMessageEvent;
SimpleNetObject;
TCPObject;
FlyingVehicleData;
FlyingVehicle;
HoverVehicleData;
HoverVehicle;
VehicleData;
Vehicle;
VehicleBlocker;
WheeledVehicleData;
WheeledVehicle;
GuiArrayCtrl;
GuiAviBitmapCtrl;
GuiAviBitmapCtrl;
GuiAviBitmapCtrl;
GuiBackgroundCtrl;
GuiBitmapCtrl;
GuiBubbleTextCtrl;
GuiButtonBaseCtrl;
GuiButtonCtrl;
GuiCanvas;
GuiCheckBoxCtrl;
GuiChunkedBitmapCtrl;
GuiConsole;
GuiConsoleEditCtrl;
GuiConsoleTextCtrl;
GuiControl;
GuiControlListPopUp;
DbgFileView;
GuiEditCtrl;
GuiFilterCtrl;
GuiFrameSetCtrl;
GuiInputCtrl;
GuiInspector;
GuiMLTextCtrl;
GuiMLTextEditCtrl;
GuiMenuBar;
GuiMessageVectorCtrl;
GuiMouseEventCtrl;
GuiPopUpMenuCtrl;
GuiProgressCtrl;
GuiRadioCtrl;
GuiScrollCtrl;
GuiSliderCtrl;
GuiTSCtrl;
GuiTextCtrl;
GuiTextEditCtrl;
GuiTextEditSliderCtrl;
GuiTextListCtrl;
GuiTreeViewCtrl;
GuiCursor;
GuiControlProfile;
GuiWindowCtrl;
MessageVector;
InteriorInstance;
MirrorSubObject;
ActionMap;
DecalData;
DecalManager;
NetStringEvent;
NetConnection;
GhostingMessageEvent;
GhostAlwaysObjectEvent;
NetObject;
PathManagerEvent;
SceneObject;
Path;
Marker;
Sky;
Sun;
TerrainBlock;
WaterBlock;
TSShapeConstructor;
Use the DECLARE_CONOBJECT macro like this:
DECLARE_CONOBJECT(yourClassNameHere);
To publish your own classes to be available to the scripting subsystem.
See you soon!
Cyq
#5
When should I use the macros ConsoleFunction and ConsoleMethod instead of con::addCommand???
12/02/2001 (1:26 pm)
Help!When should I use the macros ConsoleFunction and ConsoleMethod instead of con::addCommand???
#6
Both ways still work though.
Josh
12/02/2001 (6:45 pm)
That was answered in another thread. If I recall correctly, the macros are the older, depricated, way of doing things.Both ways still work though.
Josh
#7
The inability to search the body of the posts really make difficult finding specific info like this :)
[]'s
Cyq
12/02/2001 (7:03 pm)
Thanks!The inability to search the body of the posts really make difficult finding specific info like this :)
[]'s
Cyq
#8
Yes not being able to search body text is becoming intensely irritating. I offered to try and help Tim with this, we'll see what happens.
12/05/2001 (5:09 pm)
Most of that info above was already in the documentation... as well as descriptions of ConsoleMethod etc.Yes not being able to search body text is becoming intensely irritating. I offered to try and help Tim with this, we'll see what happens.
#9
>documentation... as well as descriptions of
>ConsoleMethod etc.
Ohh, sorry about that, I gave up searching anything in Torque's documentation a while ago, I pay more attention to it next time.
>Yes not being able to search body text is becoming
>intensely irritating. I offered to try and help Tim
>with this, we'll see what happens.
There's no point in having a forum as knowledge base if the information once stored can not be recovered! I am aware now they were having some serious performance problems so I think we should be patient. I just hope they can fix it. This is why I love ColdFusion, the Verity search engine is really efficient...
[]'s
Cyq
12/06/2001 (12:05 pm)
>Most of that info above was already in the >documentation... as well as descriptions of
>ConsoleMethod etc.
Ohh, sorry about that, I gave up searching anything in Torque's documentation a while ago, I pay more attention to it next time.
>Yes not being able to search body text is becoming
>intensely irritating. I offered to try and help Tim
>with this, we'll see what happens.
There's no point in having a forum as knowledge base if the information once stored can not be recovered! I am aware now they were having some serious performance problems so I think we should be patient. I just hope they can fix it. This is why I love ColdFusion, the Verity search engine is really efficient...
[]'s
Cyq
Associate Anthony Rosenbaum
1) here is my code to add a weapon while in game with the console
//add for spawning function serverCmdAddLaser(%client) { %weapon = new Item() { dataBlock = Laser; }; MissionCleanup.add(%weapon); %weapon.setTransform(%client.player.getEyeTransform()); }basically if I hit tilda "~" to bring up the console I then type:commandtoserver('addlaser');
and a laser will pop up at th elocation I am standing at (BTW that is a weapon w/o ammo so you need acode to spawn ammo too)
2)I have no idea what you mean . . publish?
3)A complier like Visual Studio will have ALL the methods from the whole source code arranged somewhere there to access from.
4)If you buy the code from GG you will have full acess to all the forums, otherwise . . . . . hmmmmmmmmm
Anthony