Skip to content

Commit

Permalink
fix windows compatibily and location issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AviationSFO committed Aug 10, 2022
1 parent 3ac9ed9 commit 73f1e53
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
--[[
Wordle Clone made with lua
By Steven Weinstein on 3-10-2022
By Steven Weinstein on 8-9-2022
]]

local function noSpace(str)
local normalisedString = string.gsub(str, "%s+", "")
return normalisedString
end

os.execute("cd ~/Desktop")
os.execute("clear")
-- os.execute("cd ~/Desktop")
-- os.execute("clear")
-- reading available words from file
local dir = os.getenv("PWD") or io.popen("cd ~/Desktop"):read()
local file = io.open(dir .. "/wordle/words-guessable.csv", "r")
-- local dir = os.getenv("PWD") or io.popen("cd ~/Desktop"):read()

local function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end

-- local dir = script_path()

-- print(dir .. "/words-guessable.csv")

local file = io.open("./words-guessable.csv", "r")

local words = {}
local wrongchars = {}
for i = 1, 12974 do
Expand All @@ -21,7 +32,7 @@ for i = 1, 12974 do
end
file:close()
-- opening statment
print("Wordle created by Steven Weinstein Version v1.0.")
print("Wordle created by Steven Weinstein Version v1.1")


-- defining reused functions as part of loading
Expand All @@ -47,7 +58,7 @@ end

-- generates random word as the one to guess
local function generateword()
local file = io.open(dir .. "/wordle/words-answers.csv", "r")
local file = io.open("./words-answers.csv", "r")
local a = {}
for i = 1, 2316 do
a[#a+1] = file:read("*l")
Expand Down

0 comments on commit 73f1e53

Please sign in to comment.