SRB2 Message Board  

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

Reply
 
Thread Tools Search this Thread
Old 11-02-2017   #1
choalover
チャオノコイビト
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.

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.
__________________
I love the new SRB2 2.1.17 update so far.

Last edited by choalover; 11-03-2017 at 04:03 AM.
choalover is offline   Reply With Quote
Reply

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 07:56 AM.


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