KaiserKatze Posted May 9, 2016 Share Posted May 9, 2016 I want to read Don't Starve Together\data\scripts\mainfunctions.lua with the following code: local path_mainfunctions_nix = "../../data/scripts/mainfunctions.lua" local path_mainfunctions_win = "..\\..\\data\\scripts\\mainfunctions.lua" local path_mainfunctions = nil if strfind(GLOBAL.PLATFORM, "win") then path_mainfunctions = path_mainfunctions_win elseif strfind(GLOBAL.PLATFORM, "nix") or strfind(GLOBAL.PLATFORM, "mac") then path_mainfunctions = path_mainfunctions_nix else print("[Debugger] Your platform is not supported!") return -1 end file_mainfunctions = io.open(path_mainfunctions) However the game crashes and outputs the following error: [00:01:32]: [string "../mods/test/modmain.lua"]:31: invalid filepath well, 31st line is the "io.open" invocation... maybe Klei's Lua interpreter implementation has something to do with it? Link to comment Share on other sites More sharing options...
Muche Posted May 9, 2016 Share Posted May 9, 2016 (edited) @Nymphoenix, welcome to the forums. Try local path_mainfunctions = "scripts/mainfunctions.lua" file_mainfunctions = io.open(path_mainfunctions) (even on my Windows it required forward slashes and rejected backslashes). I hope you'll make sure your code is added only if it's needed (i.e. it hasn't been already added), won't crash if the user doesn't have permission to write to it and put instructions how to revert the changes/fix their DST installation on the mod's page. Edited May 9, 2016 by Muche Link to comment Share on other sites More sharing options...
Mobbstar Posted May 10, 2016 Share Posted May 10, 2016 You can load mod files from your mod using "modimport", eg: modimport("strings.lua") loads the file "strings.lua" in the mod's directory. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now