Quote:
As far as I can tell, this works the same, but I don't understand "temp.p" and "temp.i", "temp.i.layer". I presume temp.i.layer is the same as changeimgvis, but what I don't understand is why the text being on layer 4 works, when I thought only 5 and up works for the screen instead of the playing field?
|
Layers 4+ are screen layers.
"temp.i" is a variable, which is pointing to the image object. When you use 'showtext' or 'showimg', it returns the actual image created (can also be obtained through findImg(index)).
Which means you could even do like (though it's not a good idea)
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.msg = showtext(200, 30, 30, "Arial", "b", "hi");
}
function changeText(text) {
this.msg.text = text;
}
Kinda odd the way you're doing it. I would do it either like this:
PHP Code:
with (findimg(200)) {
x = 500;
y = 500;
text = "Hello, world!";
font = "Arial"; // not sure if this is the variable name, use /scripthelp
fontface = "b"; // see above line
layer = 4;
red = 1;
blue = .5;
green = .5;
alpha = 1;
}
or
PHP Code:
showtext(200, 500, 500 "Arial", "b", "Hello, world!");
changeimgvis(200, 4);
changeimgcolors(200, 1, .5, .5, 1);
Either works, but the top one is probably preferred (though I could be wrong; the top one seems to agree with GS2 standards whereas the bottom is for compatibility).
Quote:
This really confuses me as to why everyone says "GS2 is easier to understand" or "GS2 makes more sense" because GS1 makes sense to me, but looking at this stuff, I am like.. what?!
|
GS2 makes a
lot more sense, and you'll understand it when you've been working with it longer.
Quote:
Originally Posted by Raelyn
Ok, so if I take all my functions from my base system script, and make the classes all functions, I can just go through and replace all the functions listed in the script with:
PHP Code:
function onCreated() { join("class_name"); }
Is that right? What is the echo? And will GS1 and GS2 mix? It seems like they mix, but only that GS2 doesn't work offline.. is that right?
|
GS1 and GS2
can mix, but it's strongly discouraged.
echo(message) simply outputs the message to NC (or RC if you have the server option enabled), and since he's echoing a function, it will echo whatever that function returns.
And yes, you can take all the functions you want to be in a shared class from the individual scripts and put them in a class, then join that class.
Edit (in response to designating clientside/serverside):
PHP Code:
join("class"); // serverside
//#CLIENTSIDE
function onCreated() {
classFunctionThatWillAlreadyWork();
}
or
PHP Code:
//#CLIENTSIDE
function onCreated() {
join("class"); // clientside (not a good idea)
classFunctionThatWillNotWorkBecauseOfDelaysAndWillReportAnErrorToF2(); // ;)
}