1 decade ago
by ape
I'm running into the "Unresolved (circular?) dependencies: weltmeister.weltmeister, weltmeister.edit-entities" error when trying to integrate Impact (and specifically Weltmeister) into a Rails app.
I suspect that the error occurs because Impact expects paths to be a certain way.
A default Rails app's directory structure looks something like this (leaving out directories not relevant to the issue at hand):
my_game
- app (models, controllers and Rails based views live here)
- public (images, css, and javascript live here)
What's important to know is that if I fire up the built in Rails server, paths to static files look like this:
http://localhost:3000/a_file_in_public.html
http://localhost:3000/images/an_image.png
So the question is:
Where should I put both weltmeister.html and the welmeister directory?
1 decade ago
by ape
It occurs to me after looking a bit deeper that perhaps Welmeister needs to be able to make requests to api/save.php and so on. I'll dig a bit deeper and see if I can port the API to Rails.
Knowing exactly what's going on with the "circular dependencies" error would still be good to know.
1 decade ago
by ape
I think I've been able to successfully port the api files to Ruby, but I'm back to where I started with a circular dependencies issue.
I'm routing all requests to the original API calls like so:
match '/lib/weltmeister/api/glob.php', :controller => 'weltmeister', :action => 'w_glob', :via => [:get, :post]
This will route any request to the original config.php call to a Rails controller and action. The code for that looks like:
def w_glob
glob = Dir.glob(RAILS_ROOT + '/public/lib/game/entities/*').each do |g|
g.gsub!(RAILS_ROOT + '/public/lib','')
end
render :text => glob.to_json
end
Here's what a request made by Welmeister will produce:
GET "/lib/weltmeister/api/glob.php?glob=%2Fgame%2Fentities%2F*.js"
Produces
["/game/entities/ball.js"]
I've adjust the following parts of config.js:
wm.config = {
project: {
'modulePath': '/lib',
'entityFiles': '/game/entities/*.js',
'levelPath': '/game/levels/',
'outputFormat': 'module' // 'module' or 'json'
},
/* ... */
'api': {
'save': '/lib/weltmeister/api/save.php',
'browse': '/lib/weltmeister/api/browse.php',
'glob': '/lib/weltmeister/api/glob.php'
}
};
So I'm back to where I began. What causes the circular dependency errors and how can I stop getting them?
1 decade ago
by dominic
The error message appears whenever dependencies can't be resolved. It's not necessarily because of a circular dependency, but it
may be.
Scripts in Impact
have to be loaded from the
lib/
directory. It is hardwired like that in the engine. (
impact.js
line 189 if you really want to change it)
Even if your glob script returns
["/game/entities/ball.js"]
Weltmeister attempts to load the
module game.entities.ball
which is resolved to
lib/game/entities/ball.js
- so
http://localhost:3000/lib/game/entities/ball.js has to be reachable.
Check the network tab of your browsers console, to see which .js files are actually loaded. If your server returns proper error codes (e.g. 404 when the js file is not found), Weltmeister should tell you exactly which file it can't load.
Also make sure that the name of your ball module is
"game.entities.ball
.
I don't know enough about Rails to give you a definite solution, sorry.
1 decade ago
by ape
The exact error is:
Unresolved (circular?) dependencies: weltmeister.weltmeister, weltmeister.edit-entities, weltmeister.entities
At first, I was having issues with entities loading but was able to easily adjust Rails' routing to match what Welmeister expected.
I'm having a harder time, however, with the files listed in the error above. Weltmeister doesn't actually talk to the server for those files, so I'm guessing my root path isn't correct.
Should weltmeister.html be at
http://localhost/lib/weltmeister.html or somewhere else?
1 decade ago
by Neil
Ape, did you manage to get this working? Presumably we now have a choice of 1) integrating ImpactJS directly within Rails (the route I'd like to take), or 2) mounting the impact.rb Sinatra app within Rails
https://github.com/chrisdarroch/impactrb/blob/master/impact.rb
Page 1 of 1
« first
« previous
next ›
last »