The following warnings occurred:
Warning [2] unserialize(): Error at offset 1251 of 1260 bytes - Line: 2650 - File: inc/functions.php PHP 8.3.36 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 2650 unserialize
/inc/class_datacache.php 138 native_unserialize
/inc/init.php 182 datacache->cache
/global.php 20 require_once
/printthread.php 16 require_once



MFGG Forums
How do you create functions with gamemaker language? - Printable Version

+- MFGG Forums (https://forums.mfgg.net)
+-- Forum: MFGG (https://forums.mfgg.net/forumdisplay.php?fid=4)
+--- Forum: Developer Discussion (https://forums.mfgg.net/forumdisplay.php?fid=10)
+--- Thread: How do you create functions with gamemaker language? (/showthread.php?tid=768)



How do you create functions with gamemaker language? - Mariotroid - 04-19-2018

I' asking this cause I looked into functions but it doesn' explain how to name an expression and then set the arguments. Does anyone know how to create a function name then the arguments? Thanks in advance.


RE: How do you create functions with gamemaker language? - CGWorks - 04-19-2018

user-defined functions are just called Scripts in GML. Just as a simple example if you wanted to create a simple addition script that adds 2 arguments together you would:

Create a script resource and name it something like "scr_add"

open the script resource you created and then put something like:

(in GMStudio 1.x)
Code:
///scr_add(first value, second value) return argument0 + argument1;

(in GMStudio 2.x)
Code:
///@function scr_add(first value, second value) ///@arg first value ///@arg second value return argument0 + argument1;


Then you can call it from an object