SOLVED I don't understand the code argument0

U

uni00

Guest
Hello. I read in the article that general-purpose processing can be called at any time。
引数と呼ばれるコードについて学んでいます。公式のウェブサイトや動画など、このコードについてはたくさん見ましたが、まったくわかりません。このコードは何のためにあり、それは何をしますか?このコードがなければ何が不便でしょうか?

thanks
 

Binsk

Member
Code:
show_message("Hello World");
// argument0 = "Hello World"

src_a_plus_b(number_1, number_2);
// argument0 = number_1
// argument1 = number_2
scr_a_plus_b =
Code:
return argument0 + argument1;
scr_a_plus_b(1, 2) = 3
Code:
return 1 + 2;
If you can understand this:
An argument is data from outside of a script given to the inside of the script.

show_message("Hello"), we want to change what show_message shows. We do not want a script for every possible word so we use argument0, argument1, etc.. "Hello" is argument0. show_message shows a message of whatever argument0 is. This allows us to have one script to show multiple messages by changing what argument0 is.

show_message("Hello"). argument0 was set to "Hello".
show_message("Bananas"). argument0 was set to "Bananas".
 
Last edited:
U

uni00

Guest
Code:
show_message("Hello World");
// argument0 = "Hello World"

src_a_plus_b(number_1, number_2);
// argument0 = number_1
// argument1 = number_2
scr_a_plus_b =
Code:
return argument0 + argument1;
scr_a_plus_b(1, 2) = 3
Code:
return 1 + 2;
If you can understand this:
An argument is data from outside of a script given to the inside of the script.

show_message("Hello World"), we want to change what the message shows. We don't want to have a script for every possible message. "Hello World" is argument0. show_message shows a message of whatever argument0 is. This allows us to have one script to show multiple messages by changing what argument0 is.

I'm not sure about show_massage. .. .. sorry. If you substitute another character string for argumet0, does it mean that the argument put in () is argument0?

Does scr_a_plus_b() mean you can create your own function?
 

Binsk

Member
If you substitute another character string for argumet0, does it mean that the argument put in () is argument0
Yes. If you put values inside () they are arguments. It is like this:
some_function(argument0, argument1, argument2, ...);

Does scr_a_plus_b() mean you can create your own function?
Yes. That is why we have argument0, argument1, ...

You can create your own function and whatever is put in () is given to your function to use. You use the variables put in () by calling argument0, argument1, ...
 
U

uni00

Guest
Yes. If you put values inside () they are arguments. It is like this:
some_function(argument0, argument1, argument2, ...);


Yes. That is why we have argument0, argument1, ...
Thank you for your reply. Should it be named argument?
 

Binsk

Member
Only the code inside your function must be argument. The value in () can be anything.

When people play your game then argument turns in to the value in ().
 
U

uni00

Guest
Only the code inside your function must be argument. The value in () can be anything.

When people play your game then argument turns in to the value in ().
sorry. I can't translate Japanese well.
Is it okay to enter a in () instead of argument0? I'm not sure about the existence of argument0.
 
Let's say you have a script called add_together, and you need it to add 2 numbers. You don't know what 2 numbers you might need to add together, so you can't just put the numbers directly into the script, but you can provide them as arguments. Let's have a look at how we would use the script:
Code:
add_together(1,2); // Here, we are providing 1 and 2 as arguments for the add_together script
Now, let's look at the code inside of the add_together script.

add_together script:
Code:
first_number = argument0; // This makes the variable first_number equal to argument0, which is 1
second_number = argument1; // This makes the variable second_number equal to argument1, which is 2
total_sum = first_number+second_number; // total_sum here will end up as 3, because 1+2 = 3
We could use the same script again and provide different numbers:
Code:
add_together(4,8);
Now let's look at the script code again.

add_together script:
Code:
first_number = argument0; // Argument0 is 4 this time, not 1, because we gave different numbers to the script above, so first_number is equal to 4
second_number = argument1; // Argument1 is now 8, so second_number is equal to 8
total_sum = first_number+second_number; // total_sum here will end up equaling 12, because 4+8 = 12
So the arguments just end up being equal to whatever we put inside the () brackets of a script, and you access the arguments inside the () by using argument0, argument1, argument2, etc.[/code]
 

TheouAegis

Member
引数は関数で使いために提供する数値。数値、テキスト、または数値に評価されるコードを指定できます。独自のスクリプト内で、「argument」って配列それとも「argument0」から「argument15」って変数を使用して引数を参照できます。配列を使用するに、16個を超える引数を使用できます。

instance_create(x, y, obj_cat);

この例で、xはargument0がargument[0]、 yはargument1がargument[1]、obj_catはargument2がargument[2]です。


ごめん、Googleを使ってしまった。日本語の授業は20年前。
 
U

uni00

Guest
I understood the meaning. When creating your own function, first place the arguments you want to use appropriately and place it in argument0. .. .. You can use it as an original script by instructing.

thank you very much!
 
Top