• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Castro AAC

Well. I have been rewriting some stuff using a more light-weight approach

Using default Go http package with a middleware (negroni) and changing how things are done... for example the config.lua file is now loaded using the lua vm and just getting the global variables the config declares.

The layout is also changing to a non-bootstrap one. It may be uglier to some eyes but for me is some fresh air.

https://github.com/Raggaer/castro
 
Well. I have been rewriting some stuff using a more light-weight approach

Using default Go http package with a middleware (negroni) and changing how things are done... for example the config.lua file is now loaded using the lua vm and just getting the global variables the config declares.

The layout is also changing to a non-bootstrap one. It may be uglier to some eyes but for me is some fresh air.

https://github.com/Raggaer/castro

Great, I will going to try this really soon! Also I will try to give some feedback as issues I think, cause I am learning how this works yet.
 
Well. I have been rewriting some stuff using a more light-weight approach

Using default Go http package with a middleware (negroni) and changing how things are done... for example the config.lua file is now loaded using the lua vm and just getting the global variables the config declares.

The layout is also changing to a non-bootstrap one. It may be uglier to some eyes but for me is some fresh air.

https://github.com/Raggaer/castro
Great work man, i've been following this project from start and im looking forward to use it on my upcoming server. I love everything you have created so far, keep up the good work!
 
The thing about Cloak AAC is that I did the Lua part wrong. I moved some cloak code to a new repo and started over, now it is possible to write the aac code using lua

So yes, its back with a new name and a new repo. <3
FUCK YES
 
I have many plans for this. One that might come soon is the page / widget search scrapping otland forums. I am not sure how I will finally do it but I want to.

I am happy to say that the lua part is almost finished. Complete pages can be done using lua. There might be missing stuff but as I create new pages I will discover what is missing
 
So the main layout is now updated thanks to @Peonso who did this few years ago.

85848e5cf6188d368197a817fe533ae2.png


Code:
local data = {}
data.articles = db:query("SELECT title, text, created_at FROM articles ORDER BY id DESC LIMIT 5", true)

http:render("home.html", data)

All the widgets and the current page are done using lua. The title and sub-title are loaded from the config.lua file same goes for the rates.

638f9564e96b38d2bcdc831128c76039.png


For example. on the house list page. The towns are loaded from the otbm file and the houses from the database/xml file using lua.

Code:
local data = {}

if http.getValues.town == nil then
    data.list = otbm:houseList()
else
    data.list = otbm:houseList(tonumber(http.getValues.town))
end

data.towns = otbm:townList()

http:render("houselist.html", data)

I have been pushing lots of functions to the lua bindings and I can say that they are now capable of writing full dynamic pages

---

I now need to think how I want to handle the custom pages sharing. I was thinking on a self-contained file that server owners can upload to castro leading to a installation of the page/widget. Then scrapping otland to look for released pages so owners can install them via the admin panel.

Some people been asking me for luac or encryption support but it is not in the roadmap currently. However very possible that it ends up beeing done.

There is also a page/widget creator for the admin panel beeing done. With auto-completion and private testing (only admins).

The installation of the AAC is now almost one-click you only need to specify server path on the config file. The rest is auto-generated on the first start-up.

Sorry for the long text. https://github.com/Raggaer/castro
 
Last edited:
Character view completed (missing guild but guilds are not done at the moment). Using of course lua

Code:
local data = {}
local name = url:decode(http.getValues.name)

data.info = db:query("SELECT name, stamina, health, healthmax, mana, manamax, sex, vocation, level, town_id, lastlogin, lastlogout FROM players WHERE name = ?", name, true)

if data.info == nil then
    http:redirect("/")
    return
end

data.info.vocation = xml:vocationByID(data.info.vocation)
data.info.town = otbm:townByID(data.info.town_id)
data.info.lastlogin = time:parseUnix(data.info.lastlogin)
data.info.lastlogout = time:parseUnix(data.info.lastlogout)
data.info.healthpercent = (data.info.health * 100) / data.info.healthmax

if data.info.manamax == 0 then
    data.info.manapercent = 100
else
    data.info.manapercent = (data.info.mana * 100) / data.info.manamax
end


http:render("viewcharacter.html", data)

22eebe9188db25e674a8afcdb44537cb.png
 
The dashboard

1707cbda79ccc0101974ba71d06eae5c.png


Code:
if not session:isLogged() then
    http:redirect("/subtopic/login")
    return
end

local data = {}

data.success = session:getFlash("success")
data.list = db:query("SELECT name, vocation, level FROM players WHERE account_id = ? ORDER BY id DESC", session:loggedAccount().ID)
data.account = session:loggedAccount()
data.account.Creation = time:parseUnix(data.account.Creation)
data.account.Lastday = time:parseUnix(data.account.Lastday)

if data.account.Premdays > 0 then
    data.account.IsPremium = true
end

http:render("dashboard.html", data)

You can also interact with other scripts. For example, imagine you have a global table of foods for your server. You can load them and show them on your website.

Code:
dofile(file)

print(myGlobal)

However calling dofile on each request is a bit expensive so I might do some helpers to get globals from other files and storing them on cache.
 
Thanks guys. Good words are appreciated to sustain larger projects.

@topic

Forgot to mention I added a configurable rate limiter using the Token Bucket algorithm and here is a quick example on how to read a global variable from a lua file. I will try to find out how to read local variables properly

Code:
// pvp
print(reflect:getGlobal(serverPath .. "/config.lua", "worldType"))

You can of course read tables. More will come soon ^^
 
Thanks guys. Good words are appreciated to sustain larger projects.

@topic

Forgot to mention I added a configurable rate limiter using the Token Bucket algorithm and here is a quick example on how to read a global variable from a lua file. I will try to find out how to read local variables properly

Code:
// pvp
print(reflect:getGlobal(serverPath .. "/config.lua", "worldType"))

You can of course read tables. More will come soon ^^
holy shit xD
with this I could display any kind of information about my server on website because almost all unique values are accessible from one huge global variable :D

if it can read global variable which is a table
 
holy shit xD
with this I could display any kind of information about my server on website because almost all unique values are accessible from one huge global variable :D

if it can read global variable which is a table

Yeah exactly! You can easily interact with your scripts

@topic

Highscores are now done.

b77b6e3242e68c06f804220cb0087860.png


The script for this page is a little bit larger so you can view it here
 
Last edited:
So I was a little bit bored and decided to add some json parsing and use that to read the logs.json file.

c687406ee8ac2fbba12f44e2402e544f.png


Code:
if not session:isAdmin() then
    http:redirect("/")
end

local logsfile = io.open("logs/" .. logFile)
local data = {}
local line = logsfile:read("*l")

data.logs = {}

while line do
    table.insert(data.logs, json:unmarshal(line))
    line = logsfile:read("*l")
end

http:render("logs.html", data)

I am still figuring how to read local variables from a lua state... Hope I am done soon.

Almost 200 commits!!
 
Good job mate! Looks promising! Definitely the best out there yet
 
@Amiroslo Thanks <3

Character search done

23b9d896da8290760c5ea4fc11fecc90.png


Lua:
if http.postValues["character-name"] == "" then
    session:setFlash("validationError", "Search query cant be empty")
    http:redirect("/subtopic/community/search")
    return
end

local data = {}

data.list = db:query("SELECT name FROM players WHERE name LIKE ?", "%" .. http.postValues["character-name"] .. "%", true)

if data.list == nil then
    session:setFlash("validationError", "No results found")
    http:redirect("/subtopic/community/search")
    return
end

data.query = http.postValues["character-name"]

http:render("search.html", data)

The last param of the query function is a bool to indicate if cache or not. You can edit the resulting table and since its a pointer the cache will be updated.

Pushed a few more lua functions such as singleQuery. JSON and XML marshal and umarshal. The xml unmarshal is still WIP. But this will allow users to work with any TFS related XML file and do their shit.

I am also looking into making closed source pages too.

=)
 
Back
Top