Default Values for Optional Arguments Update [GameMaker Studio 2.3]

  Рет қаралды 1,902

SamSpadeGameDev

SamSpadeGameDev

Күн бұрын

Пікірлер: 21
@sudobeats6978
@sudobeats6978 3 жыл бұрын
Hey I just wanted to say that you are one of my favorite channels on youtube for GameMaker content. Your videos are incredible and you're really great at explaining different concepts. Keep up the great work!
@meganinja456
@meganinja456 Жыл бұрын
Note: it's now possible to use a default for the first argument but still pass in for example, the second or a later argument by doing: ----my_func( , 1) In that example, it'll use the default for the first argument and "1" for the second. You can even do crazy stuff like: ----my_func( , , , 3, , 4) Don't know when they added it, but it's SO NICE. ❤
@headspin4120
@headspin4120 3 жыл бұрын
Thank you!😀
@Ruth-cz6lc
@Ruth-cz6lc 3 жыл бұрын
I think I didn't get anything but I like the delivery, thank you.
@FoxyOfJungle
@FoxyOfJungle 3 жыл бұрын
Thank you!
@Ldinos
@Ldinos 3 жыл бұрын
I like how you can pass functions in functions (just like you did with alarm_event), but does that only work when you know how many arguments that function will have? For example, if the user basically calls alarm_event(arg1,arg2,arg3..), will it throw an error because alarm_event is expected to run without any arguments?
@SamSpadeGameDev
@SamSpadeGameDev 3 жыл бұрын
I'm not entirely sure I understand the question, but in this particular example, the alarm_event shouldn't use any arguments because when it is called, no arguments are being passed in.
@Ldinos
@Ldinos 3 жыл бұрын
​@@SamSpadeGameDev Thank you! Basically, my question was how to run a function inside a function if you dont know how many arguments the user can give but I think I found out a solution function func_runner(func) { func() } func_runner( function(arg1, arg2....etc) {... } ) This works! Though, the scope of the arguments is kinda weird
@derpmorederp1417
@derpmorederp1417 3 жыл бұрын
Previously I'd just been passing in whole numbers, checking if they aren't zero and then just having stuff run based on that. I had the one calling the function regulate whether the inputs where zero or not. It sounds great, but I hope I don't have to rebuild a whole project If I update.
@SamSpadeGameDev
@SamSpadeGameDev 3 жыл бұрын
I know there were some issues with the update for some people: forum.yoyogames.com/index.php?threads/2-3-3-stable-release-thread.87375/page-3#post-524002. I haven't experienced any, but I mostly have small projects. My guess is any serious ones will be fixed within the next week or so.
@Ailwuful
@Ailwuful 3 жыл бұрын
Please don't stop doing God's work. Thank you.
@SamSpadeGameDev
@SamSpadeGameDev 3 жыл бұрын
Not planning to :)
@kyoto4167
@kyoto4167 3 жыл бұрын
have any to pass just one argument that I want? for example: function(one=0, two=0) I want to pass just the argument two, have any way?
@SamSpadeGameDev
@SamSpadeGameDev 3 жыл бұрын
Not that I'm aware of. Arguments get assigned in the order they're passed in, so if you pass in one argument its value is always assigned to one in your example.
@ultraken
@ultraken 3 жыл бұрын
You can get the default value for any argument by passing it a value of undefined. In your example, you could call function(undefined, 42) and argument one would have a value of 0 and argument two would have a value of 42.
@kyoto4167
@kyoto4167 3 жыл бұрын
@@ultraken Thanks for rply. I am wanting to pass just what I want cuz I dont want to type everything that I want to be default. My example is very simple, but in my project, the arguments can be something like, 15,20 arguments, idk at now, but will be a huge number. I am looking to others way so solve it.
@SamSpadeGameDev
@SamSpadeGameDev 3 жыл бұрын
Do you mean that the value passed in is 15 or 20 or that the function has 15 to 20 arguments? If the latter, it might be worth asking on the GMC forum for suggestions on refactoring the function. It is very rare that a function needs more than 3 or 4 arguments and they almost never need more than 5 or 6.
@ultraken
@ultraken 3 жыл бұрын
I assumed 15 or 20 different arguments. One possible solution for that would be to pass a struct to the function instead of a whole bunch of separate arguments. (That's often done in programming languages like C/C++)
@yokmp1
@yokmp1 3 жыл бұрын
This took only like 3 years to be added ... wow
@SamSpadeGameDev
@SamSpadeGameDev 3 жыл бұрын
True. From what I understand, Playtech didn't really support YoYo, so, while there were improvements, anything that was nice, but not technically necessary, was but on the backburner. Since Opera took over though, YoYo has been putting out consistent updates, promoting GameMaker more, making official tutorials, and so on. Hopefully, this will work for them and they'll continue to do it since, as a long-time fan of GameMaker, it's been nice.
Introduction to Steering Behaviors in GameMaker Studio 2
11:01
SamSpadeGameDev
Рет қаралды 7 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 108 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
I Spent 100 Hours Inside The Pyramids!
21:43
MrBeast
Рет қаралды 60 МЛН
Optimizing Steering Behaviors for GameMaker Studio 2
9:16
SamSpadeGameDev
Рет қаралды 4,8 М.
Using Sequences to Make Complex Objects in GameMaker Studio 2
7:11
SamSpadeGameDev
Рет қаралды 7 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 585 М.
5 deadly Rust anti-patterns to avoid
13:25
Let's Get Rusty
Рет қаралды 41 М.
A Beginner's Guide to GameMaker's Core Building Blocks
6:55
SamSpadeGameDev
Рет қаралды 2,9 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 858 М.
Using ChatGPT-4 to Make a Game with GameMaker
7:05
SamSpadeGameDev
Рет қаралды 9 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19