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

TFS 0.4 3777 to TFS 1.3 [8.60]

Addams

OTMadness.com OTSes Services
Staff member
Board Moderator
Joined
Sep 29, 2009
Messages
2,920
Solutions
342
Reaction score
1,688
Location
Egypt
I am changing full custom real server datapack from TFS 0.4 3777 to TFS 1.3, I do that one script by one script since days so I was wondering if there are any easier/faster ways/ideas to do it because doing it one by one will take up to months.
or if there is already released real server datapack based on 1.3 would be great, so I just add my map/custom edits, I know it is not a request thread but I can create one if needed.
I have found few BR datapacks based on 1.2 or OTX (which is based on 1.2) but they have more errors to fix than changing scripts one by one.
I really appreciate any help because I am tired of changing scripts.
 
Solution
There are no increaseItemId and decreaseItemId in 1.X. Having
XML:
    <!-- Increase/Decrease ItemId -->
    <action itemid="1873" event="function" value="increaseItemId"/>
    <action itemid="1874" event="function" value="decreaseItemId"/>
    <action itemid="1875" event="function" value="increaseItemId"/>
    <action itemid="1876" event="function" value="decreaseItemId"/>
    <action itemid="1945" event="function" value="increaseItemId"/>
    <action itemid="1946" event="function" value="decreaseItemId"/>
in 0.4, you will have
XML:
    <!-- Transform and decay -->
    <action fromid="1873" toid="1876" script="other/decayto.lua"/>
    <action fromid="1945" toid="1946" script="other/decayto.lua"/>
in 1.3 -...
You don't have to change anything. You have to simply move your datapack to TFS 1.3 directory, then make corrections in XML files (like <action actionid="123" event="script" value="test.lua"/> in 0.4 vs <action actionid="123" script="test.lua"/> in 1.3, <event type="death" name="TestDeath" event="script" value="test.lua"/> in 0.4 vs <event type="death" name="TestDeath" script="test.lua"/> in 1.3, etc) and check console errors. Just analyze what's inside otland/forgottenserver (https://github.com/otland/forgottenserver/tree/master/data) and you are done :)
 
You don't have to change anything. You have to simply move your datapack to TFS 1.3 directory, then make corrections in XML files (like <action actionid="123" event="script" value="test.lua"/> in 0.4 vs <action actionid="123" script="test.lua"/> in 1.3, <event type="death" name="TestDeath" event="script" value="test.lua"/> in 0.4 vs <event type="death" name="TestDeath" script="test.lua"/> in 1.3, etc) and check console errors. Just analyze what's inside otland/forgottenserver (https://github.com/otland/forgottenserver/tree/master/data) and you are done :)
That helped a little but still I have to edit each script because most of functions are changed from 0.4 to 1.3. Anyone has other ideas? or can provide real map 8.6 based on 1.x?
 
There are no shortcuts other than compat.lua, compat provides a list of old->new functions which lets people retain backwards compatibility with scripts so there's no need to manually update them.
For example, when a script calls getCreaturePosition(cid) it's actually defined as:
Lua:
function getCreaturePosition(cid)
    local player = Player(cid)
    if player then
        return player:getPosition()
    end
end
I'd say about 90-95% of old functions are rewritten this way, so there's no reason you'd need to manually rewrite your scripts. If they are broken it's because the script is broken, not because compat is missing a function (if it is, it's not even hard to implement a compat function, look at my example above)
The biggest change is the XML formatting like @kor mentioned.
 
There are no shortcuts other than compat.lua, compat provides a list of old->new functions which lets people retain backwards compatibility with scripts so there's no need to manually update them.
For example, when a script calls getCreaturePosition(cid) it's actually defined as:
Lua:
function getCreaturePosition(cid)
    local player = Player(cid)
    if player then
        return player:getPosition()
    end
end
I'd say about 90-95% of old functions are rewritten this way, so there's no reason you'd need to manually rewrite your scripts. If they are broken it's because the script is broken, not because compat is missing a function (if it is, it's not even hard to implement a compat function, look at my example above)
The biggest change is the XML formatting like @kor mentioned.
So 0.4 scripts should work well with TFS 1.3? No need to change them? just editing the XML? but how about the function stuffs like
XML:
    <action itemid="2067" event="function" value="decreaseItemId"/>
    <action itemid="2068" event="function" value="increaseItemId"/>
Running server with 0.4 causes 0 console errors, but when I run same server with 1.3 after changing XML, I get 100's of errors specially NPCs and Monsters.
 
Last edited:
There are no increaseItemId and decreaseItemId in 1.X. Having
XML:
    <!-- Increase/Decrease ItemId -->
    <action itemid="1873" event="function" value="increaseItemId"/>
    <action itemid="1874" event="function" value="decreaseItemId"/>
    <action itemid="1875" event="function" value="increaseItemId"/>
    <action itemid="1876" event="function" value="decreaseItemId"/>
    <action itemid="1945" event="function" value="increaseItemId"/>
    <action itemid="1946" event="function" value="decreaseItemId"/>
in 0.4, you will have
XML:
    <!-- Transform and decay -->
    <action fromid="1873" toid="1876" script="other/decayto.lua"/>
    <action fromid="1945" toid="1946" script="other/decayto.lua"/>
in 1.3 - otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/data/actions/actions.xml#L27)
You can all discover it by your own, just analyze github repository :)

Edit: I've found when it was removed - Move increase/decrease item id functions to Lua · otland/forgottenserver@7acfab7 (https://github.com/otland/forgottenserver/commit/7acfab77d19720585ec4329e11e05f058a8aa34b)
 
Last edited:
Solution
decayto.lua has a reference table where the key is "decay from" and the value is "decay to", this list should also be updated as you change actions.xml:
Lua:
-- keep in sync with actions.xml
local decayItems = {
    [1479] = 1480, [1480] = 1479, [1634] = 1635, [1635] = 1634, [1636] = 1637,
    [1637] = 1636, [1638] = 1639, [1639] = 1638, [1640] = 1641, [1641] = 1640,
    [1786] = 1787, [1787] = 1786, [1788] = 1789, [1789] = 1788, [1790] = 1791,
    [1791] = 1790, [1792] = 1793, [1793] = 1792, [1873] = 1874, [1874] = 1873,
    [1875] = 1876, [1876] = 1875, [1945] = 1946, [1946] = 1945, [2037] = 2038,
    [2038] = 2037, [2039] = 2040, [2040] = 2039, [2041] = 2042, [2042] = 2041,
    [2044] = 2045, [2045] = 2044, [2047] = 2048, [2048] = 2047, [2050] = 2051,
    [2051] = 2050, [2052] = 2053, [2053] = 2052, [2054] = 2055, [2055] = 2054,
    [2058] = 2059, [2059] = 2058, [2060] = 2061, [2061] = 2060, [2064] = 2065,
    [2065] = 2064, [2066] = 2067, [2067] = 2066, [2068] = 2069, [2069] = 2068,
    [2096] = 2097, [2097] = 2096, [2162] = 2163, [2163] = 2162, [2578] = 2579,
    [3947] = 3948, [3948] = 3947, [5812] = 5813, [5813] = 5812, [6489] = 6490,
    [6490] = 6489, [7058] = 7059, [7059] = 7058, [8684] = 8685, [8685] = 8684,
    [8686] = 8687, [8687] = 8686, [8688] = 8689, [8689] = 8688, [8690] = 8691,
    [8691] = 8690, [9575] = 9576, [9576] = 9575, [9577] = 9578, [9578] = 9577,
    [9579] = 9580, [9580] = 9579, [9581] = 9582, [9582] = 9581, [9747] = 9748,
    [9748] = 9747, [9749] = 9750, [9750] = 9749, [19691] = 19692,
    [19692] = 19691,
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    item:transform(decayItems[item.itemid])
    item:decay()
    return true
end

And yeah, combat.lua helps migrating scripts as it does support most of the old function names. But XML structure and event params has to be accomodated for. Etc I don't think TFS 1.3 has a straight out "onKill" creature event, but you could simulate "onKill" using "onDeath" by just using the killer param instead of the player param in the onDeath event.

If there is a particular script your struggling to get converted, you can keep creating threads here in support section and we will help you out.
 
Last edited:
decayto.lua has a reference table where the key is "decay from" and the value is "decay to", this list should also be updated as you change actions.xml:
Lua:
-- keep in sync with actions.xml
local decayItems = {
    [1479] = 1480, [1480] = 1479, [1634] = 1635, [1635] = 1634, [1636] = 1637,
    [1637] = 1636, [1638] = 1639, [1639] = 1638, [1640] = 1641, [1641] = 1640,
    [1786] = 1787, [1787] = 1786, [1788] = 1789, [1789] = 1788, [1790] = 1791,
    [1791] = 1790, [1792] = 1793, [1793] = 1792, [1873] = 1874, [1874] = 1873,
    [1875] = 1876, [1876] = 1875, [1945] = 1946, [1946] = 1945, [2037] = 2038,
    [2038] = 2037, [2039] = 2040, [2040] = 2039, [2041] = 2042, [2042] = 2041,
    [2044] = 2045, [2045] = 2044, [2047] = 2048, [2048] = 2047, [2050] = 2051,
    [2051] = 2050, [2052] = 2053, [2053] = 2052, [2054] = 2055, [2055] = 2054,
    [2058] = 2059, [2059] = 2058, [2060] = 2061, [2061] = 2060, [2064] = 2065,
    [2065] = 2064, [2066] = 2067, [2067] = 2066, [2068] = 2069, [2069] = 2068,
    [2096] = 2097, [2097] = 2096, [2162] = 2163, [2163] = 2162, [2578] = 2579,
    [3947] = 3948, [3948] = 3947, [5812] = 5813, [5813] = 5812, [6489] = 6490,
    [6490] = 6489, [7058] = 7059, [7059] = 7058, [8684] = 8685, [8685] = 8684,
    [8686] = 8687, [8687] = 8686, [8688] = 8689, [8689] = 8688, [8690] = 8691,
    [8691] = 8690, [9575] = 9576, [9576] = 9575, [9577] = 9578, [9578] = 9577,
    [9579] = 9580, [9580] = 9579, [9581] = 9582, [9582] = 9581, [9747] = 9748,
    [9748] = 9747, [9749] = 9750, [9750] = 9749, [19691] = 19692,
    [19692] = 19691,
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    item:transform(decayItems[item.itemid])
    item:decay()
    return true
end

And yeah, combat.lua helps migrating scripts as it does support most of the old function names. But XML structure and event params has to be accomodated for. Etc I don't think TFS 1.3 has a straight out "onKill" creature event, but you could simulate "onKill" using "onDeath" by just using the killer param instead of the player param in the onDeath event.

If there is a particular script your struggling to get converted, you can keep creating threads here in support section and we will help you out.
Thanks, I will try my best to fix what I can.
but one more last question, will keeping the script with its old functions without changing it to 1.3 functions reduce the stability of server and script or no difference? Because I am moving to 1.3 to increase the stability of server and scripting system not the opposite.
 
Keeping the old functions just wraps it into 2 function calls which is a microscopic amount of time, you don't need to worry about performance.
 
I didn't understand why he wants to upgrade from 0.4 to 1.3, on an server 8.6, doing that he will not overwrite the datapack? Meaning that he will have monsters 10.x and a lot of other stuf?
 
No that is downgraded TFS 1.3 to 8.6 client so all other stuff from higher clients are removed but it still has same stability/performance of the main TFS 1.3 so its best for 8.6.
 
Back
Top