chaoloveicemdboy
Member
This Lua script I'm working on requires SRB2PlusC. I'm having an issue where string.find isn't finding my string in the text file that I've created, even though it is there. As a result, the string is still written to the file, even though it is not supposed to. This issue happens on both string.find and string.match.
EDIT: Nevermind, I came up with a fix. The issue is that I should instead execute string.find inside of a variable, and check that variable.
Code:
local function SavePlayerIDList(player, closefile)
CheckPlayerIDList(player)
if foundrpgserverdata
OpenPlayerIDList(player, "r+")
local linenum = {}
for line in rpgfilelist.snrpg.playerlistfile:lines()
table.insert(linenum, line)
end
local printedplayeridlistfile = tostring(rpgfilelist.snrpg.playerlistfile:read())
if (linenum[1] == nil)
rpgfilelist.snrpg.playerlistfile:write("*Sonic New RPG Mod Player ID List*\n")
end
for lineCount = 2,lastuseridline
player.firstuseridlinestring = "User #" + player.userid + " = " + player.userchecknum + "\n"
player.firstuseridlineresult = string.find(printedplayeridlistfile, player.firstuseridlinestring, 1, true)
if (player.firstuseridlineresult == nil)
rpgfilelist.snrpg.playerlistfile:write("User #" + player.userid + " = " + player.userchecknum + "\n")
end
end
if (closefile == true)
ClosePlayerIDList(player, "r+", true)
end
end
end
EDIT: Nevermind, I came up with a fix. The issue is that I should instead execute string.find inside of a variable, and check that variable.
Last edited: