Menu
CoddyTech

Run Script Files

Lesson 1 of 48 in Coddy's GDScript for Lua Developers course.

Lua chunks run top-level statements; GDScript files declare classes whose methods execute through the engine. This course uses Godot 4.7.2 console programs and Lua 5.1 comparisons. Each task has a named RefCounted helper and a locked Node entry script. class_name registers the helper and new() constructs an instance. The supplied _ready() method reads one JSON array and prints the helper result. Run these introductory files unchanged. Later starters intentionally fail behavior until completed. The comparisons use standard Lua, with no game-platform APIs.

challenge icon

Challenge

Easy

Run the supplied files unchanged. Unlike a Lua chunk, the GDScript entry runs in _ready(). The registered Exercise helper returns ready; the locked Node driver reads one JSON array and prints result=ready followed by a newline. Keep the helper in exercise.gd and the entry in main.gd.

Try it yourself

extends Node

func contract_ok(data: Array) -> bool:

	return true

func _ready() -> void:
	var data: Array = JSON.parse_string(OS.read_string_from_stdin())
	if not contract_ok(data):
		print("API_CONTRACT_FAILED")
		return
	print("result=" + Exercise.solve(data))

All lessons in GDScript for Lua Developers

Practice on your own: Online GDScript compiler