Just wondering if there is a built in function to print a line of text to the screen in-game to help me troubleshoot my coding and to make sure things are working, ect.
I see Print("some words") used by some people who paste code onto the forums and it looks like its syntax is highlighted.
Is this a function people are writing themselves? Could someone paste it? It dosent work in the editor alone.
Don't use pure galaxy script but there's a trigger action called Debug Message which is useful for troubleshooting, so you could probably look up and find out what the native is.
So by pasting this function into a custom script section you can then use the Print("some words") function.
You can also change the '1' in the function to a '4'. Then the message will show up on the left side of the screen, written in red. The '1' will make it pop up normally.
Alternatively you can use what Riley said, which is especially useful if you want to debug a lot and have to examine the results, which doesn't work so well with simply displaying them for a couple of seconds.
You can specify a place to write the debug messages into, in this case TriggerDebug.txt. This file will be created in your Documents folder where you can also find Banks and replays.
Every debug message will be put into a new line, and in the end you can open the file and look at all of them.
Thanks a ton s3rius. I've seen alot of your posts around, I'd like to thank you for your dedication to the community and the forums.
I am trying to learn Galaxy just from piecing together what I can from the API docs and tuts here on the site. I have a decent amount of programming experience (C, Java, Actionscript) but there are a few things I don't understand about Galaxy - could you, (or any other readers) help me with these?
0) Can you explain to me what var type "fixed" is? There is a wordy definition about it around here somewhere, but I can't get my head wrapped around exactly what it is and how I can use it.
As in: fixed PointGetX(point p)
Can I used "fixed" vars much like "int"?
1) Why can't I get any of these "built in" functions to work that start with "libNtve_gf_"? They all come up with syntax errors.
Example: bool libNtve_gf_UnitInRegion(unit u, region regioin);
if I write (assuming I have already defined my unit and region)
2) When does my code execute? I've typed all my code into the GUI trigger editor as their own standalone thing as "custom script". How can I "call" my functions to run in the map? So far I've been creating triggers to run my functions with the GUI trigger editor, making events, and the calling my functions under "actions" as "custom script". Is there a better way to do this?
0)
Fixed is a decimal number. So as opposed to an integer, fixed doesn't have to be a full number (or whatever you call it).
You probably know these things from C/Java as double/float.
Sc2 doesn't have float but operates only on fixed. Wiki entry on fixed-point. You can use it just like float, though.
You only have to watch out for type conversions. C/Java accepted a type cast from float to int, but Sc2 doesn't. You have to use a type-cast function. A conversion from int to fixed is no problem, though.
1)
The libNtve_gf_XXX are non-native functions that come from one of the standard built-in libraries. They need to be included, or won't work otherwise.
Usually the editor automatically includes them and starts them up, so you don't have to care about it. However, it only does so if you have at least one GUI trigger with anything in it. God knows why >.>
So to fix that it should be enough if you make a new trigger in GUI and add any action/condition to it. It doesn't even have to make sense, but it forces the editor to auto-include the LibNative library.
If you have a GUI trigger and it still doesn't work then I don't know right now. You could upload the map to let me take a look at it.
2)
I covered a problem very similar to this recently. This should clear it up, I think.
Hi all.
Just wondering if there is a built in function to print a line of text to the screen in-game to help me troubleshoot my coding and to make sure things are working, ect.
I see Print("some words") used by some people who paste code onto the forums and it looks like its syntax is highlighted.
Is this a function people are writing themselves? Could someone paste it? It dosent work in the editor alone.
Kind regards, Lou.
Don't use pure galaxy script but there's a trigger action called Debug Message which is useful for troubleshooting, so you could probably look up and find out what the native is.
There's no normal Print() function, so they've probably written it themselves.
The function you should probably use is:
Since that's a pain in the ass to write all the time, it's useful to wrap it up:
So by pasting this function into a custom script section you can then use the Print("some words") function.
You can also change the '1' in the function to a '4'. Then the message will show up on the left side of the screen, written in red. The '1' will make it pop up normally.
Alternatively you can use what Riley said, which is especially useful if you want to debug a lot and have to examine the results, which doesn't work so well with simply displaying them for a couple of seconds.
You can specify a place to write the debug messages into, in this case TriggerDebug.txt. This file will be created in your Documents folder where you can also find Banks and replays.
Every debug message will be put into a new line, and in the end you can open the file and look at all of them.
Of course you can also wrap this one up:
It isn't necessary to call TriggerDebugSetTypeFile every time, but it also doesn't hurt :)
Thanks a ton s3rius. I've seen alot of your posts around, I'd like to thank you for your dedication to the community and the forums.
I am trying to learn Galaxy just from piecing together what I can from the API docs and tuts here on the site. I have a decent amount of programming experience (C, Java, Actionscript) but there are a few things I don't understand about Galaxy - could you, (or any other readers) help me with these?
0) Can you explain to me what var type "fixed" is? There is a wordy definition about it around here somewhere, but I can't get my head wrapped around exactly what it is and how I can use it.
As in: fixed PointGetX(point p) Can I used "fixed" vars much like "int"?
1) Why can't I get any of these "built in" functions to work that start with "libNtve_gf_"? They all come up with syntax errors. Example: bool libNtve_gf_UnitInRegion(unit u, region regioin);
if I write (assuming I have already defined my unit and region)
bool testBool = false;
testBool = libNtve_gf_UnitInRegion(unitList[0], region1); syntax error!
2) When does my code execute? I've typed all my code into the GUI trigger editor as their own standalone thing as "custom script". How can I "call" my functions to run in the map? So far I've been creating triggers to run my functions with the GUI trigger editor, making events, and the calling my functions under "actions" as "custom script". Is there a better way to do this?
Thanks in advance.
@Laconi: Go
0)
Fixed is a decimal number. So as opposed to an integer, fixed doesn't have to be a full number (or whatever you call it).
You probably know these things from C/Java as double/float.
Sc2 doesn't have float but operates only on fixed. Wiki entry on fixed-point. You can use it just like float, though.
You only have to watch out for type conversions. C/Java accepted a type cast from float to int, but Sc2 doesn't. You have to use a type-cast function. A conversion from int to fixed is no problem, though.
1)
The libNtve_gf_XXX are non-native functions that come from one of the standard built-in libraries. They need to be included, or won't work otherwise.
Usually the editor automatically includes them and starts them up, so you don't have to care about it. However, it only does so if you have at least one GUI trigger with anything in it. God knows why >.>
So to fix that it should be enough if you make a new trigger in GUI and add any action/condition to it. It doesn't even have to make sense, but it forces the editor to auto-include the LibNative library.
If you have a GUI trigger and it still doesn't work then I don't know right now. You could upload the map to let me take a look at it.
2)
I covered a problem very similar to this recently. This should clear it up, I think.