SGScript

1 program Added 2026-02-26T00:00:00Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled Evidence Report issue View issues
Aliases: —
Provenance: commit eb90568dae · authored 2026-02-26T15:38:51+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

SIMSCRIPT (0.50)Scrapscript (0.47)ZScript (0.46)F-Script (0.43)ReScript (0.43)

LLM-contributed programs

Action Flow

Provenance: commit eb90568dae · authored 2026-02-26T15:38:51+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
code.sgs · license: MIT · added: 2026-02-26T00:00:00Z


function pseudosleep( time )
{
	t = ftime();
	while( ftime() - t < time );
}


global Action = {};

function Action.create( init )
{
	data =
	{
		name = '<unnamed>',
		type = '',
		onstart = null,
		ontick = null,
		onend = null,
		ended = false,
	};
	foreach( k, v : init )
		data[ k ] = v;
	return class( data, Action );
}

function Action.createTimed( init )
{
	if( !isset( init, "time" ) )
		init.time = 1.0;
	if( !isset( init, "type" ) )
		init.type = "Timed";
	
	if( isset( init, "ontick" ) )
	{
		oldtick = init.ontick;
		init.ontick = function() use( oldtick )
		{
			this.time -= DT;
			if( this.time <= 0 )
				this.end();
			else if( oldtick )
				oldtick.call( this );
		};
	}
	else
	{
		init.ontick = function()
		{
			this.time -= DT;
			if( this.time <= 0 )
				this.end();
		};
	}
	
	return Action.create( init );
}

function Action.end()
{
	this.ended = true;
}

global ActionFlow =
{
	actions = [],
};

function ActionFlow.tick()
{
	var AA = this.actions;
	for( i = 0; i < AA.size; ++i )
	{
		action = AA[ i ];
		if( action.ontick )
			action.ontick();
		if( action.ended )
		{
			if( action.onend )
				action.onend();
			AA.erase( i-- );
		}
	}
}

function ActionFlow.addAction( act )
{
	this.actions.push( act );
	if( act.onstart )
		act.onstart();
}

function ActionFlow.hasActions()
{
	return !!this.actions;
}


// Test prep

function intro_fade()
{
	println( "time: ", this.time );
}
function intro_end()
{
	ActionFlow.addAction( Action.createTimed({ named = "Stopping...", time = 1.0 }) );
	println( "Stopping in 1 sec!" );
}

ActionFlow.addAction( Action.createTimed({ name = "Intro", time = 2.0, ontick = intro_fade, onend = intro_end }) );


// Test action

starttime = ftime();
while( ActionFlow.hasActions() )
{
	curtime = ftime();
	global DT = curtime - starttime;
	ActionFlow.tick();
	starttime = curtime;
	
	pseudosleep( 0.01 );
}

Contribute — propose a file extension

Tell us where to find evidence about SGScript (mapped to pl/sgscript). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/SGScript/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← SGML sgsh →