SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Thread Tools Search this Thread
Old 11-02-2017   #1
Default *Fixed Issue* [SRB2PLC] String Not Finding Even Though in File

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.

local function SavePlayerIDList(player, closefile)
	if foundrpgserverdata
		OpenPlayerIDList(player, "r+")
		local linenum = {}
		for line in rpgfilelist.snrpg.playerlistfile:lines()
			table.insert(linenum, line)
		local printedplayeridlistfile = tostring(rpgfilelist.snrpg.playerlistfile:read())
		if (linenum[1] == nil)
			rpgfilelist.snrpg.playerlistfile:write("*Sonic New RPG Mod Player ID List*\n")
		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")
		if (closefile == true)
			ClosePlayerIDList(player, "r+", true)
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 by choalover; 11-03-2017 at 04:03 AM.
choalover is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 09:47 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.