mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
More work done on Telecomms:
▫ Signals can now be rejected by Subspace broadcasters through a specific data[] parameter. ▫ Improved the log browser. ▫ Log browsers and telecommunication monitors no longer require access to use. You do need access to delete logs, however. ▫ Intercoms need power to work. They don't drain power, they just need a constant flow of equipment power. As such, that offline intercom sprite's now finally being put to use. Scripting language: ▫ Sorry about all the files; they're all necessary! It's important to notice that the basic structure of the scripting language code is not mine; I cannibalized the base structure from some obscure BYOND project. It's pretty well documented, and I'd say easier to browse through than atmos. Here's the basic deal: A compiler datum manages the relationships between the three main subsystems of a scripting language: the Scanner, the Parser, and the Interpreter. The Scanner splits raw text into token datums that the Parser can read. The Parser transforms the otherwise random bits and strings into ordered AST Trees and nodes for the Interpreter to read. The interpreter actually executes the code and handles scope/functions/code blocks. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3193 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
182
code/modules/scripting/IDE.dm
Normal file
182
code/modules/scripting/IDE.dm
Normal file
@@ -0,0 +1,182 @@
|
||||
client/verb/tcssave()
|
||||
set hidden = 1
|
||||
if(mob.machine)
|
||||
if(istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && mob.machine in view(1, mob))
|
||||
var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
|
||||
if(Machine.editingcode != mob)
|
||||
return
|
||||
|
||||
if(Machine.SelectedServer)
|
||||
var/obj/machinery/telecomms/server/Server = Machine.SelectedServer
|
||||
Server.setcode( winget(src, "tcscode", "text") ) // this actually saves the code from input to the server
|
||||
src << output(null, "tcserror") // clear the errors
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to save: Unable to locate server machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to save: Unable to locate machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to save: Unable to locate machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
|
||||
|
||||
client/verb/tcscompile()
|
||||
set hidden = 1
|
||||
if(mob.machine)
|
||||
if(istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && mob.machine in view(1, mob))
|
||||
var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
|
||||
if(Machine.editingcode != mob)
|
||||
return
|
||||
|
||||
if(Machine.SelectedServer)
|
||||
var/obj/machinery/telecomms/server/Server = Machine.SelectedServer
|
||||
Server.setcode( winget(src, "tcscode", "text") ) // save code first
|
||||
var/list/compileerrors = Server.compile() // then compile the code!
|
||||
|
||||
// Output all the compile-time errors
|
||||
src << output(null, "tcserror")
|
||||
|
||||
if(compileerrors.len)
|
||||
src << output("<b>Compile Errors</b>", "tcserror")
|
||||
for(var/scriptError/e in compileerrors)
|
||||
src << output("<font color = red>\t>[e.message]</font color>", "tcserror")
|
||||
src << output("([compileerrors.len] errors)", "tcserror")
|
||||
|
||||
// Output compile errors to all other people viewing the code too
|
||||
for(var/mob/M in Machine.viewingcode)
|
||||
if(M.client)
|
||||
M << output(null, "tcserror")
|
||||
M << output("<b>Compile Errors</b>", "tcserror")
|
||||
for(var/scriptError/e in compileerrors)
|
||||
M << output("<font color = red>\t>[e.message]</font color>", "tcserror")
|
||||
M << output("([compileerrors.len] errors)", "tcserror")
|
||||
|
||||
|
||||
else
|
||||
src << output("<font color = blue>TCS compilation successful!</font color>", "tcserror")
|
||||
src << output("(0 errors)", "tcserror")
|
||||
|
||||
for(var/mob/M in Machine.viewingcode)
|
||||
if(M.client)
|
||||
M << output("<font color = blue>TCS compilation successful!</font color>", "tcserror")
|
||||
M << output("(0 errors)", "tcserror")
|
||||
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to compile: Unable to locate server machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to compile: Unable to locate machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to compile: Unable to locate machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
|
||||
client/verb/tcsrun()
|
||||
set hidden = 1
|
||||
if(mob.machine)
|
||||
if(istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && mob.machine in view(1, mob))
|
||||
var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
|
||||
if(Machine.editingcode != mob)
|
||||
return
|
||||
|
||||
if(Machine.SelectedServer)
|
||||
var/obj/machinery/telecomms/server/Server = Machine.SelectedServer
|
||||
Server.setcode( winget(src, "tcscode", "text") ) // save code first
|
||||
var/list/compileerrors = Server.compile() // then compile the code!
|
||||
|
||||
// Output all the compile-time errors
|
||||
src << output(null, "tcserror")
|
||||
|
||||
if(compileerrors.len)
|
||||
src << output("<b>Compile Errors</b>", "tcserror")
|
||||
for(var/scriptError/e in compileerrors)
|
||||
src << output("<font color = red>\t>[e.message]</font color>", "tcserror")
|
||||
src << output("([compileerrors.len] errors)", "tcserror")
|
||||
|
||||
// Output compile errors to all other people viewing the code too
|
||||
for(var/mob/M in Machine.viewingcode)
|
||||
if(M.client)
|
||||
M << output(null, "tcserror")
|
||||
M << output("<b>Compile Errors</b>", "tcserror")
|
||||
for(var/scriptError/e in compileerrors)
|
||||
M << output("<font color = red>\t>[e.message]</font color>", "tcserror")
|
||||
M << output("([compileerrors.len] errors)", "tcserror")
|
||||
|
||||
else
|
||||
// Finally, we run the code!
|
||||
src << output("<font color = blue>TCS compilation successful! Code executed.</font color>", "tcserror")
|
||||
src << output("(0 errors)", "tcserror")
|
||||
|
||||
for(var/mob/M in Machine.viewingcode)
|
||||
if(M.client)
|
||||
M << output("<font color = blue>TCS compilation successful!</font color>", "tcserror")
|
||||
M << output("(0 errors)", "tcserror")
|
||||
|
||||
var/datum/signal/signal = new()
|
||||
signal.data["message"] = ""
|
||||
if(Server.freq_listening.len > 0)
|
||||
signal.frequency = Server.freq_listening[1]
|
||||
else
|
||||
signal.frequency = 1459
|
||||
signal.data["name"] = ""
|
||||
signal.data["job"] = ""
|
||||
signal.data["reject"] = 0
|
||||
signal.data["server"] = Server
|
||||
|
||||
Server.Compiler.Run(signal)
|
||||
|
||||
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to run: Unable to locate server machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to run: Unable to locate machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to run: Unable to locate machine. (Back up your code before exiting the window!)</font color>", "tcserror")
|
||||
|
||||
|
||||
client/verb/exittcs()
|
||||
set hidden = 1
|
||||
if(mob.machine)
|
||||
if(istype(mob.machine, /obj/machinery/computer/telecomms/traffic))
|
||||
var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
|
||||
if(Machine.editingcode == mob)
|
||||
Machine.storedcode = "[winget(mob, "tcscode", "text")]"
|
||||
Machine.editingcode = null
|
||||
else
|
||||
if(mob in Machine.viewingcode)
|
||||
Machine.viewingcode.Remove(mob)
|
||||
|
||||
client/verb/tcsrevert()
|
||||
set hidden = 1
|
||||
if(mob.machine)
|
||||
if(istype(mob.machine, /obj/machinery/computer/telecomms/traffic) && mob.machine in view(1, mob))
|
||||
var/obj/machinery/computer/telecomms/traffic/Machine = mob.machine
|
||||
if(Machine.editingcode != mob)
|
||||
return
|
||||
|
||||
if(Machine.SelectedServer)
|
||||
var/obj/machinery/telecomms/server/Server = Machine.SelectedServer
|
||||
|
||||
// Replace quotation marks with quotation macros for proper winset() compatibility
|
||||
var/showcode = dd_replacetext(Server.rawcode, "\\\"", "\\\\\"")
|
||||
showcode = dd_replacetext(showcode, "\"", "\\\"")
|
||||
|
||||
winset(mob, "tcscode", "text=\"[showcode]\"")
|
||||
|
||||
src << output(null, "tcserror") // clear the errors
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to revert: Unable to locate server machine.</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to revert: Unable to locate machine.</font color>", "tcserror")
|
||||
else
|
||||
src << output(null, "tcserror")
|
||||
src << output("<font color = red>Failed to revert: Unable to locate machine.</font color>", "tcserror")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user