KristWrap is similar to tmpim's k.lua, but without the need to change your coding style to support jua.
This may contains bugs! I haven't yet had time to test it fully, but it should work overall.
Like stated above, this is similar to k.lua, but you don't need to change your coding style. Initially, this project will purely be for transactions and etc. It may get larger later (or I may forget about it, who knows?), but for now I'm building it for Simplify Shop V2.
-
wget https://raw.githubusercontent.com/Fatboychummy-CC/KristWrap/master/KristWrap.lua
orwget https://raw.githubusercontent.com/Fatboychummy-CC/KristWrap/master/minified.lua
-
Download rxi's json library, from https://github.com/rxi/json.lua
-
Download Anavrin's Sha256 library, from https://pastebin.com/6UV4qfNF
-
In your program, set the endpoint
- If you don't know what this means, or you just wish to use "the normal krist", use
KristWrap.useDefaultEndPoint()
.
- In parallel, you want to run
KristWrap.run
with the following arguments:
- Table of strings
- Each string is an event you want to subscribe to, like
"transactions"
, or"blocks"
- Each string is an event you want to subscribe to, like
- (optional): Private key, in either raw or KristWalletFormat.
- Write your code, I recommend using parallel. Example follows:
local KristWrap = require "KristWrap"
local privatekey = "something"
parallel.waitForAny(
function()
KristWrap.useDefaultEndPoint()
KristWrap.run({"transactions"}, privatekey)
end,
function()
KristWrap.Initialized:Wait() -- wait for KristWrap.run to connect properly.
while true do
local to, from, value, metadata = KristWrap.Transaction:Wait()
-- Do stuff with the transaction here.
end
end
)
For all some events, you can use either KristWrap.Event:Wait([number timeout])
or KristWrap.Event:Connect(<function callback>)
. Use Wait
for simplicity, or Connect
if you wish for a more Jua-like usage (Or more roblox-like usage, if you're used to that).
Note: Event:Connect
requires KristWrap.run
to be ran in parallel.