Your first gd script
English | 日本語
gd runs GDScript from the terminal. Start with one file; you do not need a scene or project file.
Install and check
Install the current release using the installation guide, then run:
gd --versionSave this as hello.gd:
func main():
print("Hello, world!")
return 0gd hello.gdmain is the entry point. Returning 0 indicates success to the shell. A nonzero exit code indicates failure.
Read arguments
A main function may accept the command-line arguments. Keep validation at the boundary of your script.
func main(args):
var name := "world" if args.is_empty() else str(args[0])
print("Hello, ", name, "!")
return 0gd hello.gd AdaFor named options, use GD.cli and GDCLIFlags.
Understand API signatures
A signature such as read_text(path: String) -> String, Err describes the success value and the error slot. Check the error before using the value. The return section also tells you whether the call waits automatically or returns a Signal to await.
Read and write files introduces error handling. Build a web service uses the same rules in request handlers.