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

Lua [OTBR] Creaturescripts Error Transform

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
hi, help me with this error from this scripts?

Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/heart_of_destruction/aftershock_transform.lua:callback
...pts/quests/heart_of_destruction/aftershock_transform.lua:16: attempt to perform arithmetic on a nil value
stack traceback:
        [C]: in function '__div'
        ...pts/quests/heart_of_destruction/aftershock_transform.lua:16: in function <...pts/quests/heart_of_destruction/aftershock_transform.lua:2>


foreshock_transform.lua
Lua:
local aftershockTransform = CreatureEvent("AftershockTransform")
function aftershockTransform.onThink(creature)
    if not creature:isMonster() then
        return true
    end

    local monsterTable = {
        [80] = {fromStage = 0, toStage = 1},
        [60] = {fromStage = 1, toStage = 2},
        [40] = {fromStage = 2, toStage = 3},
        [25] = {fromStage = 3, toStage = 4},
        [10] = {fromStage = 4, toStage = 5}
    }
  
    for index, value in pairs(monsterTable) do
        local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
        if realityQuakeStage == 0 then
            local aftershockHealth = creature:getHealth()
            if hp <= index and aftershockStage == value.fromStage then
                creature:remove()
                local monster = Game.createMonster("foreshock", {x = 32208, y = 31248, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32203, y = 31246, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32205, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32210, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32212, y = 31246, z = 14}, false, true)
                monster:addHealth(-monster:getHealth() + aftershockHealth, COMBAT_PHYSICALDAMAGE)
                aftershockStage = value.toStage
            end
        end
    end
    return true
end

aftershockTransform:register()
 
Last edited by a moderator:
OP
OP
A

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
Add before for loop, let me know what it prints on console
Lua:
print('creature: ' .. creature .. '\nHP ' .. creature:getHealth() .."\nMax HP: ".. creature:getMaxHealth())
I have to change the whole line 16 for this?
Lua:
print('creature: ' .. creature .. '\nHP ' .. creature:getHealth() .."\nMax HP: ".. creature:getMaxHealth())
 
OP
OP
A

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
no, I said add it before the for loop.
LINE 14.
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/heart_of_destruction/aftershock_transform.lua:callback
...pts/quests/heart_of_destruction/aftershock_transform.lua:14: attempt to concatenate local 'creature' (a userdata value)
stack traceback:
        [C]: in function '__concat'
        ...pts/quests/heart_of_destruction/aftershock_transform.lua:14: in function <...pts/quests/heart_of_destruction/aftershock_transform.lua:2>
 
OP
OP
A

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
Lua:
print('\nHP ' .. tostring(creature:getHealth()) .."\nMax HP: ".. tostring(creature:getMaxHealth()))
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/heart_of_destruction/aftershock_transform.lua:callback
...pts/quests/heart_of_destruction/aftershock_transform.lua:16: attempt to perform arithmetic on a nil value
stack traceback:
        [C]: in function '__div'
        ...pts/quests/heart_of_destruction/aftershock_transform.lua:16: in function <...pts/quests/heart_of_destruction/aftershock_transform.lua:2>

HP 105000
Max HP: 105000

HP 105000
Max HP: 105000

HP 105000
Max HP: 105000

HP 105000
XD.png

XD.png
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,247
Solutions
71
Reaction score
587
Location
Hell
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/heart_of_destruction/aftershock_transform.lua:callback
...pts/quests/heart_of_destruction/aftershock_transform.lua:16: attempt to perform arithmetic on a nil value
stack traceback:
        [C]: in function '__div'
        ...pts/quests/heart_of_destruction/aftershock_transform.lua:16: in function <...pts/quests/heart_of_destruction/aftershock_transform.lua:2>

HP 105000
Max HP: 105000

HP 105000
Max HP: 105000

HP 105000
Max HP: 105000

HP 105000
View attachment 57685

View attachment 57686
could u try
replacing
Lua:
if not creature:isMonster() then
    return true
end
with:
Lua:
if (not creature) or (not creature:isMonster()) then
    return true
end
 
OP
OP
A

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
could u try
replacing
Lua:
if not creature:isMonster() then
    return true
end
with:
Lua:
if (not creature) or (not creature:isMonster()) then
    return true
end
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/heart_of_destruction/foreshock_transform.lua:callback
...ipts/quests/heart_of_destruction/foreshock_transform.lua:16: attempt to perform arithmetic on a nil value
stack traceback:
        [C]: in function '__div'
        ...ipts/quests/heart_of_destruction/foreshock_transform.lua:16: in function <...ipts/quests/heart_of_destruction/foreshock_transform.lua:2>


HP 105000
Max HP: 105000


HP 105000
Max HP: 105000


HP 105000
Max HP: 105000


HP 105000
 
OP
OP
A

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
add break after creature:remove() Line 20

It gave me this error, I think the break would have to go like this, right?
Lua:
> aftershock_transform.lua [error]
^ ...pts/quests/heart_of_destruction/aftershock_transform.lua:21: 'end' expected (to close 'if' at line 19) near 'local'
> foreshock_transform.lua [error]
^ ...ipts/quests/heart_of_destruction/foreshock_transform.lua:21: 'end' expected (to close 'if' at line 19) near 'local'
Reloaded: scripts.
[Warning - Monster::Monster] Unknown event name: ForeshockTransform
[Warning - Monster::Monster] Unknown event name: AftershockTransform

Code:
local foreshockTransform = CreatureEvent("ForeshockTransform")
function foreshockTransform.onThink(creature)
    if (not creature) or (not creature:isMonster()) then
    return true
end

    local monsterTable = {
        [80] = {fromStage = 0, toStage = 1},
        [60] = {fromStage = 1, toStage = 2},
        [40] = {fromStage = 2, toStage = 3},
        [25] = {fromStage = 3, toStage = 4},
        [10] = {fromStage = 4, toStage = 5}
    }
    print('\nHP ' .. tostring(creature:getHealth()) .."\nMax HP: ".. tostring(creature:getMaxHealth()))
    for index, value in pairs(monsterTable) do
        local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
        if realityQuakeStage == 0 then
            local foreshockHealth = creature:getHealth()
            if hp <= index and aftershockStage == value.fromStage then
                creature:remove() break
                local monster = Game.createMonster("aftershock", {x = 32208, y = 31248, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32203, y = 31246, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32205, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32210, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32212, y = 31246, z = 14}, false, true)
                monster:addHealth(-monster:getHealth() + foreshockHealth, COMBAT_PHYSICALDAMAGE)
                foreshockStage = value.toStage
            end
        end
    end
    return true
end

foreshockTransform:register()
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,247
Solutions
71
Reaction score
587
Location
Hell
Lua:
local foreshockTransform = CreatureEvent("ForeshockTransform")
function foreshockTransform.onThink(creature)
    if (not creature) or (not creature:isMonster()) then
        return true
    end
    local monsterTable = {
        [80] = {fromStage = 0, toStage = 1},
        [60] = {fromStage = 1, toStage = 2},
        [40] = {fromStage = 2, toStage = 3},
        [25] = {fromStage = 3, toStage = 4},
        [10] = {fromStage = 4, toStage = 5}
    }
    for index, value in pairs(monsterTable) do
        local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
        if realityQuakeStage == 0 then
            local foreshockHealth = creature:getHealth()
            if hp <= index and aftershockStage == value.fromStage then
                local monster = Game.createMonster("aftershock", {x = 32208, y = 31248, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32203, y = 31246, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32205, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32210, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32212, y = 31246, z = 14}, false, true)
                monster:addHealth(-monster:getHealth() + foreshockHealth, COMBAT_PHYSICALDAMAGE)
                foreshockStage = value.toStage
                creature:remove()
                break
            end
        end
    end
    return true
end
foreshockTransform:register()
 
OP
OP
A

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
Lua:
local foreshockTransform = CreatureEvent("ForeshockTransform")
function foreshockTransform.onThink(creature)
    if (not creature) or (not creature:isMonster()) then
        return true
    end
    local monsterTable = {
        [80] = {fromStage = 0, toStage = 1},
        [60] = {fromStage = 1, toStage = 2},
        [40] = {fromStage = 2, toStage = 3},
        [25] = {fromStage = 3, toStage = 4},
        [10] = {fromStage = 4, toStage = 5}
    }
    for index, value in pairs(monsterTable) do
        local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
        if realityQuakeStage == 0 then
            local foreshockHealth = creature:getHealth()
            if hp <= index and aftershockStage == value.fromStage then
                local monster = Game.createMonster("aftershock", {x = 32208, y = 31248, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32203, y = 31246, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32205, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32210, y = 31251, z = 14}, false, true)
                local monster = Game.createMonster("spark of destruction", {x = 32212, y = 31246, z = 14}, false, true)
                monster:addHealth(-monster:getHealth() + foreshockHealth, COMBAT_PHYSICALDAMAGE)
                foreshockStage = value.toStage
                creature:remove()
                break
            end
        end
    end
    return true
end
foreshockTransform:register()

Lua:
> aftershock_transform.lua [error]
^ ...pts/quests/heart_of_destruction/aftershock_transform.lua:19: 'end' expected (to close 'if' at line 17) near 'local'
> foreshock_transform.lua [error]
^ ...ipts/quests/heart_of_destruction/foreshock_transform.lua:19: 'end' expected (to close 'if' at line 17) near 'local'
 
Top