arcticfox1919 / LuaDardo

A Lua virtual machine written in Dart
Apache License 2.0
172 stars 32 forks source link

Unable to create files using io.open() #11

Closed WaterBlueNewWorld closed 2 years ago

WaterBlueNewWorld commented 2 years ago

I'm trying to write a file on C:\Users\Public but when I call the code from file nothing happens

Here is my lua code

function testDartLua()
    file = io.open('C:\\Users\\Public\\file.txt', 'w')
    file:write('hello!')
    file:close(file)
end

And this is my dart code:

import 'package:lua_dardo/lua.dart';

void main(List<String> args) {
  LuaState state = LuaState.newState();
  state.openLibs();
  state.doFile('bin/main.lua');
  state.getGlobal("testDartLua");
  if (state.isFunction(-1)) {
    state.pCall(0, 0, 0);
  }
}

When I run this code the process ends correctly, but the file is not created in the specified directory.

I have also tried using doString(), yet I still got the same result

import 'package:lua_dardo/lua.dart';

void main(List<String> args) {
  LuaState state = LuaState.newState();
  state.openLibs();
  state.doString('''
  file = io.open('C:\\\\Users\\\\Public\\\\file.txt', 'w')
  file:write('hello!')
  file:close(file)
  ''');
}

I would really appreciate any help you can provide about why is this happening

arcticfox1919 commented 2 years ago

Sorry, lua's standard library is not fully implemented!

WaterBlueNewWorld commented 2 years ago

I see. I'm looking forward to it being implemented, if it is possible in the future