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
sousben opened this issue Jul 26, 2017 · 6 comments
Closed

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

sousben opened this issue Jul 26, 2017 · 6 comments
Labels
Question/Support re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console)

Comments

@sousben
Copy link

sousben 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
Copy link
Contributor

zeromus 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
Copy link
Contributor

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

@sousben
Copy link
Author

sousben 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
Copy link
Contributor

zeromus 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
Copy link
Contributor

vadosnaprimer commented Jul 28, 2017

so we can ditch kopilua

It's needed for the future linux port.

@zeromus
Copy link
Contributor

zeromus 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

@YoshiRulz YoshiRulz added re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console) Question/Support labels Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question/Support re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console)
Projects
None yet
Development

No branches or pull requests

5 participants