Menu
CoddyTech

Text and Comments

Lesson 2 of 48 in Coddy's GDScript for Luau Developers course.

Luau executes top-level statements and uses -- for comments. GDScript statements run inside functions; the supplied Node enters _ready. GDScript uses # for comments, while a quoted # remains data. Luau print separates arguments with tabs in this CLI; GDScript print concatenates arguments without separators. Construct exact report text rather than depending on implicit spacing. The exercises return values from helpers and leave printing to the locked entry point. This is general console programming, with no Roblox services or game objects.

Complete Luau comparison. Save the files together and run main.luau with the Luau CLI:

File main.luau:

-- A comment does not print.
print("tag", 7)
print("# data")

Luau output:

tag	7
# data

Complete GDScript comparison:

File main.gd:

extends Node

func _ready() -> void:
	print("tag", 7)
	print("# data")

GDScript output:

tag7
# data
challenge icon

Challenge

Easy

Return the exact text item=<name>;count=<n>. Inputs are a name and an integer. Do not print in the helper.

Input is one JSON array on stdin. The locked main parses it, calls the public APIs and prints result= followed by the returned text and a newline. No helper should print. Independent fixed probes verify required API behavior before the input case; they do not enforce implementation style.

Your code goes in exercise.gd. main.gd holds the supplied input/output code and cannot be edited. Keep each class_name type in its named file.

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))
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in GDScript for Luau Developers

Practice on your own: Online GDScript compiler