Game Development Community

Help with .CPP and.CS

by Jan-Reinald Viardo · in Torque Game Engine Advanced · 09/07/2009 (4:25 am) · 5 replies

Hi, I am really new to Torque Game Programming and I am wondering if someone could help me with my problem or send me a link to a guide. I am having problems making a global variable in .CPP and I want it changed in .CS. For example. How do I create a global boolean in C++ and how can I change the value of it in TorqueScript (.CS). Please help me. Thank you very much. A detailed explanation would be appreciated. Thanks

#1
09/07/2009 (6:40 am)
Use the documentation link under the Support menu on this website.

Go to the section that states "TorqueScript Overview" under the TGEA section. There is a whole part on Variables and making them accessible in the engine and in script.

The other option is to look at the source code you have, specifically the "torqueConfig.h" file ... this has variables that are set in the engine (.cpp) and then used in (.cs) and visa-versa.
#2
09/09/2009 (9:26 am)
I still can't find the answer to my question. I don't get it. How can I be able to declare a boolean data type in C++ and how can the value of it be changed in torquescript? How can I change the value of the boolean to true or false in torquescript? Sorry for this very beginner question. But this would help me a lot. Thanks..
#3
09/09/2009 (1:49 pm)
What you want to do is create the variable in whatever class you are working with, and then create get/set functions and their ConsoleMethod counterparts in order to work with them, instead of exposing them directly.

You'll be able to find all kinds of references to ConsoleMethods in the engine- they're in just about every class, and a project search will turn up literally hundreds of examples to follow.

Hope that helps.
#4
09/10/2009 (11:46 pm)
Ok. Thanks. What is the difference between consolemethod and consolefunction?
#5
09/11/2009 (12:43 am)
IIRC: A consolemethod is a function on an object instance. A consolefunction is a global function (no object needed).