Ofcourse it shouldn't crash on you, but I have noticed some errors in the code. First of all, you are using non constant variables to define the bounds of an array. At this point, arrays are really just turned into arrays in galaxy, so only constant expressions can be used to define the size of an array. Secondly, you are attempting to define the size with fixed types. Having an array of size 1.25 really doesn't make scense - this should be integer type variables instead.
Also, correct me if Im wrong, but PointFromId(1) returns a point, right? Plus is not defined between point and fixed types.
Another thing, you are trying to invoke the method with Wall.Generation(). You must invoke that method on an actual instance of your Wall struct. So you must first define a variable of type Wall, and then invoke the method on that variable. Otherwise it is searching for a method called Generation in a namespace called Wall.
And lastly, when you want the struct variable DISTANCE, you should not write Wall in front of it. You should just write DISTANCE. In case you had a local variable also called distance you could write #struct.DISTANCE. Same thing apply to Wall.DX and Wall.DY
1
I strive to make galaxy++ resemble languages like c# or java in terms of features, while still having regular galaxy as a subset. My main reason for implementing assignments in expressions is that this is present in those languages. I agree that it can make the code more difficult to read in some cases, but I think it's up to the individual programmer to decide when/if he wants to use it.
About the if (x=5) error.. I could add a warning if you only have an assignment in an if, then that shouldn't be a problem.
3? - what happened to 2?
Like in java, the else will be connected to the closest if. So if you write
if(...)//Firstif(...)//Second...else...
The else will be connected to the second if statement.
This is not something I'm likely to change - having to add blocks everywhere is one of those things that has annoyed me in pure galaxy. If you really consider it a problem though, I could be persuaded into making an option to give an error if braces are omitted. ;)
4
The struct/array is copied to the called method via the data table. I have to make a copy, since reference passing is not possible in galaxy, and I can not do something which is not possible in galaxy.
------------------------------------------
Edit: On second thought, it would probably be possible using struct arrays and integer pointers to them, but those arrays would sit and take memory all the time, so I like the current approach better - unless someone know about a big performance hit using data tables? ------------------------------------------
You can however mark parameters with #ref (both bulk copy types and normal types). This will make sure to copy the data back into the variable after the method returns. When invoking struct methods, the struct you are calling on is passed to the method in this way, so you can make a p.setX method, and it will work as you would expect - with one exception. When passing a field as #ref the field will not be changed before the method has returned. If it was really reference passing, you would expect the called method to write directly to the field. This behavior can be achieved by marking the parameter with #ref and the function with #inline, but this will cause the code to take up more space if the function is called from many different places (And the function can not be recursive).
If you use getter/setter methods, I would recommend marking them as #inline if they are not too complex - then you skip passing stuff to the data table, and just inline the method where you are calling from.
Added a function to compile and run the script (copy the script to your map, and test it in starcraft)
Added a featuere to collapse blocks in the editor
Changed i++: It now functions as you would expect from other languages
Added ++i
Fixed an error that gave an incorrect result when having multiple assignments to the same variable in the same statement
Bulk copy parameters are now pr default passed value type
Added #ref to specify that a parameter should be passed as refference type
Added #out to specify that a parameter should function as an extra return value
I'm sorry about changing the language in a way that changes the semantics of existing programs. I try to only do it when I feel it is absolutely necessary. Also, somehow I don't think that anyone has written that much code yet :)
Technically, this is a new tool.. I wrote most of it from scratch, since I wanted my own text editor and stuff this time around..
Also, I don't plan to remove my other tool, since it still serves to give useful error messages and stuff for pure galaxy.
Compared to modern programming languages, galaxy is lacking a lot of key features. I feel that stuff like making for loops, not worrying about having to put local variable declarations on top, and a bunch of other things are stuff that really should be a part of galaxy. For this reason I designed my own language, called galaxy++, and I built this editor that can convert it to normal galaxy.
I designed it so that regular galaxy is a subset of galaxy++, apart from special galaxy++ keywords. This means that existing galaxy code can be used in the editor with very minor modifications.
The editor
The editor is organized as a list of projects, where each project is a collection of your galaxy++ files and dialogs in various folders. The editor has key features, like useful error messages, the ability to test the map with a click of a button, a suggestion box which shows you suggestions to functions, keywords, variables and types as you type, and a drag and drop dialog designer. For a list of the language features, see the assets page (link at the bottom of this post).
Feedback
I will be happy to get any feed back from you. Both positive and negative.
If you found any bugs, please post about them here, send me a PM, or use the error report feature. If you got some code to replicate the error, I would like that as well (you can choose to include your project in an error report, if you use the error report feature).
Of course, suggestions to improvements or new features are also welcome.
Disclaimer
Use this program at your own risk.
Although I of course try to get rid of them, I can't guarantee that it is completely bug free, so save often and make backups.
If you do run into a bug, please tell me about it, so I can exterminate it.
@Kueken531: Go
Right, thanks - uploaded a fixed version.
Ofcourse it shouldn't crash on you, but I have noticed some errors in the code. First of all, you are using non constant variables to define the bounds of an array. At this point, arrays are really just turned into arrays in galaxy, so only constant expressions can be used to define the size of an array. Secondly, you are attempting to define the size with fixed types. Having an array of size 1.25 really doesn't make scense - this should be integer type variables instead.
Also, correct me if Im wrong, but PointFromId(1) returns a point, right? Plus is not defined between point and fixed types.
Another thing, you are trying to invoke the method with Wall.Generation(). You must invoke that method on an actual instance of your Wall struct. So you must first define a variable of type Wall, and then invoke the method on that variable. Otherwise it is searching for a method called Generation in a namespace called Wall.
And lastly, when you want the struct variable DISTANCE, you should not write Wall in front of it. You should just write DISTANCE. In case you had a local variable also called distance you could write #struct.DISTANCE. Same thing apply to Wall.DX and Wall.DY
I'll look into the crash when I get home.
Edit
Uploaded a new version.
@peeeq: Go
1
I strive to make galaxy
++
resemble languages like c# or java in terms of features, while still having regular galaxy as a subset. My main reason for implementing assignments in expressions is that this is present in those languages. I agree that it can make the code more difficult to read in some cases, but I think it's up to the individual programmer to decide when/if he wants to use it.About the if (x=5) error.. I could add a warning if you only have an assignment in an if, then that shouldn't be a problem.
3? - what happened to 2?
Like in java, the else will be connected to the closest if. So if you write
The else will be connected to the second if statement.
This is not something I'm likely to change - having to add blocks everywhere is one of those things that has annoyed me in pure galaxy. If you really consider it a problem though, I could be persuaded into making an option to give an error if braces are omitted. ;)
4
The struct/array is copied to the called method via the data table. I have to make a copy, since reference passing is not possible in galaxy, and I can not do something which is not possible in galaxy.
------------------------------------------
Edit: On second thought, it would probably be possible using struct arrays and integer pointers to them, but those arrays would sit and take memory all the time, so I like the current approach better - unless someone know about a big performance hit using data tables?
------------------------------------------
You can however mark parameters with #ref (both bulk copy types and normal types). This will make sure to copy the data back into the variable after the method returns.
When invoking struct methods, the struct you are calling on is passed to the method in this way, so you can make a p.setX method, and it will work as you would expect - with one exception. When passing a field as #ref the field will not be changed before the method has returned. If it was really reference passing, you would expect the called method to write directly to the field. This behavior can be achieved by marking the parameter with #ref and the function with #inline, but this will cause the code to take up more space if the function is called from many different places (And the function can not be recursive).
If you use getter/setter methods, I would recommend marking them as #inline if they are not too complex - then you skip passing stuff to the data table, and just inline the method where you are calling from.
Added a new version.. Some of the changes are
i++: It now functions as you would expect from other languages
++i
I'm sorry about changing the language in a way that changes the semantics of existing programs. I try to only do it when I feel it is absolutely necessary. Also, somehow I don't think that anyone has written that much code yet :)
@LinkD: Go
Technically, this is a new tool.. I wrote most of it from scratch, since I wanted my own text editor and stuff this time around..
Also, I don't plan to remove my other tool, since it still serves to give useful error messages and stuff for pure galaxy.
But thanks.. glad you like it :)
This project is dead.
http://www.sc2mapster.com/forums/resources/third-party-tools/19619-galaxy-editor/?page=27#p539
----------------------------------------------------------
Compared to modern programming languages, galaxy is lacking a lot of key features. I feel that stuff like making for loops, not worrying about having to put local variable declarations on top, and a bunch of other things are stuff that really should be a part of galaxy. For this reason I designed my own language, called galaxy
++
, and I built this editor that can convert it to normal galaxy. I designed it so that regular galaxy is a subset of galaxy++
, apart from special galaxy++
keywords. This means that existing galaxy code can be used in the editor with very minor modifications.The editor
The editor is organized as a list of projects, where each project is a collection of your galaxy
++
files and dialogs in various folders. The editor has key features, like useful error messages, the ability to test the map with a click of a button, a suggestion box which shows you suggestions to functions, keywords, variables and types as you type, and a drag and drop dialog designer. For a list of the language features, see the assets page (link at the bottom of this post).Feedback
I will be happy to get any feed back from you. Both positive and negative.
If you found any bugs, please post about them here, send me a PM, or use the error report feature. If you got some code to replicate the error, I would like that as well (you can choose to include your project in an error report, if you use the error report feature).
Of course, suggestions to improvements or new features are also welcome.
Disclaimer
Use this program at your own risk.
Although I of course try to get rid of them, I can't guarantee that it is completely bug free, so save often and make backups.
If you do run into a bug, please tell me about it, so I can exterminate it.
Download and language documentation
See the asset page for the documentation
http://www.sc2mapster.com/assets/galaxy-editor-beier
Please note: as of v2.8.5, xna 3.1 is needed. You can find it at
http://www.microsoft.com/download/en/details.aspx?id=15163
The latest versions are uploaded to
ftp://46.163.69.112/Releases/