• Minor technical glitch has been resolved. Logging in and posting is now possible again!
  • Congratulations to new Staff Members on their promotion!

Creating items or using lever destroys the tile

Klonera

Once upon a time.
Premium User
Joined
Jul 16, 2016
Messages
403
Best answers
1
Reaction score
52
Location
Sweden
Hello,
How do you fix this?
If you create wrong item with /i command for example /i great mana pation, 100 it creates 100 items which you can't remove and if you use a lever this happens

 
Last edited:

adrianokk

Member
Joined
Jan 22, 2019
Messages
34
Best answers
0
Reaction score
1
and because there is a limit of things you can put on top of 1 block
what is playing there, is so many many items or Sprits repeated in 1 single block, so of that.
is an anti-crash system
 
OP
Klonera

Klonera

Once upon a time.
Premium User
Joined
Jul 16, 2016
Messages
403
Best answers
1
Reaction score
52
Location
Sweden
and because there is a limit of things you can put on top of 1 block
what is playing there, is so many many items or Sprits repeated in 1 single block, so of that.
is an anti-crash system
Allright, how do i disable it?
 
OP
Klonera

Klonera

Once upon a time.
Premium User
Joined
Jul 16, 2016
Messages
403
Best answers
1
Reaction score
52
Location
Sweden
Bump
 

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
358
Location
Poland
This is something in your source. Creating items that don't exist shouldn't do anything by default.
 
OP
Klonera

Klonera

Once upon a time.
Premium User
Joined
Jul 16, 2016
Messages
403
Best answers
1
Reaction score
52
Location
Sweden
This is something in your source. Creating items that don't exist shouldn't do anything by default.
Soo, what is there to look for/edit in the source? i have no basic information about it :(
 

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
358
Location
Poland
Soo, what is there to look for/edit in the source? i have no basic information about it :(
Check your create_item.lua script first (talkactions/scripts). Make sure that you can't spawn something that isn't a thing, using /i command.
If you're still able to do that then it's something messed up with source code.
Lua:
local invalidIds = {
    1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 15, 19, 21, 26, 27, 28, 35, 43
}

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")

    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(split[1]))
        if not tonumber(split[1]) or itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")
            return false
        end
    end

    if table.contains(invalidIds, itemType:getId()) then
        return false
    end

    local count = tonumber(split[2])
    if count then
        if itemType:isStackable() then
            count = math.min(10000, math.max(1, count))
        elseif not itemType:isFluidContainer() then
            count = math.min(100, math.max(1, count))
        else
            count = math.max(0, count)
        end
    else
        if not itemType:isFluidContainer() then
            count = 1
        else
            count = 0
        end
    end

    local result = player:addItem(itemType:getId(), count)
    if result then
        if not itemType:isStackable() then
            if type(result) == "table" then
                for _, item in ipairs(result) do
                    item:decay()
                end
            else
                result:decay()
            end
        end
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    return false
end
 

Itutorial

Advanced OT User
Joined
Dec 23, 2014
Messages
1,461
Best answers
31
Reaction score
325
Post your /i command data/talkactions/scripts/create_item.lua
 
OP
Klonera

Klonera

Once upon a time.
Premium User
Joined
Jul 16, 2016
Messages
403
Best answers
1
Reaction score
52
Location
Sweden
Post your /i command data/talkactions/scripts/create_item.lua
Lua:
local invalidIds = {
    1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 15, 19, 21, 26, 27, 28, 35, 43, 1094
}

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")

    if(not split or not split[1]) then
        player:sendCancelMessage('Incorrect syntax use "/i itemName,quantity" OR "/i itemID,quantity".')
        return false
    end

    local itemType = ItemType(split[1])
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(split[1]))
        if itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")
            return false
        end
    end

    if table.contains(invalidIds, itemType:getId()) then
        return false
    end

    local count = tonumber(split[2])
    if count ~= nil then
        if itemType:isStackable() then
            count = math.min(10000, math.max(1, count))
        elseif not itemType:isFluidContainer() then
            count = math.min(100, math.max(1, count))
        else
            count = math.max(0, count)
        end
    else
        if not itemType:isFluidContainer() then
            count = 1
        else
            count = 0
        end
    end

    local result = player:addItem(itemType:getId(), count)
    if result ~= nil then
        if not itemType:isStackable() then
            if type(result) == "table" then
                for _, item in ipairs(result) do
                    item:decay()
                end
            else
                result:decay()
            end
        end
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end
    return false
end
 

jaicob

Excellent OT User
Joined
Feb 16, 2009
Messages
102
Best answers
2
Reaction score
39
post the lever script you use
 
OP
Klonera

Klonera

Once upon a time.
Premium User
Joined
Jul 16, 2016
Messages
403
Best answers
1
Reaction score
52
Location
Sweden
post the lever script you use
Theres alot of lever scripts, heres the one at rookgaard
Lua:
local config = {
    bridgePositions = {
        {position = Position(32099, 32205, 8), groundId = 9022, itemId = 4645},
        {position = Position(32100, 32205, 8), groundId = 4616},
        {position = Position(32101, 32205, 8), groundId = 9022, itemId = 4647}
    },
    leverPositions = {
        Position(32098, 32204, 8),
        Position(32104, 32204, 8)
    },
    relocatePosition = Position(32102, 32205, 8),
    relocateMonsterPosition = Position(32103, 32205, 8),
    bridgeId = 5770
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local leverLeft, lever = item.itemid == 1945
    for i = 1, #config.leverPositions do
        lever = Tile(config.leverPositions[i]):getItemById(leverLeft and 1945 or 1946)
        if lever then
            lever:transform(leverLeft and 1946 or 1945)
        end
    end

    local tile, tmpItem, bridge
    if leverLeft then
        for i = 1, #config.bridgePositions do
            bridge = config.bridgePositions[i]
            tile = Tile(bridge.position)

            tmpItem = tile:getGround()
            if tmpItem then
                tmpItem:transform(config.bridgeId)
            end

            if bridge.itemId then
                tmpItem = tile:getItemById(bridge.itemId)
                if tmpItem then
                    tmpItem:remove()
                end
            end
        end
    else
        for i = 1, #config.bridgePositions do
            bridge = config.bridgePositions[i]
            tile = Tile(bridge.position)

            tile:relocateTo(config.relocatePosition, true, config.relocateMonsterPosition)
            tile:getGround():transform(bridge.groundId)
            Game.createItem(bridge.itemId, 1, bridge.position)
        end

    end
    return true
end
 
Top