Return values

Posted by TCHRacoon on June 21, 2007, 1:25 p.m.

Now that I finally understand all the drag and drop actions, I started to learn the actual scripting thing. I got on pretty well, it is not so hard but there is one thing I do not understand: Return values, there was no example that I could find with the search term return or value or so. I do not get the gamemaker help because I am dutch and do not speak Englisch perfectly. ( I'd like it if you helped me with my spelling, in case I made any mistakes in my blog.) And allmighty google didn't know the answer to. So, could anybody please explain me, in clear language understandable for newbs like me, explain me how to use return values and show me a little example.

I also have another problem, and that is sound effects. I succeeded in adding all kinds of sound effects in script. But making my onw sound effects didn't seem to work. Is it just not working or am I doing something wrong???.

Furthermore I wanted to say that the whole thing about GamePwner is just bullcrap. Stop it OK. I know Shadow Yoshi can be an ass, no offence, and the same counts for GP. Just stop the whole thing and don't talk about it anymore coz the whole freakin' thing is starting to get on my nerves.

And people should stop Spamming the forums as well. How about getting a forum mod. Serprex or something, I guess he'd want to.

That was all for today.

TCHRacoon

Comments

TCHRacoon 17 years, 5 months ago

yeah I understand that, but how can you do something with the outcome of it.

Is it like:

if argument0=10 or something

s 17 years, 5 months ago

Just like those DnDs that return true or false(Though use 1 and 0,GM doesn't allow boolean…sadly)

arguments are the stuff in the()

Kaz 17 years, 5 months ago

Ok, lets say I actually want to use what the script gets. (I'm assuming thats what you mean)

if multiply(5,4)=20{

//do stuff

}

TCHRacoon 17 years, 5 months ago

Yeah, thanks Kaz I get that part now.

But what if you use those boxes where the player can fill a variable in himself.

TCHRacoon 17 years, 5 months ago

Like message ext, you get 3 options, how do you do that?

Bryan 17 years, 5 months ago

value=function(argument0,argument1,…)

In the script it should say eg this

return argument0+argument1+argument2;

It will add up the first argument, second and third.

Resulting in

value=Add(2,2,2);

value will then contain the value 6.

I could explain this in dutch.. but well.. im busy XD

Kaz 17 years, 5 months ago

//some_function(x)

if argument0=1{

//do something

}

if argument0=2{

//do something different

}

Gamer3D 17 years, 5 months ago

Ok… You seem not to have gotten the point.

If I make this script (titled sqr):

return argument0 * argument0;

Then I can use it in any way I want. For example:

y = sqr(x);

This is, in effect, the following:

y = x * x;

If you REALLY need to know what return does, then here is the simple version:

return x;

Places x in a standard memory slot. It can be accessed by

variable = script_name(argument0, argument1...)

This sets variable to the value returned by the script.

TCHRacoon 17 years, 5 months ago

thanks guys for being so helpful. I appriciate that.

@ bryan, where did you learn to speak English so well?

@SY thanks I knew the English, it was a spelling error. Still thanks!

s 17 years, 5 months ago

Can also just use if script()=something{}