• 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!

Using lua instead of xml

This feature, what distribution would you like to see it in?

  • 0.3.6

    Votes: 4 26.7%
  • 0.4

    Votes: 4 26.7%
  • Otx 2/3

    Votes: 0 0.0%
  • Tfs 1.0

    Votes: 0 0.0%
  • Tfs 1.1

    Votes: 0 0.0%
  • Tfs 1.2

    Votes: 2 13.3%
  • Tfs 1.3

    Votes: 5 33.3%

  • Total voters
    15

Union_

Banned User
Joined
Jan 4, 2017
Messages
21
Reaction score
6
I wanted to learn more about the lua C api which is why I have made it my
goal to convert tfs 0.3.6, all of it's xml files to lua.

So far I've convert items, vocations, part of actions but 1st I have to rewrite
baseevents. Currently I have a standard template which runs outside of the tfs
source. This template allows me to easily define the execution of functions I will have to
add or replace when it comes time to update the source.

I am learning as I go, the actions file is actually written 100 times better than the vocations
or items files I've already released. I've written a more universal function in which you
will be able to add ids by range, table or 1 item at a time. I think working with lua as opposed
to working with xml is much easier.

As soon as I get this working 0.3.6 I will update tfs 1.x
 
Tfs 1.0 = Tfs 1.1 = Tfs 1.2 = Tfs 1.3
Otx 2/3 = Tfs 1.0+
So, all these 6 are almost the same.

0.4 is a bugged shit
0.3.6 too old

You should rewrite this poll to something like:
1. TFS 1.0+
2. TFS 0.3.6

From these 2 options, 1.0+ for me best.


Does XML in this case is lighter? Less memory eating in OTS case?
 
Last edited:
You shouldn't even make API changes to older versions, it's not worth it. Just work with the bleeding edge from GitHub.
 
well in tfs 1.1+ paramters got changed in lua functions

I also prefer tfs 1.x
my xml file looks like this:
Code:
    <!-- AUTOMATIC REGISTRATION -->
        <action fromaid="2000"  toaid="2300"    script="AIDItems.lua"/>
    
    <!-- TEMPORARY -->
        <action itemid="2272"                   script="TEMPORARY/dispelItem.lua"           allowfaruse="1"/>
        <action itemid="2282"                   script="TEMPORARY/mendItem.lua"             allowfaruse="1"/>
        <action itemid="7434"                   script="TEMPORARY/throwaxeItem.lua"         allowfaruse="1"/>
        <action itemid="7696"                   script="IDItems.lua"/>                  <!-- old spellScroll -->
    
    <!-- upgrade items -->
        <action itemid="2312"                   script="IDItems.lua"/>                  <!-- sight stone-->
        <action itemid="2264"                   script="IDItems.lua"/>                  <!-- defence stone-->
        <action itemid="2297"                   script="IDItems.lua"/>                  <!-- crit stone-->
Could make all into actionID, but wutever.
But this pretty much shows that having xml file is pointless if you use lua to register items anyway.
and good things about lua is, you can do registration on any file.

Code:
function onUse(player, item, fromPos, itemEx, toPos, isHotkey)
local itemAID = item:getActionId()
local t = AIDItems[itemAID]
    
    if not itemEx or type(itemEx) == "table" then itemEx = checkForItemEx(itemEx, toPos) end
    if t then return executeActionSystem(player, item, t, itemEx, fromPos, toPos) end
end
Example table how registered onUse actions look like:
Code:
AIDItems = {
    [AID.other.wineMachine] = {funcSTR = "wineMachineInForest"},
    [AID.other.beerMachine] = {funcSTR = "beerMachineInForest"},
    [AID.other.lockedDoor] = {text = {msg = "this door is locked"}},
    [AID.other.door] = {funcSTR = "openDoor"},
    [AID.other.cyclopsDebris] = {
        transform = {itemID = 0},
        text = {text = {msg = "*sweep*"}},
    },

Another thing what annoys me are these undeleteable lib folders.
When you loose actions.xml I will probably use your version.
I do not like the way data folder is sorted anyway.

my movements, onMove, onLook use same table structure and registration pattern.

This is how I'd prefer my data folder would look like.
2rdcg46.jpg
 
Reinventing the wheel again?
More like improving it. The current structure of all the distributions are too restrictive, with this new feature developers will be able to fully customize not only the folder structure of tfs but also the execution of both the internal and external functionality of the framework.

When I am done, I will release the different distributions on github and then you can argue amongst yourselves the cons vs. the benefits of this feature. Until then, thank you for your less than optimistic constructive comment.
 
More like improving it. The current structure of all the distributions are too restrictive, with this new feature developers will be able to fully customize not only the folder structure of tfs but also the execution of both the internal and external functionality of the framework.

When I am done, I will release the different distributions on github and then you can argue amongst yourselves the cons vs. the benefits of this feature. Until then, thank you for your less than optimistic constructive comment.
could you give an example of why moving over to lua instead of xml would be useful and less restrictive?
 
could you give an example of why moving over to lua instead of xml would be useful and less restrictive?
i can drop a fully working scripts to your server on a single file without you having to register them to any xml or event functions
 
i can drop a fully working scripts to your server on a single file without you having to register them to any xml or event functions
And why does that have to exclude the XML processing? Just to get rid of backward compatibility?

One thing is: Registering events with Lua
Other is: Replace XML with Lua.

They're different.
 
And why does that have to exclude the XML processing? Just to get rid of backward compatibility?

One thing is: Registering events with Lua
Other is: Replace XML with Lua.

They're different.
why would we need that?
for flash client? (don't use that)
you say they are different.
well yeah they are xml is more annoying and robust. Need to do source edits to make it more dynamic.
with Lua you can improve it on the go.
Sure way easier to crash or cause errors for server, but we can also make server not start if Lua registrations are not written correctly.

But what to iI know, this is just what I think. I'm not programmer.
Care to enlighten us why should we not loose xml?
and what's the problem if its replaced with Lua and c++?
 
One good and strong point about XML is organization and visibility
 
One good and strong point about XML is organization and visibility
This also possible with lua, you can either organize your code into a well formatted table structure or you can write a function which does that for you. Lua is a versatile language whereas xml is not.
 
Back
Top