Page 5 of 22

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 8:26 am
by Germanunkol
Actually, I just had a friend test on a win PC last night and she had the exact same problem (that and the fact that she couldn't find the AI folder at first because it is hidden).
I have no idea what's wrong with it, but it might be that the paths are messed up on the windows version. The problem should be somewhere in ai.lua, but it's quite a complex setup.
If you don't want to poke around give me a few days and I'll try to work it out...

Edit: Maybe you could try it once more and give me the console printout (after trying the "reload"-button) when you start with the --console option?

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 12:21 pm
by gennn
Hi!
I have the same problem. I think this is the relevant part i get in the console:

Code: Select all

scriptName      C:/Users/hp3015/AppData/Roaming/LOVE/trAinsported.love\AI\trAins
ported.love\AI\TutorialAI1.lua
Err: Scripts/ai.lua:86: attempt to index global 'fh' (a nil value)
Your game looks beautiful, looking forward to play it! :awesome:

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 4:23 pm
by LuaWeaver
EDIT: I found the bug! Windows uses both backslashes and forward slashes when talking about directories, but only one at a time. It prints "scriptName C:/Users/Ben Zastawnik/AppData/Roaming/LOVE/trAInsported\AI\TutorialAI1.lua", and the differing slashes cause Windows to have a panic attack and not open the file.

EDIT 2: Damn, you beat me to it! I spent too long fiddling with the PATH variables instead of just modifying love.conf.

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 4:40 pm
by Germanunkol
@ gennn: Thanks, that was indeed the problem!
@ LuaWeaver: You're right, I messed up there. The error is actually occurring much earlier in the process: I set the wrong path to the AI folder on windows systems.

I did not know Löve/Lua handle the path's slashes for me. So I thought I had to differ between the two and use \ for Windows and / for Unix systems. I was wrong there, I should be using / for both.

I've sent a version to a friend to test. If you want to test it yourself, in main.lua, replace this:

Code: Select all

		AI_DIRECTORY = love.filesystem.getSaveDirectory()
		if AI_DIRECTORY:find("/") == 1 then		-- Unix style!!
			AI_DIRECTORY = AI_DIRECTORY .. "/AI/"
		else
			AI_DIRECTORY = AI_DIRECTORY .. "\\AI\\"
		end
with this:

Code: Select all

		AI_DIRECTORY = love.filesystem.getSaveDirectory()
		AI_DIRECTORY = AI_DIRECTORY .. "/AI/"
This has not been confirmed to work yet - if it does, please tell me! Otherwise I'll wait for confirmation by my friend and upload a new version once that's sorted out.

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 5:03 pm
by LuaWeaver
Yes, it does work on my machine now! I can get past the tutorial now just fine.

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 6:47 pm
by Germanunkol
Great! Thanks for reporting. WIll update the .love file in the first post sometime tomorrow, probably.

@Ronald_Yonaba: I think at some point I'll try to implement your pathfinding into an AI... it looks very solid: https://github.com/Yonaba/Jumper :D Or does any one else want to give it a try?
Right now I still don't allow "require" in AIs, as that will be hard to work with when uploading -> I only want to allow one file to be uploaded at a time.
Any thoughts on this? Any ideas how I could allow the require function?
Only way I can think of right now is to parse the file, look for "require" calls, then copy+paste those files into the file where the require call was...? But when? Maybe upon upload? Anyone with enough php knowledge for this?

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 9:19 pm
by Taz
@Germanunkol

Isn't it possible to just upload a zip file to your server and read all the related .lua-files out of it ? Here is a library that can load .zip files : http://www.keplerproject.org/luazip/manual.html

Hope this helps :nyu:

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 10:16 pm
by Germanunkol
That's a good idea, but then people would have to zip the files correctly - which is simple enough, but another hurdle to overcome. Also, upon zipping, hierarchy may be lost... in case someone includes a file from somewhere else.

The longer I think of it, the more I like this approach:
When a user chooses a file to upload, the script searches the file beforehand for "require" statements. All the files found are copied into the main source file (but only the copy which is to be uploaded - the file on the computer stays the same). Then I'd only have one file uploaded and this would be a fully functional AI - no need to change my server code. It's already ugly enough as it is, because it has to work with a mysql database to load the files.
But I'd really have to dive even further into javascript/php for this.
So I'll give it more thought and maybe go for your .zip idea...

Re: trAInsported: Alpha testers needed

Posted: Mon Feb 18, 2013 10:58 pm
by Robin
Germanunkol wrote:When a user chooses a file to upload, the script searches the file beforehand for "require" statements. All the files found are copied into the main source file (but only the copy which is to be uploaded - the file on the computer stays the same). Then I'd only have one file uploaded and this would be a fully functional AI - no need to change my server code.
Good grief, that is ugly.
  1. If you do this, at least wrap the included scripts in do ... end blocks, otherwise locals will break.
  2. I don't know how errors are handled, but if the uploader gets to see tracebacks when something goes wrong, this approach renders them nearly useless.
  3. Ugh.

Re: trAInsported: Alpha testers needed

Posted: Tue Feb 19, 2013 8:31 am
by Germanunkol
Good point.
I was going to use functions instead of do ... end blocks, because that way a object oriented approach in the form of:

Code: Select all

object = {}
function object.new()
   ...
end

return object
would not be destroyed.

How about this approach: The upload script looks for all the require calls and then automatically zips those files and uploads the zipped file? That way users wouldn't have to deal with it...
No idea how to do this though.