Syntax #Functions

Functions ฟังก์ชั่น ก็เหมือนกับกลุ่มคำสั่งที่เขียนขึ้นเพื่อทำหน้าที่อย่างใดอย่างหนึ่ง โดยจะแบ่งเป็น ฟังก์ช้่นระบบ กับ ฟังก์ชั่นที่เขียนขึ้นเอง ฟังก์ชั่นในระบบตัวอย่างที่เห็นได้ชั่น และเจอบ่อย ๆ func _ready (): pass func _process ( delta ): pass func _fixed_process ( delta ): pass รูปแบบการสร้างฟังก์ชั่น func ชื่อฟังก์ชั่น (ตัวแปร,ตัวแปรn?): (TAB) pass เช่น func helloworld(): (TAB) print('helloworld') func _ready(): helloworld() helloworld() รูปแบบการพิมพ์ฟังก์ชั่นของ GDScript จะไม่มีเครื่องหมายปิดและเปิดเหมือนโปรแกรมอื่น ยกตัวอย่าง #php function helloworld() { echo "helloworld"; } ดังนั่นการกด (TAB) ย่อหน้าจะเป็นการบอกถึงข้อมูลที่อยู่ในฟังก์ชั่นนั่น ๆ หรือในเงือนไขนั่น ๆ เช่น 1) func helloworld (text): 2) (TAB) if(text!=""): 3) (TAB)(TAB) print(text) 4) func profile () 5) (TAB) print('sittichai...