• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Script compatibility?

Simbaclaws

ˁ(⦿ᴥ⦿)ˀ
Joined
Mar 15, 2016
Messages
41
Reaction score
1
Location
Netherlands
I found the following thread in the resources section of the forum:

https://otland.net/threads/all-lua-scripts.63853/

I found out there is a compat.lua in data/lib/compat/
Does this mean that older scripts that are meant for versions like 0.3.x also work for the current 1.2 tfs build?
I would like to implement some scripts into my server and I doubt whether they will work with my version.
Would I have to rewrite them because they only support older versions?
Also some, or even most of these scripts in this thread don't show a version that it's compatible with.

In other words, are scripts downward compatible?
 
Hello Simba,

I believe most of that scripts work with 0.3.x tfs versions. With that said, maybe you will find some trouble trying to run them with tfs 1.2.
The reason that happens is because some of the 0.3.x lua functions are not in compat.lua from tfs 1.2.
In most of the cases you can simple check what function gives an error and use the equivalent from tfs 1.2. In the cases that that don't work you will have to come up with something else.
You can also ask for help here in the forum for porting a specific feature to tfs 1.2.
 
Is there perhaps some sort of list that displays which functions have been replaced by which others? What the equivalents are for certain functions?
Also I'm very new to tibia scripting. Not so much to lua but still, I think I should just go on and test some things out to see if they work.

Also, I don't suppose there is something like a debugger for lua scripts in tibia is there?
 
The compat.lua contains functions of TFS 0.2, alot of functions of TFS 0.2 and 0.3/0.4 are the same, so some 0.3/0.4 scripts will also work.
There are quite some differences besides functions, such as creaturescripts types and userdata parameters of main functions instead of cid, which also could give some problems.

If you want to use the older version scripts without rewriting them, you can look which functions give nil value errors and look in compat.lua for a similar function or in luascript.cpp.
 
The compat.lua contains functions of TFS 0.2, alot of functions of TFS 0.2 and 0.3/0.4 are the same, so some 0.3/0.4 scripts will also work.
There are quite some differences besides functions, such as creaturescripts types and userdata parameters of main functions instead of cid, which also could give some problems.

If you want to use the older version scripts without rewriting them, you can look which functions give nil value errors and look in compat.lua for a similar function or in luascript.cpp.
Thanks, I suppose this was what I was looking for :)
One question though, wouldn't it be possible to add more functions from 0.x versions to compat.lua and basically enable backward compatibility for a lot of scripts?
It would be quite sweet if we could have backward compatibility for ALL scripts :)
Then I won't have to worry about rewriting them, even though this could be considered little effort.

As a programmer I'd love to code as less as possible ^.^ (I'm kinda lazy, or just really bussy with other things)
 
One question though, wouldn't it be possible to add more functions from 0.x versions to compat.lua and basically enable backward compatibility for a lot of scripts?
Yes, you can always add more functions, some functions will be just a different name, so you can use a 0.3/0.4 compat.lua and switch the function names.
For example TFS 0.3.6 100-compat.lua
Code:
getPlayerStorageValue = getCreatureStorage
Then you can add it like this at the bottom of the compat.lua of your server.
Code:
getCreatureStorage = getPlayerStorageValue
The function getPlayerStorageValue is a TFS 0.2 function which is already added to compat.lua.
Several TFS 0.3/0.4 functions don't exist in TFS 0.2, so then you can look in luascript.cpp for an alternative.
 
Thanks, I suppose this was what I was looking for :)
One question though, wouldn't it be possible to add more functions from 0.x versions to compat.lua and basically enable backward compatibility for a lot of scripts?
It would be quite sweet if we could have backward compatibility for ALL scripts :)
Then I won't have to worry about rewriting them, even though this could be considered little effort.

As a programmer I'd love to code as less as possible ^.^ (I'm kinda lazy, or just really bussy with other things)
Just create a library file and reference that, this way when you switch distros you only need to update the one file to the new functions if any, this is what the compat file is for but you can create your own library and reference those functions.
 
Back
Top