From 71d53f167ea4d937bebf5a57b380255df9e7167d Mon Sep 17 00:00:00 2001 From: aconconi Date: Sat, 8 Oct 2022 20:16:30 +0200 Subject: [PATCH 1/2] linting, added porting notes for Lua --- 33_Dice/lua/README.md | 10 +++++++++- 33_Dice/lua/dice.lua | 7 +++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/33_Dice/lua/README.md b/33_Dice/lua/README.md index c063f42f..14d23cc2 100644 --- a/33_Dice/lua/README.md +++ b/33_Dice/lua/README.md @@ -1,3 +1,11 @@ Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html) -Conversion to [Lua](https://www.lua.org/) +Conversion to [Lua](https://www.lua.org/) by Alex Conconi + +--- + +### Porting notes for Lua: + +- This is a straightfoward port with only minor modifications for input validation and text formatting. +- The "Try again?" question accepts 'y', 'yes', 'n', 'no' (case insensitive), whereas the original BASIC version defaults to no unless 'YES' is typed. +- The "How many rolls?" question presents a more user friendly message in case of invalid input. diff --git a/33_Dice/lua/dice.lua b/33_Dice/lua/dice.lua index 7b8d556a..17f9b8a6 100644 --- a/33_Dice/lua/dice.lua +++ b/33_Dice/lua/dice.lua @@ -26,9 +26,8 @@ Lua port by Alex Conconi, 2022. local function print_intro() - print("\n Dice") - print("Creative Computing Morristown, New Jersey") - print("\n\n") + print("\n" .. string.rep(" ", 19) .. "Dice") + print("Creative Computing Morristown, New Jersey\n\n") print("This program simulates the rolling of a") print("pair of dice.") print("You enter the number of times you want the computer to") @@ -85,7 +84,7 @@ local function roll_dice(num_rolls) end -function print_results(counts) +local function print_results(counts) print("\nTotal Spots Number of Times") for roll_total, count in pairs(counts) do print(string.format(" %-14d%d", roll_total, count)) From 79f197c5a3d8de0aad9babe7ff10fcf962008a67 Mon Sep 17 00:00:00 2001 From: aconconi Date: Fri, 14 Oct 2022 20:48:31 +0200 Subject: [PATCH 2/2] Updated Lua porting notes --- 33_Dice/lua/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/33_Dice/lua/README.md b/33_Dice/lua/README.md index 14d23cc2..610e3873 100644 --- a/33_Dice/lua/README.md +++ b/33_Dice/lua/README.md @@ -4,8 +4,13 @@ Conversion to [Lua](https://www.lua.org/) by Alex Conconi --- -### Porting notes for Lua: +### Porting notes for Lua -- This is a straightfoward port with only minor modifications for input validation and text formatting. -- The "Try again?" question accepts 'y', 'yes', 'n', 'no' (case insensitive), whereas the original BASIC version defaults to no unless 'YES' is typed. -- The "How many rolls?" question presents a more user friendly message in case of invalid input. +- This is a straightfoward port with only minor modifications for input +validation and text formatting. + +- The "Try again?" question accepts 'y', 'yes', 'n', 'no' (case insensitive), +whereas the original BASIC version defaults to no unless 'YES' is typed. + +- The "How many rolls?" question presents a more user friendly message +in case of invalid input.