Updated Program (markdown)
100
Program.md
100
Program.md
@@ -1,35 +1,27 @@
|
|||||||
This is one of my favorite part<br>
|
With a program object you are able to open programs like shell or worm or any custom program you've made. There is only 1 thing you have to remember: the program needs at least one os.sleep() or coroutine.yield() somewhere.
|
||||||
With the program object you are able to open programs like shell or worm or any custom program you've made. There is only 1 thing you have to do: the program needs at least one os.sleep() or coroutine.yield() somewhere.
|
<br>
|
||||||
<br><br>
|
Here is a list of all available functions for programs: <br>
|
||||||
|
Remember program inherits from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
|
||||||
````lua
|
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|
||||||
local aProgram = mainFrame:addProgram("myFirstProgram"):show()
|
|
||||||
````
|
|
||||||
|
|
||||||
This will create a default program with the size 12 width and 6 height on position 1 1 (relative to its parent frame), the default background is colors.black, the default text color is colors.white and the default zIndex is 5.
|
|
||||||
|
|
||||||
Here are all possible functions available for programs. Remember program inherit from [object](https://github.com/NoryiE/NyoUI/wiki/Object):
|
|
||||||
|
|
||||||
## getStatus
|
## getStatus
|
||||||
returns the current status
|
returns the current status
|
||||||
````lua
|
````lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aProgram = mainFrame:addProgram("myFirstProgram"):show()
|
local aProgram = mainFrame:addProgram("myFirstProgram"):show()
|
||||||
NyoUI.debug(aProgram:getStatus()) -- returns "running", "normal", "suspended" or "dead"
|
basalt.debug(aProgram:getStatus()) -- returns "running", "normal", "suspended" or "dead"
|
||||||
````
|
````
|
||||||
**args:**-<br>
|
**parameters:**-<br>
|
||||||
**returns:** "running" - if its running, "normal" - is active but not running (waiting for a event), "suspended" - is suspended or not started, "dead" - has finished or stopped with an error<br>
|
**returns:** string "running" - if its running, "normal" - is active but not running (waiting for a event), "suspended" - is suspended or not started, "dead" - has finished or stopped with an error<br>
|
||||||
|
|
||||||
## execute
|
## execute
|
||||||
executes the given path (-program)
|
executes the given path (-program)
|
||||||
````lua
|
````lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aProgram = mainFrame:addProgram("myFirstProgram"):show()
|
local aProgram = mainFrame:addProgram("myFirstProgram"):show()
|
||||||
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm, have fuuuuuuuuuuuuuuun
|
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
|
||||||
````
|
````
|
||||||
**args:** filepath - the path to the program you want to execute<br>
|
**parameters:** string filepath - (the path to the program you want to execute)<br>
|
||||||
**returns:** the object<br>
|
**returns:** self<br>
|
||||||
|
|
||||||
## stop
|
## stop
|
||||||
gives a terminate event to the program, which means if you are running a shell, and the shell executes a program by itself you have to call stop 2 times to entirely close the running program
|
gives a terminate event to the program, which means if you are running a shell, and the shell executes a program by itself you have to call stop 2 times to entirely close the running program
|
||||||
@@ -39,5 +31,73 @@ local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/sh
|
|||||||
mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:stop() end):show()
|
mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:stop() end):show()
|
||||||
|
|
||||||
````
|
````
|
||||||
**args:**-<br>
|
**parameters:**-<br>
|
||||||
**returns:** the object<br>
|
**returns:** self<br>
|
||||||
|
|
||||||
|
## pause
|
||||||
|
pauses the program (prevents the program from receiving events)
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
|
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
|
||||||
|
mainFrame:addButton("myFirstButton"):setText("close"):onClick(function() aProgram:pause(true) end):show()
|
||||||
|
|
||||||
|
````
|
||||||
|
**parameters:** boolean pause<br>
|
||||||
|
**returns:** self<br>
|
||||||
|
|
||||||
|
## isPaused
|
||||||
|
returns if the program is currently paused
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
|
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
|
||||||
|
mainFrame:addButton("myFirstButton"):setText("pause"):onClick(function() basalt.debug(aProgram:isPaused()) end):show()
|
||||||
|
|
||||||
|
````
|
||||||
|
**parameters:** -<br>
|
||||||
|
**returns:** boolean isPaused<br>
|
||||||
|
|
||||||
|
## injectEvent
|
||||||
|
injects a event into the program manually
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
|
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
|
||||||
|
mainFrame:addButton("myFirstButton"):setText("inject"):onClick(function() aProgram:injectEvent("char", "w") end):show()
|
||||||
|
|
||||||
|
````
|
||||||
|
**parameters:** string event, any parameter, any parameter, any parameter, any parameter, boolean ignorePause<br>
|
||||||
|
**returns:** self<br>
|
||||||
|
|
||||||
|
## injectEvents
|
||||||
|
injects a event table into the program manually
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
|
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
|
||||||
|
--example will follow
|
||||||
|
|
||||||
|
````
|
||||||
|
**parameters:** string event, any parameter, any parameter, any parameter, any parameter, boolean ignorePause<br>
|
||||||
|
**returns:** self<br>
|
||||||
|
|
||||||
|
## getQueuedEvents
|
||||||
|
returns a table of all currently queued events (while pause is active incomming events will go into a queueEvents table) as soon as the program gets unpaused
|
||||||
|
it will inject these events
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
|
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
|
||||||
|
mainFrame:addButton("myFirstButton"):setText("inject"):onClick(function() basalt.debug(aProgram:getQueuedEvents()) end):show()
|
||||||
|
|
||||||
|
````
|
||||||
|
**parameters:** -<br>
|
||||||
|
**returns:** table queuedEvents<br>
|
||||||
|
|
||||||
|
## updateQueuedEvents
|
||||||
|
here you can manipulate the queuedEvents table with your own events table
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
|
local aProgram = mainFrame:addProgram("myFirstProgram"):execute("rom/programs/shell.lua"):show()
|
||||||
|
--example will follow
|
||||||
|
|
||||||
|
````
|
||||||
|
**parameters:** table queuedEvents<br>
|
||||||
|
**returns:** self<br>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user