Game Development Community

How to best "port" a command line game

by NaF · in Torque 3D Beginner · 04/25/2013 (5:16 am) · 2 replies

Hi guys,

Until now I coded my game completely as a command line game. Now I would like to move all my stuff to
torgue so I can start on visualizing numbers and menus with torgue UI.


Is there a way to directly connect my old c++ command line code to torgue?



Example:
I have a string vector with a number of elements in it. Can I just display a picked element in a UI?
(similar to just showing it in the console with cout)


Thanks in advance,
NaF


About the author

Recent Threads


#1
04/25/2013 (7:20 am)
So, you're basically trying to expose your C++ code to TorqueScript?

This is relatively simple:

Copying right from my forums here:
DefineEngineFunction(TSFunctionName, Return Type, (Parameters), (Default Parameters (usually don't use)), "Documentation Generation String") {
   //Do Code Here
}

DefineEngineMethod is used for a class specific call, IE: Player.applyDamage();

Which requires the following headers be on your C++ file:
#include "platform/platform.h"
#include "console/console.h"
#include "console/consoleInternal.h"
#include "console/engineAPI.h"

As for printing to the torque console, you can just use:
Con::printf("Same syntax as C++ printf().");

Which just requires the console.h header.

Good luck!
#2
04/25/2013 (10:39 am)
Please show us what it looks like with a screen shot. I think what you want is doable, but it not coming across lucidly.