ftguy2018 Posted October 29, 2018 Share Posted October 29, 2018 Is there a way to import a JS file into the project in such of way that when we export for WEB it will be included into the game.min.js ? Quote Link to comment Share on other sites More sharing options...
Wolfsbane Posted October 30, 2018 Share Posted October 30, 2018 Like loading it as a plugin? Quote Link to comment Share on other sites More sharing options...
ftguy2018 Posted November 2, 2018 Author Share Posted November 2, 2018 Yes, like loading as a plugin and so it can be obfuscate as 1 file ? actually I am just copy pasting the javascript into the main file but it is not really convenient Quote Link to comment Share on other sites More sharing options...
pstrejczek Posted November 2, 2018 Share Posted November 2, 2018 Why not separate that code into class/classes in Panda2 instead of copy pasting to the main file? This would keep the code maintainable and should still result in single game.min.js If it is some kind of library that is reusable it's better to pack it into a plugin - it seems to be quite simple. Quote Link to comment Share on other sites More sharing options...
ftguy2018 Posted November 2, 2018 Author Share Posted November 2, 2018 Because it is an external library coming from outside the panda2 dev environment and so I am looking for a quick and simple way to use it and to maintain it by copy pasting a new version and have it "included" in the output JS Quote Link to comment Share on other sites More sharing options...
enpu Posted November 3, 2018 Share Posted November 3, 2018 Just create new module and copy paste the content of the JS file into it. Quote Link to comment Share on other sites More sharing options...
ftguy2018 Posted November 5, 2018 Author Share Posted November 5, 2018 Thank you I will look into how to doing modules, is there a quick tutorial about how to create modules using the latest panda2 editor ? Quote Link to comment Share on other sites More sharing options...
Wolfsbane Posted November 5, 2018 Share Posted November 5, 2018 There's one on the main website: https://www.panda2.io/tutorials/module Quote Link to comment Share on other sites More sharing options...
ftguy2018 Posted November 6, 2018 Author Share Posted November 6, 2018 actually it is using the old editor, the new editor has a different layout and pressing the + button in the tab does not do anything, do I need to update the editor ? Quote Link to comment Share on other sites More sharing options...
ftguy2018 Posted November 6, 2018 Author Share Posted November 6, 2018 On 11/3/2018 at 6:04 PM, enpu said: Just create new module and copy paste the content of the JS file into it. @enpu I am sorry maybe it is a very simple question but I am not so familiar with the module concept So let's say if I wanted to add that secure-ls JS file into a module so it can be called from the game and could access the new secure-ls class and export it in the main game.min https://github.com/softvar/secure-ls/tree/master/dist Where should I copy paste the code, into the file ? anywhere before the module keyword ? into the class , before the body function ? can you please shine some light ? And once again sorry if that question is maybe simple just I want to be sure to do it right. Thank you, Quote Link to comment Share on other sites More sharing options...
ftguy2018 Posted November 8, 2018 Author Share Posted November 8, 2018 Ok I could find a way to include the file in a module Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.