MFGG Forums
  • Home
  • Members
  • Help
  • Search
MFGG Main Site MFGG Forums MFGG Developer Discussion v
« Previous 1 … 11 12 13 14 15 16 Next »
How do you create functions with gamemaker language?
MFGG Forums MFGG Developer Discussion v
« Previous 1 … 11 12 13 14 15 16 Next »
How do you create functions with gamemaker language?
MFGG Forums MFGG Developer Discussion v
« Previous 1 … 11 12 13 14 15 16 Next »
How do you create functions with gamemaker language?
Mark All Posts Read Today's Posts

How do you create functions with gamemaker language?
Canada Mariotroid
Blooper
Members
Submitter Super Reviewer Iso Collab Contributor Sprite Comp Top 5 (3) Minigame Comp Winner Minigame Comp Runner-Up (4) Minigame Comp Top 5 (5) Music Comp Runner-Up Drawing Comp Runner-Up (4) Drawing Comp Top 5 (5) Skull Badge NCFC Contributor (2) Secret Santa
#1
04-19-2018, 06:43 PM
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.

  ↳
United States CGWorks
Hammer Bro
Members
#2
04-19-2018, 08:36 PM (This post was last modified: 04-19-2018, 08:36 PM by CGWorks.)
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
[-] The following 2 users Like CGWorks's post:2 users Like CGWorks's post
  ↳ Pedigree, YoshisIsland3
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
Forum Jump:

Mario Fan Games Galaxy - Powered by MyBB | MFGG Staff | Contact Us

Linear Mode
Threaded Mode