You are not logged in.
Pages: 1
I'm making websites with SurgeScript..
In a .bat file (Windows only) put this:
surgescript.exe web.ss > web.html
This is the web.ss:
object "Application"
{
state "main"
{
Console.print('<!DOCTYPE HTML>');
Console.print('<html>');
Console.print('<head>');
Console.print('<title>Hello World from SurgeScript</title>');
Console.print('</head>');
Console.print('<body>');
Console.print('<p>Hello <b>World</b>!</p>');
Console.print('</body>');
Console.print('</html>');
Application.exit();
}
}
And this is your website:
Hello World!
I'm missing how to start a local server, but that can be done with several tools, I'm running it with VS Code 'Live Server' plugin. Or you can double click the file...
Offline
I never thought of it, but creating a website with SurgeScript might indeed be possible
You can have your .bat file call SurgeScript to serve a web page. You can also pass command line arguments to your script, so you can receive some input. Link your .bat to a web server (use CGI or something) and voilá, you have the first website ever written in SurgeScript served to the web
Offline
Yes, it's an idea.
I don't have currently access to a CGI server, but I can try locally.
The thing that diferentiates a language from the rest, is not just the intrinsic language features, but all the libraries available to use.
For that, I asked about having an 'import' clause, instead of feeding the executable with all sources one by one. So libraries can be distributed anywhere, and you need to just import them, or put them in the surgescript 'path'.
Offline
But don't worry adding import, it was just a sugerence, is not needed for the game, better focus on the main goal, that's using it with the game engine.
I can run a bat and add all the files with no problem
Offline
Regarding the game, I would like that users have the ability to just put their scripts on a folder like scripts/ and let the game just work without any issues.
But I'll think about it.
Suppose that you have a single instance of an object, say, SceneManager, and that you need to use it frequently in the game. How would you import it into your script?
Offline
Regarding the game, I would like that users have the ability to just put their scripts on a folder like scripts/ and let the game just work without any issues.
Yes, is the best.
Suppose that you have a single instance of an object, say, SceneManager, and that you need to use it frequently in the game. How would you import it into your script?
What you are saying is a global variable, or static methods, or a mix of both.
With global variable, if the unit is in the imports section, that variable is available for that unit and objects inside.
like
// in scenemanager.ss, somewhere
GlobalSceneManager = spawn(SceneManager);
import 'scenemanager.ss'
GlobalSceneManager.doSomething() //.. call of the global variable, the advantage on this is that the state is stored in the global, and any unit that imports it can access (read, write) the state of this global
With static methods, if the unit is in the imports section, the class methods are available with no need to instantiate them.
import 'scenemanager.ss'
object SceneManager {
hello_string_never_recheable_from_static_methods (variable visible only for an instance)
static hello_static_string (global variable inside a class, visible outside)
static fun doSomething...
}
SceneManager.doSomething() //.. with no need to instantiate
What I know, is that static methods only uses the data inside of them, and also static fields. But they don't have a 'state' of the normal fields.
So you can implement globals or static class methods.
Or something better, like an object that's global
global object SceneManager {
}
it can be instantiated automatically by the engine, or instantiated only the first time by the code
The name of the object is SceneManager, and you call it like SceneManager.doSomething()..
Offline
Pages: 1