Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read("*number") not working in 2.1.1 (always returning 0) #940

Closed
bensoussanj opened this issue Jul 26, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@bensoussanj
Copy link

commented Jul 26, 2017

I came across this issue while trying to load a previously saved state with the Mar I/O script.
Couldn't find anyone with the same issue, so I guessed it must have appeared recently.

Also, this part in the release notes of version 2.1.1 could mean someone broke something while fixing something else:

fix io.open with mode "a"

@zeromus

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2017

Nobody broke something while fixing that. Someone broke something while switching out the 100% of the lua implementation with another. Change the lua core in config > customize, or give me a malfunctioning test case (besides mari/o) I can a/b check between the two lua cores

@adelikat

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2017

if it was a savestate from a 1.x release then that's the problem. Previous SNES savestates are no longer valid in 2.x

@bensoussanj

This comment has been minimized.

Copy link
Author

commented Jul 27, 2017

@adelikat I was only trying to read a text file, not loading a savestate
@zeromus you can try the following code:

	console.clear()
	local fileWrite = io.open("testFile.txt", "w")
	fileWrite:write("Yellow world\n")
	fileWrite:write(18 .. "\n")
	fileWrite:write(36 .. "\n")
	fileWrite:close()
			
	local fileRead = io.open("testFile.txt", "r")
	firstLine = fileRead:read("*l")
	firstNum = fileRead:read("*n")
	fileRead:read()
	secondNum = fileRead:read("*n")
	
	console.writeline("1: " .. firstLine .. " 2. " .. firstNum .. " 3. " .. secondNum)
	fileRead:close()

and this is what it prints in the console:

1: Yellow world 2. 0 3. 0

@zeromus zeromus closed this in 29191a5 Jul 28, 2017

@zeromus

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2017

If it doesn't work, use \r\n (I can't remember for sure now, but I think '\n' will work).

FYI, kopilua's IO library is NOT READY FOR PRODUCTION USE.
We need to pressure people to validate the old luainterface hard so we can ditch kopilua

@vadosnaprimer

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2017

so we can ditch kopilua

It's needed for the future linux port.

@zeromus

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2017

Could use keralua for that instead. I didnt use keralua originally because it had the same problem luainterface+lua did but if I've fixed that, then I know how to fix keralua. With keralua you then build a native lua dll. Basically keralua replaces the managed c++ with more normal pinvoke, I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.