Game Development Community

Torque Script

by Student-GameDevelopment · in Torque Game Engine · 07/23/2009 (7:36 am) · 3 replies

Hello everyeone,
I am having trouble with one thing about the scripting. I have a lot of C++ experience, and the script mimics that which is good. However, in C++ you have headers that you place in your modules which allows access to all your data across the modules. I understand in torque i can make a player.cs, and item.cs, monster.cs and so on. How do i make them all come together? Do i have to do something in main.cs so torque knows about them?

And with functions, if i create functions in the player.cs for handling leveling up, and adding picked up items to an item array, how does torque know when to call those functions?

I have read the docs, they are helpful, but not enough i guess. Would be nice to see the scripts to a game that works and does a bit of what i am trying to do. Give me something to study and go by.

Also, i cannot draw well in the constructor, do you know a place where i can get free monster and item models? They dont have to be of great quality, but i dont understand the constructor because i am not an artist.

Thanks

Westwood Online college student

#1
07/23/2009 (10:21 am)
Quote:
I understand in torque i can make a player.cs, and item.cs, monster.cs and so on. How do i make them all come together? Do i have to do something in main.cs so torque knows about them?

And with functions, if i create functions in the player.cs for handling leveling up, and adding picked up items to an item array, how does torque know when to call those functions?
Just make sure that your script file(s) get's executed. Your functions would have to be called from somewhere. They can be piggybacked off of a callback or you can have an initial call that sets off a "cascading" chain of events.

Quote:
Would be nice to see the scripts to a game that works and does a bit of what i am trying to do. Give me something to study and go by.
What are your trying to do? You should have two starter kits, a racing and a FPS kit. They are simplistic and aren't fully featured games but should be rather easy to follow to give you a jumpstart. Just start from main.cs follow the links. Turn on trace " trace(1); " and you can see the script flow in the console -- just add that trace command to where you want the "feedback" to start displaying and use trace(0); to turn it off. It's a little used tool that's great for debugging scripts but can also be used to understand the program flow from beginning to end if you add it as the first line in main.cs.

Quote:
Also, i cannot draw well in the constructor, do you know a place where i can get free monster and item models? They dont have to be of great quality, but i dont understand the constructor because i am not an artist.
There is some "free" art to be found here and there but the problem with such free art is that it often needs to be exported for use in Torque. You can find some free stuff here on the forums and the Resources section that is already "Torque-ready" -- but you'll have to do some digging (search) to find them. First lesson about Constructor: you wouldn't use it for creatures and items anyway. It's mainly for structures -- Interior shapes.

Hope that helps a little to get you looking in the right directions.

#2
07/23/2009 (10:36 am)
Ok thank you for your reply. So if the constructor is for structures, what do i use to create items, weapons, monsters?

What am i trying to do?
I would like to create a first person RPG, similar to oblivion. Although i know i wont be able to make the graphics as good, but it looks like the scripting would allow me to create quest chains.

I will try out the trace command on the fps starter kit to see how it attackes a weapon to the screen, and lets you shoot it. I need to also learn how to do weapon to monster collision, for fighting.

I am definately not used to a library that has full control over what is going on, but I think the script might give me more freedom than it seems at first glance, i just need to get to know it well.

So the main.cs is like the winmain for C++ i assume, i put all other files i need loaded in there using the exec command i think. That is what it looks like the one in the starter kit is doing. Then i have a main function in there that calls the other functions from the other files? Meaning, if i loaded a player.cs, and an item.cs, would main.cs be able to call the functions in those files?

Am i on the right track here?

Thank you for your time.
#3
07/23/2009 (10:59 am)
Any 3d modeling application in which you can export to the .dts format can be used for Torque, this could be Blender, Milkshape, XSI, Houdini, Maya, Lightway, 3DS Max, etc.

I don't have the links anymore but there was a series of Tutorials/Guides by a user called Dreamer who stepped through building a RPG -- I'm sure a search would turn those up.

The actual mounting procudure for mounting is kind of spread out across the scripts, so that may be a little confusing at first. Key areas to look at would be inventory.cs, item.cs, weapons.cs, and also in player.cs.
Quote:
I think the script might give me more freedom than it seems at first glance, i just need to get to know it well.
Torque script is very flexible and powerful despite it's apparent simplicity. It does take a little getting used to though. I've been a fan of Torque Script back from when I modded Tribes.

The main.cs in the root directory is what gets the different "modules" started and tells the executable how to parse some command line parameters. The modules can be described as:
  • common - which is the core script functionality that virtually all Torque based will use over and over.
  • tools - editor module
  • game - this where the actual game code resides. In the example projects these are the individual starter.fps or starter.racing directories.

  • Inside of each of these sections you will find another main.cs or init.cs file that actually loads the individual script files for each module. For the game components there will be a game.cs in the server scripts that exec's all of the relevant game code. Some people find it confusing seeing a lot of the same named files and even the same functions being repeated across the common and "game" folders. The simplest way to think of this duplication is that the common package gets things started and ready for you. Your game package overrides what it needs to in order to make you game work the way you want it.

    So yeah you were on the right track, and you probably would have noticed the "branching" nature of the scripts rather quickly -- but a little extra information doesn't hurt, I hope.

    Start exploring, have fun, and good luck. You'll find that many people around here are helpful when you need a little help or insight. There's also a lot of common knowledge and information to be found here on the forums -- chances are that if you hit a stumbling block someone somewhere already knows how to overcome it.