Files
Aurora.3/code/modules/ntsl2/ntsl2.dm
William Lemon 4e365c0eaf NTSL2+ (#6256)
Warning! Big Scary Change!
NTSL2+ is a re-work of NTSL.
The goals of this rework are to remove worries regarding server load, and make it impossible for a malicious program to crash the server.
The result is an asynchronous daemon based interpreted language, called NTSL2+.

The Daemon in question can be found Here

Features:

Programming Language worth considering a programming language
Limit-able execution - Unable to hold the server up
Runs on Modular Computers
Shitty in-game networking.
Players can finally write their own laptop programs I cannot stress that enough.
2019-04-20 18:24:04 +03:00

45 lines
1.5 KiB
Plaintext

/datum/NTSL_interpreter
var/connected = 0
var/list/programs = list()
/datum/NTSL_interpreter/proc/attempt_connect()
var/res = send(list(action="clear"))
if(!res)
log_debug("NTSL2+ Daemon could not be connected to. Functionality will not be enabled.")
else
connected = 1
log_debug("NTSL2+ Daemon connected successfully.")
/datum/NTSL_interpreter/proc/disconnect()
connected = 0
send(list(action="clear"))
for(var/datum/ntsl_program/P in programs)
P.kill()
/datum/NTSL_interpreter/proc/new_program(var/code, var/computer, var/mob/user)
if(!connected)
return 0
log_ntsl("[user.name]/[user.key] uploaded script to [computer] : [code]", istype(computer, /datum/TCS_Compiler/) ? SEVERITY_ALERT : SEVERITY_NOTICE, user.ckey)
var/program_id = send(list(action="new_program", code=code, ref = "\ref[computer]"))
if(connected) // Because both new program and error can send 0.
var/datum/ntsl_program/P = new(program_id)
programs += P
return P
return 0
/*
Sends a command to the Daemon. This is an internal function, and should be avoided when used externally.
*/
/datum/NTSL_interpreter/proc/send(var/list/commands)
if(config.ntsl_hostname && config.ntsl_port) // Requires config to be set.
var/http[] = world.Export("http://[config.ntsl_hostname]:[config.ntsl_port]/[list2params(commands)]")
if(http)
return file2text(http["CONTENT"])
return 0
var/datum/NTSL_interpreter/ntsl2 = new()
/hook/startup/proc/init_ntsl2()
ntsl2.attempt_connect()
return 1