darozak / Advolition

1 stars 0 forks source link

Allow user to run script from file #54

Closed darozak closed 5 months ago

darozak commented 5 months ago

Allow the user to select and run a robot script from a computer text file. It should be possible to do this using the eval() function.

I also found instructions for selecting and importing a local text file into a string.

darozak commented 5 months ago

I found instructions for using eval() to define a class.

darozak commented 5 months ago

I think I can do this by having the 'main' script evaluate the text in an HTML field every time it is run. The HTML field will contain a robot class definition that is added to the game engine.

The main function itself will be called when a "Run" button is pressed in the browser.

darozak commented 5 months ago

Success!!! I'm now able to read and run a robot script from an HTML text area (https://github.com/darozak/Advolition/commit/db4c2aed1680e2bb2fff12cb123461ecbd9d5152).

Next, I need to make a button that will stop the script when it's running.

darozak commented 5 months ago

I added an HTML button and JS function to stop the game when it is running (https://github.com/darozak/Advolition/commit/c0c618eb629295f5c0b81449a6a3202f43ea742d).

Now I need to write a function that will allow the user to load a robot script from a local file.

darozak commented 5 months ago

I removed the text input field. Rather, the player can now load their robot script from a local file and the game engine will use it for the game (https://github.com/darozak/Advolition/commit/487af977d557743e39876001d6de9a6a49ea7ad6). This issue has been resolved and is working well!