Game Development Community

dev|Pro Game Development Curriculum

In-Game Script Editor

by Marcus L · 11/18/2010 (10:24 pm) · 44 comments

Tested on: 1.1b3

This resource will add a new tool, the script editor, to the world editor's toolbar. I made this resource because of the time i spend closing and opening T3D, which was extremely time consuming. And even tho I'm able to exec the scripts after i change them in torsion, it is not the optimal solution. Therefore i created the in-game script editor. Just so that's said; atm. this editor is very simple and does not even support undoing yet. This doesn't mean this is useless, it just means you should probably not use it for complex coding (for the time being).

Installation:


First, start of by downloading this .rar.
Extract it to game/tools.

Then, this is how to install the rest of this resource:
Where it says // Added, it means that the line is added.
Where it says // Removed, it means that the line is removed.
Where it says // Changed, it means that the line is changed.
Where it says ..., it means that there is code between what ever that was last written.
Whenever it says ..., there will be an comment below describing what function it is.

I recommend you using CTRL + F to find where to put the code blocks. Remember to backup before installing.

We'll start by editing core/scripts/client/helperfuncs.cs
// Put below function loadFileText( %file)
// Added ->
function saveFileText( %file, %text )
{
   // File Object
   %fo = new FileObject();
   %fo.OpenForWrite(%file);
   
   // Write Text
   %fo.writeLine(%text);
   
   // Clean Up
   %fo.delete();
   return %text;
}
// Added <-

Then edit tools/worldEditor/gui/ToolsToolbar.ed.gui
//In the beginning of the gui
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiContainer(EWToolsToolbar) {
   canSaveDynamicFields = "0";
   Enabled = "0";
   internalName = "ToolsToolbar";
   isContainer = "1";
   Profile = "editorMenubarProfile";
   HorizSizing = "right";
   VertSizing = "bottom";
   Position = "0 31";
   //MXG: 14 is the number of tools, change if you have more
   Extent = (29 + 4) * 14 + 12 SPC "33"; // Changed
   MinExtent = "8 2";
   canSave = "1";
   Visible = "1";
   hovertime = "1000";
   isClosed = "0";
   isDynamic = "0";

Last, edit tools/worldEditor/scripts/EditorGui.ed.cs
...
//In function EditorGui::init(%this)
         EWInspectorWindow.setVisible( false );
      }
   } 
   
   // Added ->
   if( !isObject( %this-->ScriptTreeWindow ) )
   {
      // Load Creator/Inspector GUI
      exec("~/scriptEditor/scriptEditorGui.gui");
      if( isObject( EWScriptTreeWindow ) )
      {
         %this.add( EWScriptTreeWindow );
         EWScriptTreeWindow-->EditorTree.selectPage( 0 );
         EWScriptTreeWindow.setVisible( false );
      }
   }
   // Added <-
...
//Same
   EWorldEditor.init();
   ETerrainEditor.init();

   //Creator.init();
   EWCreatorWindow.init();
   EWBrowserWindow.init(); // Added

Now just enter any level,
Press F11,
And you'll see a new icon in the toolbar,
Press it,
And you'll have a TextPad window and a FileTree on the side.

You'll now see that you have a Save button, a Close Button and a Refresh button.
The Save button will save any change you've made to the current script.
The Close button will close the TextPad. This can be restored by opening any script. Also note that whenever you're closing the TextPad it'll ask you if you want to save, even tho you've not made any change.
The Refresh button will automatically save you're file and execute it. Note that the save button will not execute.

The FileTree is just like the mesh selector from the Object Editor. It will by default only search for .cs and .gui files. This can be changed in the Edit->Editor Settings... dialog.

Screenshot:

img502.imageshack.us/img502/20/scripteditor2j.pngRight click->view image for full size (it got cut off).


This resource is actually "Known Issue" free =). But there is a lot of room for improvement. Here is a list for those who want to help me improve this resource:
  1. Undoing
  2. Proper file tree
  3. Code markup
  4. File tree right click context menu
  5. Auto-Complete-Me (IntelliSense)
Hopefully, someone from the community will help to improve this resource, and maybe the Torque dev team could include this functionality in future builds I'm aware that this is not the time!

If you stumble upon some issues, let me know.
Also know that my methods might not be correct, nor the most professional. Therefore if you see some silly mistakes please leave a comment with the "fix".

Thanks,
Marcus L.
Page «Previous 1 2 3 Last »
#1
11/18/2010 (10:39 pm)
Neat work Markus ;)
#2
11/19/2010 (12:16 am)
Thank you! Just today I was wishing for this, and here it is! :) Perfect!
#3
11/19/2010 (12:21 am)
Stupendous, Marcus!
#4
11/19/2010 (12:47 am)
What a life saver! I can understand what you mean it takes to much time going back and forth. This script editor is so nice! I also tested it in Beta 3 and I can confirm it works.
#5
11/19/2010 (3:20 am)
Great stuff! ..it's amazing that this wasn't already a part of T3D!
#6
11/19/2010 (5:54 am)
As always, thanks for your contribution.
Maybe there's some problems with formatting, once you have saved and made the refresh, the script stops working. The log:
scripts/client/audio/audio.cs Line: 410 - syntax error
>>> Advanced script error report.  Line 410.
>>> Some error context, with ## on sides of error halt:
}
##
##//Resumes the playback of paused sound sources.
//
>>> Error report complete.
#7
11/19/2010 (8:55 am)
Quote:
echo("Isn't this cool =)?");
For sure it is !
#8
11/19/2010 (9:31 am)
@All
Thanks :D

@Tek0
Thank you for testing and verifying my resource for 1.1b3 =)

@eb
Yeah, it is strange that this wasn't a part of T3D. That's why I'd like them to include this.

@Alifo
I did not encounter this problem when testing... Could you give me some steps to replicate?

@Vincent
Lol, yeah, thx =D.
#9
11/19/2010 (12:59 pm)
oh wow Marcus,
youve made my day man, this is awesome
#10
11/19/2010 (2:00 pm)
@Marcus
No problem, glad to test it out. I'll be using this alot.
#11
11/19/2010 (2:53 pm)
mmm, and the intellisense? XD................. nice...
#12
11/19/2010 (6:29 pm)
@Marcus, thanks for this!
#13
11/19/2010 (7:30 pm)
@deepscratch
Thanks =)

@Javier
Yeah, i called it Auto-Complete-Me in the list of things to improve. I know it is a very useful feature that this resource definitely needs! I just don't have the know-how nor the time :S. Anyways, thanks for the feedback =D.

@John
Np.

@Konrad
Coincidences seems to happen often around here :3

@Christian
Thank you :]

@Netwyrm
And thank you as well!
#15
11/20/2010 (1:29 am)
I just tried using it in beta 3. Tab does not seem to be working. Also, when you are all the way to the left on a line and press back space, it only sometimes goes to the previous line.
#16
11/20/2010 (2:37 am)
Very Nice! Like-it-a-lot!
Thanks!
#17
11/20/2010 (9:37 am)
@Jack
Quote:Tab does not seem to be working
Yeah, this is simply how the MLTextEdit works, anyhow I will try to fix this myself.
Quote:Also, when you are all the way to the left on a line and press back space, it only sometimes goes to the previous line.
Didn't manage to replicate this even tho i didn't try for that long. If you want me to try to fix this PM me and I'll see what i can do.

@Jim
Glad-to-help =)
#18
11/20/2010 (3:22 pm)
@Marcus:
Actually, after restarting my comp, going back a line now works. Not sure what happened, but at least it works now! =)
thanks again!
#19
11/20/2010 (5:02 pm)
awesome, nice tool, ty man, this really save time!
#20
11/20/2010 (5:22 pm)
Nice work! Much cleaner than my attempt to hack in hooks for CrimsonEditor. This is great inspiration to rethink how I was doing things, thanks.
Page «Previous 1 2 3 Last »