mirror of
https://github.com/LDDestroier/CC/
synced 2025-02-22 22:10:03 +00:00
Create goto-snippet.lua
This is a snippet, not an API. Firstly, never ever ever use GOTO. Never even code GOTO. Neve-oh fuck Declare tags with --::tagName:: Goto tags with goto(tagName). Don't include any colons or hyphens. goto(tag) will not include any local variables, so keep that in mind.
This commit is contained in:
parent
c099c170ed
commit
9e7475e684
17
goto-snippet.lua
Normal file
17
goto-snippet.lua
Normal file
@ -0,0 +1,17 @@
|
||||
-- goto
|
||||
goto = function(tag) local f,c,l,o=fs.open(shell.getRunningProgram(), "r"),"","",false while l do if o then c=c..l l=f.readLine() if l then c=c.."\n" else break end else l=f.readLine() if l then o=l:find("--::"..tag.."::")==1 end end end f.close() load(c,nil,nil,_ENV)() end
|
||||
|
||||
-- example
|
||||
goto("test")
|
||||
|
||||
print("Before")
|
||||
|
||||
--::test::
|
||||
|
||||
print("After")
|
||||
|
||||
--[[
|
||||
After
|
||||
Before
|
||||
After
|
||||
--]]
|
Loading…
x
Reference in New Issue
Block a user