From af56bbb0d233caa7d40034c0f158a4ea4474d085 Mon Sep 17 00:00:00 2001 From: Ibrahim Abdulhameed Date: Mon, 1 Sep 2025 12:32:09 +0100 Subject: [PATCH] feat: add io --- source/_posts/lua.md | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/source/_posts/lua.md b/source/_posts/lua.md index a67b8da..e3f988f 100644 --- a/source/_posts/lua.md +++ b/source/_posts/lua.md @@ -53,18 +53,6 @@ boys, girls = 2, 3 -- global variables Lua is a dynamically typed language and hence only the values will have types not the variables. -### Comments - -```lua --- This is a single line comments -``` - -```lua ---[[ - Comments (multi-line) could also be written like this ---]] -``` - ### Data Types {.col-span-2 .row-span-2} | Value Type | Description | @@ -80,6 +68,30 @@ Lua is a dynamically typed language and hence only the values will have types no See: [Data Types](#data-types) +### IO + +```lua +-- Writes data to the standard output or a file. +io.write("Enter your name: ") +-- Reads input from the user or a file. You can specify formats like "*l" (line), "*n" (number), or "*a" (all). +name = io.read() + +io.write("Enter your age: ") +age = io.read() +``` + +### Comments + +```lua +-- This is a single line comments +``` + +```lua +--[[ + Comments (multi-line) could also be written like this +--]] +``` + ## Operators ### Arithmetic