[WARNING] This is just a preview of what the documentation will look like, unfinished and information may be wrong.

Documentation

Official KRNL Documentation


This documentation covers every aspect of KRNL. It will work as a public knowledge base about, and objects related to KRNL. Anything you may find "undocumented" is either not available, or does not exist.

This will be updated as more is added to KRNL as a whole.

Execution Environment


A reference to every function contained within the execution environment.

Debug Library

debug.getconstants

<table> debug.getconstants(<function, int> func)

Returns the constants in function or level func


EXAMPLE

local idx = 1
local isReady = false
function f()
      if idx > 0 then
         print(isReady and 'Can initiate an ability' or 'Cannot initiate an ability')
      elseif idx == 0 then
         print('bruh moment')
      end
end

table.foreach(debug.getconstants(f), print)

-- 1 0
-- 2 print
-- 3 Can initiate an ability
-- 4 Cannot initiate an ability
-- 5 bruh moment

debug.getconstant

<variant> debug.getconstant(<function, int> func, <int> idx)

Returns the constant in func at index idx


EXAMPLE

local idx = 1
local isReady = false
function f()
   if idx > 0 then
      print(isReady and 'Can initiate an ability' or 'Cannot initiate an ability')
   elseif idx == 0 then
      print('bruh moment')
   end
end
                                                
print(debug.getconstant(f, 2)) -- print

debug.setconstant

<void> debug.setconstant(<function, int> func, <int> idx, <variant> value)  

Sets the constant in function or level func at index idx to value


EXAMPLE

function f()
   var = "Ayo"
   print(var, "Hey")
end

debug.setconstant(f, 2, "Hello")
f()

-- Hello Hey

debug.getprotos

<table> debug.getprotos(<function> func)

Returns all inner functions of func


EXAMPLE

function f()
   function f1()
         print('hello from function f1')
   end

   function f2()
         print('hello from function f2')
   end
end

for k,v in next, debug.getprotos(f) do
   v()
end

-- hello from function f1
-- hello from function f2

debug.getproto

<variant> debug.getproto(<function> func, <int> idx [, <bool> inst])

Returns the inner function of func at index idx. If inst is set to true, returns all instances of the inner function as a table.


EXAMPLE

function f()
   function f1()
         print('hello from function f1')
   end
   function f2()
         print('hello from function f2')
   end
end

debug.getproto(f, 2)()

-- hello from function f2

debug.getstack

<table> debug.getstack(<int> lvl)

WIP


EXAMPLE

WIP

debug.setstack

<function, table> debug.getproto(<function> func, <int> idx [, <bool> inst])

WIP


EXAMPLE

WIP


Copyright © Krnl 2020