Game Development Community

Accessing C++ objects from scripts

by Mitchell · in Torque Game Engine · 10/11/2007 (8:53 am) · 4 replies

Hey guys,

Is there a way to reference variables (ints, arrays, chars, etc.) that are in code from the scripting engine?

Let's say I wanted to call a function, or get the variable data from an object when I call it from a GUI button click event. I know the GUI is tied to the scripting engine, but can it reference C++ code/objects/variables?

#1
10/11/2007 (9:30 am)
Short answer: if it's in an initpersistfield in the back end, it's shared between script and scource. less short answer: and there are other methods still burried in there that'll take some digging.
#2
10/11/2007 (10:52 am)
How do I make variables/objects initpersistfield?
#3
10/11/2007 (12:21 pm)
@Space Monkey - Depending on what you use to compile, do a find in files (Ctrl+Shift+F in Visual Studio) for the word "initPersistField"

You will find examples of how to expose member variables and objects to script.
#4
10/11/2007 (4:08 pm)
Http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5516

Check that resource out, it will show you how to make a basic object in the engine and usable by script.