embeddable scripting language in C
riicchhaarrd / cgsc Goto Github PK
View Code? Open in Web Editor NEWembeddable (game) scripting language in C
Home Page: https://r1chard.nl/gsc
License: MIT License
embeddable (game) scripting language in C
Home Page: https://r1chard.nl/gsc
License: MIT License
embeddable scripting language in C
probably due to handling sizes smaller than 0xff differently in asm
#pragma comment(lib, "msvcrt.dll")
main()
{
for(i=0;i<2000;i++)
{
p=malloc(i);
if(p==0)
{
printf("p=0 at %\n",i);
}
free(p);
}
}
Possible?
I need my game library to call into specific routines in script.
Jarrod
There are (currently) three examples:
fclose
which isn't setup in src_defaultlib.c
.fclose()
allows it to run.This tries to call the function rand()
which isn't defined in src_defaultlib.c
.
Changing the calls to rand()
to read randomint()
allos it to get further.
But even with that we see failures:
deagol ~/cidscropt $ ./bin/cidscropt examples/color_circles.osc
variable 'vid_width' does not exist!
BLOCK=1,curpos=832,at=895
Shuffling the variables around so each is defined in the functions eventually allows it to run, but nothing useful happens:
deagol ~/cidscropt $ ./bin/cidscropt examples/color_circles.osc
built-in function 'set_pixel' does not exist! (0)
Segmentation fault
It looks like variables defined inside functions aren't accessible outside that function, which is is what you'd expect from a C-like function. This is demonstrated by this example:
function bar()
{
global = 3
print("Global set to " + global + "\n" );
}
main() {
bar()
// print("Global is now dead: " + global + "\n")
}
Uncomment the second print and you see a failure - and this is exactly how the code in the color_circles
example is setup - specifically you'll see the function rand_col()
defined variables, and the vid_size
, etc, variables in main aren't available in clear_screen()
.
In short it would be nice if the examples all worked :)
Possible?
I want to be able to compile some sources, bind the byte code to a runner and that runner will check on startup if there a "payload" attached (as a win32 resource), load back in and then execute it.
I looked over the src and example scripts, am I right in assuming
#include <file>
is the only way to include modules of code in script?
[script]
#include <module1>
#include <module2>
#include <module3>
game_startup() {
}
game_shutdown() {
}
game_update(deltaTime) {
}
game_render() {
}
game_show() {
}
main {
...
}
my gamelib will load the main script file, it needs to then load in all the different parts that make up the game script code, I can then compile and save out the bytecode to the runner is what I'm going for. On execution, the lib will then call into the game_xxx functions as needed.
The ability to
#pragma comment(lib, "gamelib.dll")
is so sweet and the thread support, ahh marvelous. How does gsc compare to LuaJit in terms of performance. My current gamelib is using LuaJit and I'm looking to switch to gsc.
Thanks
Jarrod
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.