• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

[Tool] Lua scripts Node Builder

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,646
Solutions
54
Reaction score
1,776
Location
Poland
GitHub
Oen44
Another day, another project 😅.

I'm not here to sell you this nor convince that this is something you should praise, just wanted to showcase what is on the way.
Node based editors are already a thing for years, the most famous being Blueprints from Unreal Engine 4 and Unity Bolt (you can create games without writing single line of code).
Lua is not as advanced as C++ or C# so it's not going to be that powerful either but that doesn't mean it won't be useful.

Will this be open-source? Yeah, of course. I just need time to make every functionality working so then I can rewrite entire code (well 80%) and make it open-source friendly.

This video is a showcase of building this simple NPC script.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local requiredLevel = 150 -- declared in builder as "Required Level" number
local storageKey = 1234 -- declared in builder as "Storage Key" number
local bossName = "Demon" -- decalred in builder as "Boss Name" string

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function onMessageDefault(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid) -- get Player from creature id (cid)
    if msg == "boss" then -- check if message is equal to "boss"
        if player:getLevel() >= requiredLevel then -- check if player level is higher or equal than Required Level
            if player:getStorageValue(storageKey) == -1 then -- check if player hasn't spawned boss before
                Game.createMonster(bossName, Position(1000, 1000, 7)) -- spawn boss
                player:setStorageValue(storageKey, 1) -- set storage value to 1
            end
        end
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onMessageDefault)
npcHandler:addModule(FocusModule:new())

This being my 1050th post and achieving reaction score 1000, that's 95.2% of my posts, incredible.
 
Last edited:

GhostX

Mapping Board Moderator
Staff member
Board Moderator
Joined
Nov 2, 2011
Messages
6,044
Reaction score
1,781
Location
UK
Twitch
ghostxpr0
Looks awesome! Interested to see how this pans out!
 
OP
OP
oen432

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,646
Solutions
54
Reaction score
1,776
Location
Poland
GitHub
Oen44
I know it's alpha stage and a lot to work on but if anyone has any feedback or just questions, please post here.
 

nugo

Australia OT Mapper
Joined
Apr 1, 2009
Messages
382
Solutions
4
Reaction score
185
This is sick, if you need a tester that isn't the best coder let me know I'll help out.
 

Nemphis

Veteran OT User
Joined
Jun 22, 2009
Messages
627
Reaction score
365
Location
Sweden
Our community need anything to make it easier for new developers! This tool could be very good for this cause. I never used a node system so I dont understand how to think while using it, imo coding is easier to get into and more fun(for me). But i see why this is useful! Keep it going!
 
OP
OP
oen432

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,646
Solutions
54
Reaction score
1,776
Location
Poland
GitHub
Oen44
Our community need anything to make it easier for new developers! This tool could be very good for this cause. I never used a node system so I dont understand how to think while using it, imo coding is easier to get into and more fun(for me). But i see why this is useful! Keep it going!
It might seem like coding is easier but it's not, however it's faster and better if you want something more complicated.
There is even Scratch (used in schools) that uses blocks instead of code to create something and introduce kids to programming/coding.

Now imagine someone creates a simple script using this builder, generates the code and then by comparison they can learn about Lua a lot. Some brains work better with visual representation, which is why node based building is so good.
 

Dip Set

Veteran OT User
Joined
Dec 27, 2007
Messages
376
Solutions
2
Reaction score
329
This is something that could cut the learning curve for new users (and experienced users) down significantly. Super pumped.
 

The Frenesy

Member
Joined
Sep 3, 2020
Messages
32
Solutions
1
Reaction score
7
This tool can be very useful for lay people who do not know how to program or have difficulty.

Scripting with the help of this program will be very good because we will understand all the logic behind the codes.

It would be interesting if it supports multi projects, like TFS 0.4, 1.3 and 1.4 (if it arrives).
 

Dip Set

Veteran OT User
Joined
Dec 27, 2007
Messages
376
Solutions
2
Reaction score
329
In theory, a user should be able to add custom variables and could use the same base node builder with any tfs though, right?
 
OP
OP
oen432

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,646
Solutions
54
Reaction score
1,776
Location
Poland
GitHub
Oen44
In theory, a user should be able to add custom variables and could use the same base node builder with any tfs though, right?
Nope. TFS 0.4 and 1.3 syntax is so different, it would not work. Both would need separated generator. But as I said, I don't care about these versions, even if it means that there will be less users :) My scripts already got few people to upgrade from old TFS to new one, I hope this will get even more to do the same. People are posting threads about "why TFS development is slow", well, that's one of the reasons.
 

risy

Member
Joined
Aug 25, 2007
Messages
51
Solutions
1
Reaction score
6
Location
Spain
i need that now! its awesome oen432! you can give me a beta version for create npcs for my new rpg server?? i need make a lot of npcs...
 
OP
OP
oen432

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,646
Solutions
54
Reaction score
1,776
Location
Poland
GitHub
Oen44
F again.

how many time do you need for made a stable release for public test it?
No sure, I'm not able to work on this every day. It can take from 1 week to 1 month. As soon as it's going to be ready for public release (even in alpha/beta), I'll post here.
 

risy

Member
Joined
Aug 25, 2007
Messages
51
Solutions
1
Reaction score
6
Location
Spain
Thank you very much in advance for your work.

I have been in discord for a long time on several servers in which you participate, I will be attentive to any progress on the subject and the day you publish your first beta, I hope I can contribute to improve it by finding possible bugs that there were in the code.

Thanks from the entire opentibia community, without people like you it would not be possible to obtain these advances in a world as fun as opentibia.
 
Top