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

RevScripts convert to revscripts pls

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
Hello.

this script is from @Xikini and i cant convert this to revscript to use on tfs1.3, and i dont understand this yet. i can change some scripts and adapt for my use, but this conversion still confusion to me, if someone can convert and comment the diferences for this script as exemple.


Lua:
--[[

.------..------..------..------..------..------.
|X.--. ||I.--. ||K.--. ||I.--. ||N.--. ||I.--. |
| :/\: || (\/) || :/\: || (\/) || :(): || (\/) |
| (__) || :\/: || :\/: || :\/: || ()() || :\/: |
| '--'X|| '--'I|| '--'K|| '--'I|| '--'N|| '--'I|
`------'`------'`------'`------'`------'`------'

]]--

local config = {
    [45000] = {
        object = {
            position = Position(250, 242, 7),
            itemId = 1514,
            removeTimer = 4 -- seconds
        },
        tilePositions = {
            Position(248, 245, 7),
            Position(250, 245, 7),
            Position(252, 245, 7)
        }
    },
    [45001] = {
        object = {
            position = Position(1000, 1000, 7),
            itemId = 1111,
            removeTimer = 4
        },
        tilePositions = {
            Position(1000, 1000, 7),
            Position(1000, 1000, 7),
            Position(1000, 1000, 7)
        }
    }
}

local function removeAndReAddObject(position, objectId, timer)
    position:sendMagicEffect(CONST_ME_POFF)
    if timer > 0 then
        Tile(position):getItemById(objectId):remove()
        addEvent(removeAndReAddObject, timer, position, objectId, 0)
    else
        Game.createItem(objectId, 1, position)
    end
end

local stepTilesRemoveObject = MoveEvent()
stepTilesRemoveObject:type("stepin")

function stepTilesRemoveObject.onStepIn(player, item, position, fromPosition)

    -- confirm is player
    if not player:isPlayer() then
        return true
    end
  
    -- confirm index
    local actionId = item:getActionId()
    local index = config[actionId]
    if not index then
        print("LUA error: ActionId not in table." .. actionId)
        return true
    end
  
    -- confirm that object exists
    if Tile(index.object.position):getItemCountById(index.object.itemId) == 0 then
        position:sendMagicEffect(CONST_ME_POFF)
        return true
    end
  
    -- confirm if all tiles are occupied
    local positionAmount = #index.tilePositions
    local playerCount = 0
    for i = 1, positionAmount do
        local creature = Tile(index.tilePositions[i]):getTopCreature()
        if not creature or not creature:isPlayer() then
            index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_RED)
        else
            index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_GREEN)
            playerCount = playerCount + 1
        end           
    end
  
    -- remove and reAdd stone
    if playerCount == positionAmount then
        removeAndReAddObject(index.object.position, index.object.itemId, index.object.removeTimer * 1000)
    end   
    return true
end

for actionid, _ in pairs(config) do
    stepTilesRemoveObject:aid(actionid) -- adds all actionid's from config
end
stepTilesRemoveObject:register()


Something simple now, how restricting the use of this item only to equipment/weapons/wands,etc ... on this way it is can be used on the floor or in containers, etc ...

Code:
local epicgem = Action()
local itemId = 40810
function epicgem.onUse(cid, item, frompos, item2)
    rollRarity(item2, 'epic')
    item:remove(1)
    return true
end

epicgem:id(itemId)
epicgem:register()

thanks.

FLP
 
Solution
Put on your sunglasses, as you will see a horrible code. In Brazil we call it a gambiarra.

I should work with object-oriented programming, even without knowing how to program I can do aberrations like this:


Lua:
-- FLP#2311


local tilesPositions = {
    {x = 33049, y = 31638, z = 5},
    {x = 33049, y = 31628, z = 5},
    {x = 33071, y = 31613, z = 5}
}

local wallsPositions = {
    {x = 33074, y = 31612, z = 5},
    {x = 33074, y = 31613, z = 5},
    {x = 33074, y = 31614, z = 5},
    {x = 33074, y = 31615, z = 5},
    {x = 33074, y = 31616, z = 5}
}

local function removeAndReAddObject(position, objectId, timer)
        for i = 1, #wallsPositions do
        wall = Tile(wallsPositions[i]):getItemById(9533)
        -- Check there is...
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
It's on revscript already
Strange. it does not work in TFS 1.3 and in the topic a guy said he needed to be converted.

FLP
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
Hello.

this script is from @Xikini and i cant convert this to revscript to use on tfs1.3, and i dont understand this yet. i can change some scripts and adapt for my use, but this conversion still confusion to me, if someone can convert and comment the diferences for this script as exemple.


Lua:
--[[

.------..------..------..------..------..------.
|X.--. ||I.--. ||K.--. ||I.--. ||N.--. ||I.--. |
| :/\: || (\/) || :/\: || (\/) || :(): || (\/) |
| (__) || :\/: || :\/: || :\/: || ()() || :\/: |
| '--'X|| '--'I|| '--'K|| '--'I|| '--'N|| '--'I|
`------'`------'`------'`------'`------'`------'

]]--

local config = {
    [45000] = {
        object = {
            position = Position(250, 242, 7),
            itemId = 1514,
            removeTimer = 4 -- seconds
        },
        tilePositions = {
            Position(248, 245, 7),
            Position(250, 245, 7),
            Position(252, 245, 7)
        }
    },
    [45001] = {
        object = {
            position = Position(1000, 1000, 7),
            itemId = 1111,
            removeTimer = 4
        },
        tilePositions = {
            Position(1000, 1000, 7),
            Position(1000, 1000, 7),
            Position(1000, 1000, 7)
        }
    }
}

local function removeAndReAddObject(position, objectId, timer)
    position:sendMagicEffect(CONST_ME_POFF)
    if timer > 0 then
        Tile(position):getItemById(objectId):remove()
        addEvent(removeAndReAddObject, timer, position, objectId, 0)
    else
        Game.createItem(objectId, 1, position)
    end
end

local stepTilesRemoveObject = MoveEvent()
stepTilesRemoveObject:type("stepin")

function stepTilesRemoveObject.onStepIn(player, item, position, fromPosition)

    -- confirm is player
    if not player:isPlayer() then
        return true
    end
 
    -- confirm index
    local actionId = item:getActionId()
    local index = config[actionId]
    if not index then
        print("LUA error: ActionId not in table." .. actionId)
        return true
    end
 
    -- confirm that object exists
    if Tile(index.object.position):getItemCountById(index.object.itemId) == 0 then
        position:sendMagicEffect(CONST_ME_POFF)
        return true
    end
 
    -- confirm if all tiles are occupied
    local positionAmount = #index.tilePositions
    local playerCount = 0
    for i = 1, positionAmount do
        local creature = Tile(index.tilePositions[i]):getTopCreature()
        if not creature or not creature:isPlayer() then
            index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_RED)
        else
            index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_GREEN)
            playerCount = playerCount + 1
        end          
    end
 
    -- remove and reAdd stone
    if playerCount == positionAmount then
        removeAndReAddObject(index.object.position, index.object.itemId, index.object.removeTimer * 1000)
    end  
    return true
end

for actionid, _ in pairs(config) do
    stepTilesRemoveObject:aid(actionid) -- adds all actionid's from config
end
stepTilesRemoveObject:register()


Something simple now, how restricting the use of this item only to equipment/weapons/wands,etc ... on this way it is can be used on the floor or in containers, etc ...

Code:
local epicgem = Action()
local itemId = 40810
function epicgem.onUse(cid, item, frompos, item2)
    rollRarity(item2, 'epic')
    item:remove(1)
    return true
end

epicgem:id(itemId)
epicgem:register()

thanks.

FLP
Yeah as other guy stated, this is already made for TFS 1.3 using revscripts.

Should be able to just drag and drop it into your scripts folder and it'll work right away.

The other guy was using tfs 1.2 or 1.3 before revscripts was added, so needed to convert it to non-revscript to use it in his project.

---
Can you describe what isn't working for you?

Are you getting errors in console?
 
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
Can you describe what isn't working for you?

Are you getting errors in console?
[2021-09-05 21:10:56.242] [warning] [MoveEvents::addEvent] - Duplicate move event found: 45000
[2021-09-05 21:10:56.243] [warning] [MoveEvents::addEvent] - Duplicate move event found: 45001

and if i remove

for actionid, _ in pairs(config) do
stepTilesRemoveObject:aid(45000, 45001) -- adds all actionid's from config
end

i dont get a error but also dont work.

FLP
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
[2021-09-05 21:10:56.242] [warning] [MoveEvents::addEvent] - Duplicate move event found: 45000
[2021-09-05 21:10:56.243] [warning] [MoveEvents::addEvent] - Duplicate move event found: 45001

and if i remove

for actionid, _ in pairs(config) do
stepTilesRemoveObject:aid(45000, 45001) -- adds all actionid's from config
end

i dont get a error but also dont work.

FLP
That means some other script is using actionid's 45000 and 45001

Change those numbers to something you haven't used before. like 45010 and 45011, as an example.
 
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
That means some other script is using actionid's 45000 and 45001

Change those numbers to something you haven't used before. like 45010 and 45011, as an example.
have any maximum range? I’ve already tested a huge list of numbers and it always says it’s duplicated.


"[2021-09-05 21:22:50.125] [warning] [MoveEvents::addEvent] - Duplicate move event found: 90100
[2021-09-05 21:22:50.126] [warning] [MoveEvents::addEvent] - Duplicate move event found: 45101"



FLP
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
have any maximum range? I’ve already tested a huge list of numbers and it always says it’s duplicated.


"[2021-09-05 21:22:50.125] [warning] [MoveEvents::addEvent] - Duplicate move event found: 90100
[2021-09-05 21:22:50.126] [warning] [MoveEvents::addEvent] - Duplicate move event found: 45101"



FLP
If that is happening, then some other script is erroneously registering a massive amount of id's.
(I just tested the script on my 1.3 test server, and it's working correctly.)

Have you installed some other script recently?
Lua:
--[[

.------..------..------..------..------..------.
|X.--. ||I.--. ||K.--. ||I.--. ||N.--. ||I.--. |
| :/\: || (\/) || :/\: || (\/) || :(): || (\/) |
| (__) || :\/: || :\/: || :\/: || ()() || :\/: |
| '--'X|| '--'I|| '--'K|| '--'I|| '--'N|| '--'I|
`------'`------'`------'`------'`------'`------'

]]--

local config = {
    [45010] = {
        object = {
            position = Position(250, 242, 7),
            itemId = 1514,
            removeTimer = 4 -- seconds
        },
        tilePositions = {
            Position(248, 245, 7),
            Position(250, 245, 7),
            Position(252, 245, 7)
        }
    },
    [45011] = {
        object = {
            position = Position(1000, 1000, 7),
            itemId = 1111,
            removeTimer = 4
        },
        tilePositions = {
            Position(1000, 1000, 7),
            Position(1000, 1000, 7),
            Position(1000, 1000, 7)
        }
    }
}

local function removeAndReAddObject(position, objectId, timer)
    position:sendMagicEffect(CONST_ME_POFF)
    if timer > 0 then
        Tile(position):getItemById(objectId):remove()
        addEvent(removeAndReAddObject, timer, position, objectId, 0)
    else
        Game.createItem(objectId, 1, position)
    end
end

local stepTilesRemoveObject = MoveEvent()
stepTilesRemoveObject:type("stepin")

function stepTilesRemoveObject.onStepIn(player, item, position, fromPosition)

    -- confirm is player
    if not player:isPlayer() then
        return true
    end
   
    -- confirm index
    local actionId = item:getActionId()
    local index = config[actionId]
    if not index then
        print("LUA error: ActionId not in table." .. actionId)
        return true
    end
   
    -- confirm that object exists
    if Tile(index.object.position):getItemCountById(index.object.itemId) == 0 then
        position:sendMagicEffect(CONST_ME_POFF)
        return true
    end
   
    -- confirm if all tiles are occupied
    local positionAmount = #index.tilePositions
    local playerCount = 0
    for i = 1, positionAmount do
        local creature = Tile(index.tilePositions[i]):getTopCreature()
        if not creature or not creature:isPlayer() then
            index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_RED)
        else
            index.tilePositions[i]:sendMagicEffect(CONST_ME_MAGIC_GREEN)
            playerCount = playerCount + 1
        end           
    end
   
    -- remove and reAdd stone
    if playerCount == positionAmount then
        removeAndReAddObject(index.object.position, index.object.itemId, index.object.removeTimer * 1000)
    end   
    return true
end

for actionid, _ in pairs(config) do
    stepTilesRemoveObject:aid(actionid) -- adds all actionid's from config
end
stepTilesRemoveObject:register()
 
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
If that is happening, then some other script is erroneously registering a massive amount of id's.
(I just tested the script on my 1.3 test server, and it's working correctly.)

Have you installed some other script recently?

Yes, many, in fact it is not 100% tfs1.3 it is for OTservBR. However the other's scripts work naturally, the one I'm having problems with. I've even used other scripts made by you.

FLP
 
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
Try using something like 57875 and 57876
Hmm, dont work also =´(. The problem continues. strange that i have already managed to use other uid like 45016. maybe it is something related to this part of the code: for actionid, _ in pairs(config) do

I don't know what that does, but it doesn't seem to work on OTservBR. even though it is TFS1.3. The strangest thing that, as I said, I used several scripts here from the forum for TFS1.3, only this one is presenting problems like this.

FLP
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,522
Solutions
378
Reaction score
3,638
Hmm, dont work also =´(. The problem continues. strange that i have already managed to use other uid like 45016. maybe it is something related to this part of the code: for actionid, _ in pairs(config) do

I don't know what that does, but it doesn't seem to work on OTservBR. even though it is TFS1.3. The strangest thing that, as I said, I used several scripts here from the forum for TFS1.3, only this one is presenting problems like this.

FLP
It's just a simple for loop
example..
Lua:
local config = {
    [45010] = {    },
    [45011] = {    }
}

for actionid, _ in pairs(config) do
    print(actionid)
end
Output
Code:
45010
45011
 
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
Put on your sunglasses, as you will see a horrible code. In Brazil we call it a gambiarra.

I should work with object-oriented programming, even without knowing how to program I can do aberrations like this:


Lua:
-- FLP#2311


local tilesPositions = {
    {x = 33049, y = 31638, z = 5},
    {x = 33049, y = 31628, z = 5},
    {x = 33071, y = 31613, z = 5}
}

local wallsPositions = {
    {x = 33074, y = 31612, z = 5},
    {x = 33074, y = 31613, z = 5},
    {x = 33074, y = 31614, z = 5},
    {x = 33074, y = 31615, z = 5},
    {x = 33074, y = 31616, z = 5}
}

local function removeAndReAddObject(position, objectId, timer)
        for i = 1, #wallsPositions do
        wall = Tile(wallsPositions[i]):getItemById(9533)
        -- Check there is no walls before create new ones
        if not wall then
            Position(wallsPositions[i]):hasCreature({x = 33074, y = 31614, z = 5})
            Game.createItem(9533, 1, wallsPositions[i])
        end
    end
end

local walls = MoveEvent()
walls:type("stepin")

function walls.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
    local tileCreature1 = Tile(tilesPositions[1]):getTopCreature()
    local tileCreature2 = Tile(tilesPositions[2]):getTopCreature()
    local tileCreature3 = Tile(tilesPositions[3]):getTopCreature()
    -- Check 3 tiles positions have a creature and it is a player
    if tileCreature1 and tileCreature1:getPlayer() and tileCreature2 and tileCreature2:getPlayer() and tileCreature3 and tileCreature3:getPlayer() then
                for i = 1, #wallsPositions do
            wall = Tile(wallsPositions[i]):getItemById(9533)
            -- Check there walls before delete them
            if wall then
                wall:remove()
                position:sendMagicEffect(CONST_ME_POFF)
                addEvent(removeAndReAddObject, 2 * 60 * 1000)
            end
        end
    end
    return true
end

for index, value in pairs(tilesPositions) do
    walls:position(value)
end

walls:register()

FLP
 
Last edited:
Solution
Top