Instead of jumping straight into galaxy to code, I suggest you learn programming in general first. For example, learning to program first in Java and Cplusplus will help you immensely when creating more complicated maps.
How do u know, he don't have programming experience?
I like this picture. Right anwser for a lot of questions :D
That's literally the same setup I have. geX is still working on his master thesis so it'll be a while before 0.2.0 is out.
Oh and a crucial note to SoulCarver: Arrays starts from 0, so if you have int[2] foobar, you only have foobar[0] and foobar[1]. The SC2 editor makes it more user-friendly by starting from 1 instead.
The above will print "Hello World!" to the "debug area" (basically to
the left of the screen, just above the minimap) three real seconds after
the map starts.
Yes, that is a complete and functional MapScript.galaxy. It's not
necessary to put your trigger "Actions" in a separate function call - if
anything, keeping the entire trigger content in the same function helps
with performance a tiny bit.
As for getting your custom script to run, the easiest way is to simply
create a new "Custom Script" element in your trigger list view
(RightClick -> New -> New Custom Script, when you right-click the panel
that shows your list of triggers in the trigger editor). When you select
this new element, you'll see a large window for typing your script, and
at the very bottom a tiny little box called "Initialization Function
(Optional)". Whatever you type in this box will be the function name of
the function you want to run in this Custom Script block at map init.
So, if I make a Custom Script block with a "fooBar" function and I enter
"fooBar" in the Init Function box at the bottom, my resulting
MapScript.galaxy might look like this:
include "TriggerLibs/NativeLib"
trigger foo;
void InitLibs () {
libNtve_InitLib();
}
void fooBar() {
Wait(5, c_timeReal);
UIDisplayMessage(PlayerGroupAll(),c_messageAreaDebug,StringToText("I'm a test!"));
}
Basically, you can use this Custom Script block itself to put all your
code, one block could call functions and use globals from another Block
(as long as it's positioned lower than the others in the trigger list,
because that determines their position in the generated code and galaxy
requires forward-definition), or this one block could have:
include "fileToInclude"
as its only statement, as long as you also import a file named
"fileToInclude.galaxy" in your map through the import editor and it's
located at the root "folder" of the map. This way you can work almost
exclusively in external files. If you really want only external files,
you can also import and override MapScript.galaxy with your own code
(like I did to test the above examples), but that's a finnicky and
tricky process and you'll bash your head on a wall trying to do it
unless you know and perform the proper rituals to appease the gods of
the Editor beforehand.
This is kinda helpfull......
But i dont wanna know what the galaxy file looks like......
I wanna know what the "custom script" looks like....
what is the minimum i need to add to a "custom script" on a brand new map to make is out put "hello world"
Rollback Post to RevisionRollBack
Skype
KageNinpo = SN
My Libraries
DialogLeaderboard & TeamSort
My Projects
SPACEWAR Tribute
Infinite TD
I believed I'd already made clear in my explanations where goes what and what exactly you need in a custom script to have it working. However, here's an even more detailed explanation:
Yes, that's all it needs to work, and yes, I've tested that and it works exactly as intended.
The reason that code generates script errors is because of "playergroup players" in your first UIDisplayMessage() call. In vanilla Galaxy, you can't declare variables on-the-fly, only in the global scope and at the very top of a function. The would-be "players" variable here also doesn't even have a value, so even if it were valid code it still wouldn't work ingame. You need to tell the function to output to all players by passing it a player group that contains all players (or anyway, pass it a group that contains all players whom you want to see the message). The function PlayerGroupAll() returns such a group that contains all players. Most people use a global variable called PLAYERS_ALL or somesuch that is set to PlayerGroupAll() at map init, so as to reduce unnecessary function calls and thus optimize code a tiny bit.
Also, you send "hello world" as a parameter to the UIDisplayMessage function. "hello world" is a string. UIDisplayMessage needs a "text" variable, not a "string" variable. Thus, you need to use the StringToText() function (which transforms the string you give it into a text) to pass a text to the UIDisplayMessage() call in this case.
add the initializer InitHelloWorld at the bottom of the custom script and this should work. Just press spacebar.
If this doesn't work, just add a GUI trigger with nothing inside it. It'll automatically dump the include lib and libNtve initializations etc for you. I've had a problem before where my custom script doesn't work without it.
Yes, it does require a text value, sorry I forgot about that. What error message does the compiler spit out at the InitHelloWorld Line?
Could you please post a screenshot of your editor with the custom trigger I suggested? I'll see if I can pinpoint what's missing.
Edit: I know why its not working, It should be
void InitHelloWorld(){}
not
InitHelloWorld(){}
My bad =_=. No API = Syntax error. lol
Also, for
UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringExternal("Param/Value/1A9515A2");
You can also use StringToText("YourString") instead of StringExternal. If I'm not mistaken, String external is used in cases where you are trying to pull a string from an imported file or some file that was autogenerated by the SC2 Editor.
There *is* no such thing as a script you can just paste into a Custom Script block that will run. The reason why is that this way, the game has no way to know how or when to run that code. At the very least, you need to also type / paste a function name in the init box at the bottom of the Custom Script view so the game knows it has to run that function at map init.
Also, all the complaints and errors you've been getting I've already explained and given solutions for in my posts, so it would seem you're skipping stuff. At this point, considering that behavior, there's not much more I can do to help - I've already given you several examples and detailed explanations that contain exactly what you're asking for, as well as other examples for comparison, and so have FuzzYD and Avogatro. Simply re-reading over this thread would give you all the information you need regarding this.
Yeah franker... your examples are just too indepth.... you posted a full script file.... I want bare minimum sorry not disrespecting you im looking for bare bones .... ill figure the rest out myself for the most part
codetopasteincustomscript
name of function i need to paste into the initialize text box on the custum script....
Yeap, but the initialization function should be InitHelloWorld, as InitHelloWorld is the function that creates the trigger and adds the key press event.
So that would work then ? or is there something about the name of the functions where you need the "InitHelloWorld" in conjunction with the function named "HelloWorld"
As I wrote in a post before, you can name your functions/variables however you want to. It's somewhat of a custom to just use the actual trigger name and just add "Init" in front of it, but if you want you can name it "BLARGHGHGGHGHHWOHUBAUNA".
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
How do u know, he don't have programming experience?
I like this picture. Right anwser for a lot of questions :D
I think our friend need only a galaxy script to create 14x10 triggers for each move.
I would not edit the origial global Init Trigger function. I would go to the GUI game init function, and use the action
Because that Void InitTrigger() is from system, u always want to seperate it.
If u really like the idea of opensource. try write at least 20% of your text as comments.
In my code there is a loop:
For each Player p in PlayerGroup ActivePlayer. If u don't see it, write it as a comment
Style
He already apologized.
@DaFranker: Go
That's literally the same setup I have. geX is still working on his master thesis so it'll be a while before 0.2.0 is out.
Oh and a crucial note to SoulCarver: Arrays starts from 0, so if you have int[2] foobar, you only have foobar[0] and foobar[1]. The SC2 editor makes it more user-friendly by starting from 1 instead.
This is kinda helpfull......
But i dont wanna know what the galaxy file looks like......
I wanna know what the "custom script" looks like....
what is the minimum i need to add to a "custom script" on a brand new map to make is out put "hello world"
@s3rius: Go
this generates script errors.....
@SouLCarveRR: Go
I believed I'd already made clear in my explanations where goes what and what exactly you need in a custom script to have it working. However, here's an even more detailed explanation:
Yes, that's all it needs to work, and yes, I've tested that and it works exactly as intended.
The reason that code generates script errors is because of "playergroup players" in your first UIDisplayMessage() call. In vanilla Galaxy, you can't declare variables on-the-fly, only in the global scope and at the very top of a function. The would-be "players" variable here also doesn't even have a value, so even if it were valid code it still wouldn't work ingame. You need to tell the function to output to all players by passing it a player group that contains all players (or anyway, pass it a group that contains all players whom you want to see the message). The function PlayerGroupAll() returns such a group that contains all players. Most people use a global variable called PLAYERS_ALL or somesuch that is set to PlayerGroupAll() at map init, so as to reduce unnecessary function calls and thus optimize code a tiny bit.
Also, you send "hello world" as a parameter to the UIDisplayMessage function. "hello world" is a string. UIDisplayMessage needs a "text" variable, not a "string" variable. Thus, you need to use the StringToText() function (which transforms the string you give it into a text) to pass a text to the UIDisplayMessage() call in this case.
@DaFranker: Go
That just runs a wait... and then displays a message....
I want it to create a function that has an event... that runs the function and displays hello world...
@avogatro: Go
Lol. Thanks, I appreciate the thought :P
@SouLCarveRR: Go
Try this?
add the initializer InitHelloWorld at the bottom of the custom script and this should work. Just press spacebar.
If this doesn't work, just add a GUI trigger with nothing inside it. It'll automatically dump the include lib and libNtve initializations etc for you. I've had a problem before where my custom script doesn't work without it.
@SouLCarveRR: Go
About Event:
TriggerAddEventTimeElapsed(wasd_triggers [lv_player][0], 3, c_timeReal);
Dafrankers example has an event in it, u just didn't see it. http://wiki.sc2mapster.com/galaxy/triggers/events/time-elapsed/
@FuzzYD: Go
Fuzzy that code genereate script error on the Gui out put line
parameter type does not match function definition
replaced the
with
now it fails on this line
I have yet to see a script i can just "paste" into a "custom script field" and run ...
all the examples offered here have script compile errors....
I under stand some of these are examples I could paste into the script file...... import the script file into the mpq and they would prolly run...
I dont want to work from an external text editor..... I want to write into the "custom script fields"
eh.... I know you guys are trying to help me.....
@SouLCarveRR: Go
Just 2 trigger element in that map:
It is easier then u think.
@SouLCarveRR: Go
Yes, it does require a text value, sorry I forgot about that. What error message does the compiler spit out at the InitHelloWorld Line?
Could you please post a screenshot of your editor with the custom trigger I suggested? I'll see if I can pinpoint what's missing.
Edit: I know why its not working, It should be
void InitHelloWorld(){}
InitHelloWorld(){}
My bad =_=. No API = Syntax error. lol
Also, for
Heres the fixed version:
@SouLCarveRR: Go
There *is* no such thing as a script you can just paste into a Custom Script block that will run. The reason why is that this way, the game has no way to know how or when to run that code. At the very least, you need to also type / paste a function name in the init box at the bottom of the Custom Script view so the game knows it has to run that function at map init.
Also, all the complaints and errors you've been getting I've already explained and given solutions for in my posts, so it would seem you're skipping stuff. At this point, considering that behavior, there's not much more I can do to help - I've already given you several examples and detailed explanations that contain exactly what you're asking for, as well as other examples for comparison, and so have FuzzYD and Avogatro. Simply re-reading over this thread would give you all the information you need regarding this.
@FuzzYD: Go
thanx fuzzy ... I'll try that when I get home.....
for your example fuzzy do I need the function name entered at the bottom of the script so the editor properly initializes that function at run time?
@DaFranker: Go
Yeah franker... your examples are just too indepth.... you posted a full script file.... I want bare minimum sorry not disrespecting you im looking for bare bones .... ill figure the rest out myself for the most part
name of function i need to paste into the initialize text box on the custum script....
Fuzzy so I should do this...
then in the Initialize text box on the custom script add "HelloWorld" ?
@SouLCarveRR: Go
Yeap, but the initialization function should be InitHelloWorld, as InitHelloWorld is the function that creates the trigger and adds the key press event.
@FuzzYD: Go
So "InitHelloWorld" is actually a different function, I could just do it like this then ?
Initialize Trigger Name : InitThisShit
So that would work then ? or is there something about the name of the functions where you need the "InitHelloWorld" in conjunction with the function named "HelloWorld"
Renaming is no problem.
As I wrote in a post before, you can name your functions/variables however you want to. It's somewhat of a custom to just use the actual trigger name and just add "Init" in front of it, but if you want you can name it "BLARGHGHGGHGHHWOHUBAUNA".