Forum

> > Stranded II > General > Script Editor
Forums overviewStranded II overviewGeneral overviewLog in to reply

English Script Editor

16 replies
To the start Previous 1 Next To the start

old Script Editor

wannabeuk
User Off Offline

Quote
Hello Peeps,

Just thought id post here to let you know im working on a script editor (aswell as a full blown modding tool). This is mainly because i was asked by someone else.

Im aware there is an ingame editor with a script editor. but afaik there is no external editor, is this correct?

Also, if you wanted to use this editor what features would you like to see?

Cheers
Wannabeuk

old Re: Script Editor

MeatMagicianHDS
User Off Offline

Quote
wannabeuk has written
Hello Peeps,

Just thought id post here to let you know im working on a script editor (aswell as a full blown modding tool). This is mainly because i was asked by someone else.

Im aware there is an ingame editor with a script editor. but afaik there is no external editor, is this correct?

Also, if you wanted to use this editor what features would you like to see?

Cheers
Wannabeuk


Would it be possible to edit the script so it seems like there is a season cycle, i.e make it sunny for two days, rainy for two, snowy for two, rainy for two, then on again?

old Re: Script Editor

wannabeuk
User Off Offline

Quote
That seems more like something that would be done with the editor, this is just a tool to write the scripts.

old Re: Script Editor

slow
User Off Offline

Quote
I would love such a thing if it would allow us to select an item type, then a particular item, to see the scripting to it, and for it to allow us to edit it from there, saving the changes.

If creating new items, perhaps selecting the image/texture, model for it, and scaling could be on one side so they do not get into the way (and also show preview of those selected so we can see how it would look for those of us who are not yet proficient at images nor models yet) then scripting could occur in a text editor on the opposite side of this.

(My apologies if I make little sense or if these are not possible or are not the variety of suggestions you seek. I am still a noob with such things as these

old Re: Script Editor

MeatMagicianHDS
User Off Offline

Quote
slow has written
I would love such a thing if it would allow us to select an item type, then a particular item, to see the scripting to it, and for it to allow us to edit it from there, saving the changes.

If creating new items, perhaps selecting the image/texture, model for it, and scaling could be on one side so they do not get into the way (and also show preview of those selected so we can see how it would look for those of us who are not yet proficient at images nor models yet) then scripting could occur in a text editor on the opposite side of this.

(My apologies if I make little sense or if these are not possible or are not the variety of suggestions you seek. I am still a noob with such things as these


That would be awesome.

old Re: Script Editor

wannabeuk
User Off Offline

Quote
Well, ive already begun working on a full mod editor using the sourcecode kindly provided by Psytechnic and his mod viewer.

Adding items will be done via a similar system to viewing items, however its unlikely that i will add a model preview as that is extentive work for little reward.

The script editor is loaded from the add/edit item form, and has several features already. it already has

Event list
a list of all on:events that can be viewed with a descriptions and then double clicked to add to the code in the correct format. (i will add all the commands at some point soon)

Syntax-Highlighting
The editor already has syntax highlighting for the script, although basic.

Line Numbering
The lines in the editor are now numbered to allow for quickly finding the right line.

I also plan to add, basic syntax checking (matching braces ect) code folding and auto completetion.

old Re: Script Editor

Psytechnic
User Off Offline

Quote
wannabeuk has written
Well, ive already begun working on a full mod editor using the sourcecode kindly provided by Psytechnic and his mod viewer.


You can understand my code? Damn. I can't even understand it half the time. I must say something at the moment because this may be a waste of your time in the long run.

Yes, Stranded II Mod Viewer is a mod viewer at the moment, but this is because you can't just build a blind editor. You have to read the existing scripts and check for errors and such before you start modifying the files. So I wrote the functions for reading and checking the files. Then, I simply display them. But I have no intention of stopping there. At the moment, I have finished the items, combinations. buildings and object table displays and am now finishing the object view display, but when I've done that and the unit display, I'm turning the entire project into a mod editor.

wannabeuk has written
Adding items will be done via a similar system to viewing items, however its unlikely that i will add a model preview as that is extentive work for little reward.


This is in the pipeline for my app. I'm looking for a b3d viewer I can integrate into the app.

wannabeuk has written
The script editor is loaded from the add/edit item form, and has several features already. it already has

Event list
a list of all on:events that can be viewed with a descriptions and then double clicked to add to the code in the correct format. (i will add all the commands at some point soon)

Syntax-Highlighting
The editor already has syntax highlighting for the script, although basic.

Line Numbering
The lines in the editor are now numbered to allow for quickly finding the right line.

I also plan to add, basic syntax checking (matching braces ect) code folding and auto completetion.


Nice ideas. Very similar to things I'm going to be putting in mine. Take what you have there and allow for "code template" creation whereby a user can select a region of code, select "save to template..." and have a one-click solution to enter a template into a script.
This would cover all the standard functions, I.e. the "on:build" template will add:
1
2
3
on:build
{
}
but with the added advantage that you could make your own which could come in handy for quickly converting mods to MP varieties.

slow has written
I would love such a thing if it would allow us to select an item type, then a particular item, to see the scripting to it, and for it to allow us to edit it from there, saving the changes.


Once I've created the "create/edit" windows for the editor, there will be a button to allow you to add or edit edit any available part of whatever is selected.

slow has written
If creating new items, perhaps selecting the image/texture, model for it, and scaling could be on one side so they do not get into the way (and also show preview of those selected so we can see how it would look for those of us who are not yet proficient at images nor models yet) then scripting could occur in a text editor on the opposite side of this.


Your layout is a little flawed. Although those are considered the main parts of a defined game structure, they are not the only parts available. For instance, when creating items, I will leave a text box for manually writing a behaviour string, but will also have a safe string constructor that has a visual way of building behaviour strings, but this is unique to items. Units have definitions for animations, so they must be editable too.

The editor window will be full of various options you can set for each particular game structure, which is why it will be handled by an editor control panel. The added advantage of this is that I can integrate 7z to take a backup of the ".inf" files before you start modifying them. So if you do accidentally make a major mistake, you can revert to an earlier backup.

slow has written
(My apologies if I make little sense or if these are not possible or are not the variety of suggestions you seek. I am still a noob with such things as these


I'm building my app with the intention of making it a full blown mod editor/creator that can be used by people without a great deal of modding knowledge. All these ideas help.

And one last thing WannaBe. If you used my source code in any way, shape or form to create your app, you are bound to the GNU GPL v3 that I made the mod viewer under and therefore must release the derivative works (your app) under an equivalent CopyLeft license... Keep my work free. It's how it should be...
edited 1×, last 22.03.10 09:47:04 pm

old Re: Script Editor

wannabeuk
User Off Offline

Quote
Dont worry, i have no issues with following the licence

I have already made some changes to your code to make it easier for me to read and understand, although it took me a few hours to work through it.

If you are already working on the mod maker (i actually assumed you would, i just thought id give it a shot myself, more for love of programming)

Most of my work has been on the script editor mind, you mention the ability to add code templates, this is something i have already planned, event code is already generated like you say. double clicking the event in the list will add for example

1
2
3
on:start 
{
}

My next step is to allow for code folding (collapsing everything between the { and } into a single line. )

part of that will be the brace matching, which will allow for other features such as auto formatting, and basic syntax checking.

Another feature im looking at is getting hold of the compiler to allow for external compiling and error checking of the scritps.

Just for example here is an img. this is just a prototype with the current features.

http://img706.imageshack.us/img706/4610/editoro.jpg
edited 1×, last 22.03.10 10:55:43 pm

old Re: Script Editor

Psytechnic
User Off Offline

Quote
I really like this idea. If you make this a modal dialog (with OK, Cancel) that has a public property to return the edited script as a "List<string>" on close, I can add a button next to the script text box in the editor window to open the "Script Editor". This would do something simple like:
1
2
3
4
5
6
7
8
9
10
ScriptEditor newEditor = new ScriptEditor();
//Pass it the script you wish to modify
//You could add arguments to the Script Editor constructor such as
//ScriptEditor(List<string> scriptToEdit) and compact the designation to one line:
//ScriptEditor newEditor = new ScriptEditor(handler.Script);
//Then you handle the dialog result:
if(newEditor.ShowDialog() == DialogResult.OK)
{
    handler.Script = newEditor.Script;
}

wannabeuk has written
Another feature im looking at is getting hold of the compiler to allow for external compiling and error checking of the scripts.


There isn't a compiler for scripts as such as this is a new scripting language that DC wrote for S2 and is handled by the app itself, so "getting hold of the compiler" would technically be getting hold of the process for checking the scripts, and as the scripts are checked for different things at different times in the game, there is no comprehensive function for checking the complete integrity of a script. The closest thing you're gonna find to error checking of scripts is my mod viewer as I am handwriting the script checking...

old Re: Script Editor

wannabeuk
User Off Offline

Quote
Ah right, i assumed the scripts got compiled internally (as i have the source, but im yet to look at it)

The script editor is already as you described, and i have the same thing on the edit i made to your viewer.

However i will continue to work on just the editor only, and provide it for you to use if you wish.

Im currently working on how to code fold, i almost have it working.

old Re: Script Editor

Psytechnic
User Off Offline

Quote
wannabeuk has written
Ah right, i assumed the scripts got compiled internally (as i have the source, but im yet to look at it)

The script editor is already as you described, and i have the same thing on the edit i made to your viewer.

However i will continue to work on just the editor only, and provide it for you to use if you wish.

Im currently working on how to code fold, i almost have it working.


Good luck. Keep working on it. Are you looking to release this tool to the community? If you are, I'll grab your source code when you release it an implement as much as I can in my app. If not, then I'll ask you for the code when I need to add that functionality.

If you want the latest build of the mod viewer at any time, just message be and I'll host it on media fire. This may be a good idea now as I have changed a fair bit of underlying code for speed and also added a new chunk of error checking. You can always wait for the next release which will be in the next few days.

old Re: Script Editor

wannabeuk
User Off Offline

Quote
Ill release it to you so you can add it into your tool, and ill also release a standalone version incase anyone wants it that way.

Update:

Code folding now works.

Currently working on
Auto Complete
Brace Matching

Any other major feature you would like to see in the editor Psy?
edited 1×, last 23.03.10 07:58:59 pm

old Re: Script Editor

Psytechnic
User Off Offline

Quote
Well thank you for including me in this.
You already have a fantastic array of ideas, but instead of the commands being hardcoded (which I think they are) why not have them as individual text files structured like this.

Filename: OnBuild.txt
1
2
3
4
5
6
7
<Description>
This places the on:build function into the script editor with braces.
</Description>
<Code>
on:build{
}
</Code>

Then save them in a new folder in the same location as the app called "Scripts".

When your script editor loads, it can call these files and read the information into a structure:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class ScriptSnippet
    {
        private string filePath;
        public string FilePath
        {
            get { return filePath; }
            set { filePath = value; }
        }

        private List<string> description = new List<string>();
        public List<string> Description
        {
            get { return description; }
            set { description = value; }
        }

        private List<string> codeSnippet = new List<string>();
        public List<string> CodeSnippet
        {
            get { return codeSnippet; }
            set { codeSnippet = value; }
        }

        public ScriptSnippet()
        {
        }
    }

Then you can add this to a single listOfSnippets=List<ScriptSnippet> and enumerate through, adding the filename to the main list. Then, on clicking an item in the list, launch a search for the CodeSnippet and display and paste.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
private void OnClick(object sender, EventArgs e)
{
    foreach(CodeSnippet snippet in listOfSnippets)
    {
        if(snippet.FilePath.EndsWith(listView.SelectedText))
        {
            string desc = "";
            foreach(string line in snippet.Description)
                desc += line;
            richTextBoxDescription.Text = desc;
            //Do your placing the script in the editor here
        }
    }
}

The reason for all of this is that you now have the ability to allow the user to make their own snippets, which is what I really want to see as I know it will help a lot of modders convert normal mods to MP mods, because most of the conversion is inserting new sections into scripts. If we do this well, we might be able to rope oraclefile into helping create the code snippets.

old Re: Script Editor

wannabeuk
User Off Offline

Quote
Yes currently they are hard coded, this was mainly to help me test the prototype.

Once i get this damn brace matching working i will work on that idea.
currently have some problems with the logic on this, but i almost have it cracked.
To the start Previous 1 Next To the start
Log in to replyGeneral overviewStranded II overviewForums overview