Game Development Community

Integrate level builder with script

by Siddharth Hegde · in Torque Game Builder · 04/29/2006 (5:06 am) · 8 replies

Hi,

I am creating a level using the level builder tool and would like to access some of the elements created here in a script, orr would like to apply some script to some elements. Is there any tutorial / guide that will show me how to do this?

Also is there any guide as to how the main.cs, game.cs and level builder interact with each other and their execution order?

Thanks,

- Sid

#1
04/29/2006 (5:53 am)
These kinds of questions should really be asked in the private forums, and there are some threads there already that talk about using script stuff with the level builder.
#2
04/29/2006 (5:54 am)
Unfortunately it can't.

Level builder loads the level saved in yourgame/data/levels/levelname.t2d.
This file is actually a TorqueScript file and you can edit as you wish. You may apply scripts to elements as you wish though. Just put them in the game.cs file, or even better, create a new script file, say "myElement.cs" where the scripts for that element will be and load it from game.cs with " exec("./myElement.cs"); ".

main.cs calls game.cs. where the startGame() function is. But if levelBuilder jumps in first, the startGame() function is only called thru it.

HTH

@Philip
I disagree that this is a private forum question. It doesn't contain refferences to the engine itself, which is under NDA.
#3
04/29/2006 (6:02 am)
Isn't the editors covered by the NDA when it comes to TGB ?? I was under that impression atleast..
#4
04/29/2006 (7:12 am)
While the EULA is a bit out of date since it references T2D still, the general principles still apply:
Quote:
(d) Licensee may not distribute the source code or documentation to the engine in any manner, unless recipient also has a license to the Engine.

(e) Licensee may not distribute uncompiled script code which defines any Torque 2D-specific functionality, including but not limited to creating or mainpulating sprites, tiles, particle effects, etc, in any manner, unless recipient also has a license to the Engine.

(f) Licensee may not distribute any Torque 2D-specific editors, including but not limited to the Tile Editor and Particle Editor, in any manner, unless recipient also has a license to the Engine.

In my opinion, while the discussion so far has not broken the EULA yet, Philip is right in that we can be much more helpful in answering the questions if they were asked in the private forums. In fact, there already is at least 1 thread about this particular subject in the Getting Started section (I know because I took part in it).

Simply, the private forums allow us to post code there which would no doubt help Sid better understand the current level builder interaction with script. If it's not clear how to access the private forums, at the top of the page click on community/forums. Near the top of that page you should see an edit forums subscriptions link. In there check the box next to the Torque Game Builder Private Forums.
#5
04/29/2006 (6:51 pm)
@Mike,

AFAIK your quote only applies to the distribution of complete games. There is a big section on T2D docs that explain how to "package" your game for delivery.

It makes no sense to forbid publishing of script code that is already made public in the T2D demo.

What you cannot post here is C++ code from the engine.
#6
04/29/2006 (9:09 pm)
@Bruno,
That is entirely untrue, you can infact link Level elements in the LevelBuilder to script snippets and functions quite easily. While there is no official example of this available as it applies to the LevelBuilder, it uses the same concept of script callbacks, configuration datablocks and namespace linking to achieve this. These are used throughout all torque games and thus it's support is built upon pre-existing technologies as well as new ones.


@Siddharth,
There are ways to accomplish this and even a preliminary bounty submission that is linked as an example of this in the following private forum thread. Hope this helps and good luck on your game!

Forum Thread (Must own TGB to view) - http://www.garagegames.com/mg/forums/result.thread.php?qt=43354

Cheers,
-Justin
#7
04/30/2006 (1:17 am)
Hi,

Thanks for the help guys. Hopefully I should be able to figure it out from here.

Also sorry abt posting in the pulic forums.

- Sid
#8
04/30/2006 (4:23 am)
Bruno,

The quote is not just for packaging games, although that is a big part of it. If you reread part (e), "distributing" uncompiled script code includes posting it in public forums. Which is why, if you look back through some of the threads in this forum, some posts have been deleted with the comment to repost in the private forums.

The whole script code ok/C++ not ok only applies to TGE. TGB is a different beast in that you can make a complete game in Torquescript without touching the C++ side of things. What script code is made public in the T2D demos outside of the first main.cs? Everything else is a compiled dso.