Skip to content

Commit 2846dee

Browse files
committed
Minor fixes (file)
- Code formatting - Typos
1 parent bc40f30 commit 2846dee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+175
-171
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local newFile = fileCreate("test.txt") -- attempt to create a new file
2-
if newFile then -- check if the creation succeeded
3-
fileWrite(newFile, "This is a test file!") -- write a text line
4-
fileClose(newFile) -- close the file once you're done with it
5-
end
1+
local newFile = fileCreate("test.txt") -- attempt to create a new file
2+
if newFile then -- check if the creation succeeded
3+
fileWrite(newFile, "This is a test file!") -- write a text line
4+
fileClose(newFile) -- close the file once you're done with it
5+
end
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local newFile = File.new("test.txt") -- attempt to create a new file
2-
if (newFile) then -- check if the creation succeeded
3-
newFile:write("This is a test file!") -- write a text line
4-
newFile:close() -- close the file once you're done with it
5-
end
1+
local newFile = File.new("test.txt") -- attempt to create a new file
2+
if (newFile) then -- check if the creation succeeded
3+
newFile:write("This is a test file!") -- write a text line
4+
newFile:close() -- close the file once you're done with it
5+
end

functions/File/examples/fileCopy-2.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ addEventHandler("onResourceStart", resourceRoot, function(res)
22
local filePath = ":"..getResourceName(res).."/test.txt"
33
fileCreate(filePath) --create the file in this resource and name it 'test.txt'.
44
if fileCopy(filePath, ":"..getResourceName(res).."/test1.txt") then
5-
outputChatBox("File was successfully copied!", root, 0, 100, 0)
5+
outputChatBox("File was successfully copied!", root, 0, 100, 0)
66
else
7-
outputChatBox("File was not successfully copied, probably because it doesn't exist.", root, 100, 0, 0)
7+
outputChatBox("File was not successfully copied, probably because it doesn't exist.", root, 100, 0, 0)
88
end
99
end)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local newFile = fileCreate("test.txt") -- attempt to create a new file
2-
if (newFile) then -- check if the creation succeeded
3-
fileWrite(newFile, "This is a test file!") -- write a text line
4-
fileClose(newFile) -- close the file once you're done with it
5-
end
1+
local newFile = fileCreate("test.txt") -- attempt to create a new file
2+
if (newFile) then -- check if the creation succeeded
3+
fileWrite(newFile, "This is a test file!") -- write a text line
4+
fileClose(newFile) -- close the file once you're done with it
5+
end
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local newFile = File.new("test.txt") -- attempt to create a new file
2-
if (newFile) then -- check if the creation succeeded
3-
newFile:write("This is a test file!") -- write a text line
4-
newFile:close() -- close the file once you're done with it
5-
end
1+
local newFile = File.new("test.txt") -- attempt to create a new file
2+
if (newFile) then -- check if the creation succeeded
3+
newFile:write("This is a test file!") -- write a text line
4+
newFile:close() -- close the file once you're done with it
5+
end
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
local newFile = fileCreate("test.txt") -- attempt to create a new file
2-
if (newFile) then -- check if the creation succeeded
3-
fileWrite(newFile, "This is a test file!") -- write a text line
4-
fileClose(newFile) -- close the file once you're done with it
5-
fileDelete("test.txt") -- delete file
6-
end
1+
local newFile = fileCreate("test.txt") -- attempt to create a new file
2+
if (newFile) then -- check if the creation succeeded
3+
fileWrite(newFile, "This is a test file!") -- write a text line
4+
fileClose(newFile) -- close the file once you're done with it
5+
fileDelete("test.txt") -- delete file
6+
end
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
local newFile = File.new("test.txt") -- attempt to create a new file
2-
if (newFile) then -- check if the creation succeeded
3-
newFile:write("This is a test file!") -- write a text line
4-
newFile:close() -- close the file once you're done with it
5-
File.delete("test.txt") -- delete file
6-
end
1+
local newFile = File.new("test.txt") -- attempt to create a new file
2+
if (newFile) then -- check if the creation succeeded
3+
newFile:write("This is a test file!") -- write a text line
4+
newFile:close() -- close the file once you're done with it
5+
File.delete("test.txt") -- delete file
6+
end
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
function checkExistingFile(player,cmd,filename,resourcename)
1+
function checkExistingFile(player, cmd, filename, resourcename)
22
if not filename then -- if the player didn't include a filename
33
outputChatBox("ERROR: Syntax '/checkfile filename resourcename(optional)'.",player) -- display error
44
return false -- stop function
55
end
6+
67
if not resourcename then -- if the player didn't specify the resource he wants to check, use current resource
78
resourcename = getResourceName(resource) --every resource has a predefined global variable called resource that contains the resource pointer for that resource, in other words, the value that getThisResource() function returns.
89
else
@@ -11,12 +12,13 @@ function checkExistingFile(player,cmd,filename,resourcename)
1112
return false -- stop the function here
1213
end
1314
end
15+
1416
-- as it hasn't stopped anywhere, we have both correct resourcename and filename
1517
local exists = fileExists((":%s/%s"):format(resourcename,filename)) -- using shorter format of string.format, see StringLibraryTutorial in lua wiki for that
1618
if exists then
17-
outputChatBox(("The file %q in resource %q exists"):format(filename,resourcename))
19+
outputChatBox(("The file %q in resource %q exists"):format(filename,resourcename), player)
1820
else
19-
outputChatBox(("The file %q in resource %q doesn't exist"):format(filename,resourcename))
21+
outputChatBox(("The file %q in resource %q doesn't exist"):format(filename,resourcename), player)
2022
end
2123
end
2224
addCommandHandler("exists",checkExistingFile)
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
function checkExistingFile(player,cmd,filename,resourcename)
1+
function checkExistingFile(player, cmd, filename, resourcename)
22
if (not filename) then -- if the player didn't include a filename
33
player:outputChat("ERROR: Syntax '/checkfile filename resourcename(optional)'.") -- display error
44
return false -- stop function
55
end
6+
67
if (not resourcename) then -- if the player didn't specify the resource he wants to check, use current resource
78
resourcename = resource.name --every resource has a predefined global variable called resource that contains the resource pointer for that resource, in other words, the value that getThisResource() function returns.
89
else
@@ -11,12 +12,13 @@ function checkExistingFile(player,cmd,filename,resourcename)
1112
return false -- stop the function here
1213
end
1314
end
15+
1416
-- as it hasn't stopped anywhere, we have both correct resourcename and filename
1517
local exists = File.exists((":%s/%s"):format(resourcename,filename)) -- using shorter format of string.format, see StringLibraryTutorial in lua wiki for that
1618
if (exists) then
17-
outputChatBox(("The file %q in resource %q exists"):format(filename,resourcename))
19+
player:outputChat(("The file %q in resource %q exists"):format(filename,resourcename))
1820
else
19-
outputChatBox(("The file %q in resource %q doesn't exist"):format(filename,resourcename))
21+
player:outputChat(("The file %q in resource %q doesn't exist"):format(filename,resourcename))
2022
end
2123
end
2224
addCommandHandler("exists",checkExistingFile)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
local newFile = fileCreate("test.txt") -- attempt to create a new file
2-
if (newFile) then -- check if the creation succeeded
1+
local newFile = fileCreate("test.txt") -- attempt to create a new file
2+
if (newFile) then -- check if the creation succeeded
33
local path = fileGetPath(newFile)
4-
outputChatBox("New file created at: "..path, root, 0, 255, 0)
5-
fileClose(newFile) -- close the file once you're done with it
6-
end
4+
outputChatBox("New file created at: " .. path, root, 0, 255, 0)
5+
fileClose(newFile) -- close the file once you're done with it
6+
end

0 commit comments

Comments
 (0)