• 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 Magic wall problem

Daemonium

Programmer
Joined
Oct 18, 2015
Messages
57
Solutions
1
Reaction score
8
Location
Canada
I keep having this problem for a while already.

[15/02/2018 20:22:46] [Error - Spell Interface]
[15/02/2018 20:22:46] data/spells/scripts/support/magic wall rune.lua:eek:nCastSpell
[15/02/2018 20:22:46] Description:
[15/02/2018 20:22:46] data/spells/scripts/support/magic wall rune.lua:11: attempt to get length of global 'illegal' (a nil value)
[15/02/2018 20:22:46] stack traceback:
[15/02/2018 20:22:46] data/spells/scripts/support/magic wall rune.lua:11: in function <data/spells/scripts/support/magic wall rune.lua:5>

I can't understand where the error is....

here's the script :

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

function onCastSpell(cid, var)
	local p = getThingPos(cid)
	local t1, t2 = getTileInfo(p), getTileInfo(variantToPosition(var))
	if t1.protection or t2.protection or t1.optional or t2.optional then
		return not doPlayerSendCancel(cid, 'You cannot use this rune here.')
	end
	for i = 1, #illegal do
		if isInRange(p, illegal[i][1], illegal[i][2]) then
			doPlayerSendCancel(cid, 'You cannot use this rune here.')
			return false
		end
	end

	return doCombat(cid, combat, var)
end

thanks for the help
 
Last edited:
The loop is there so you can define an area where the magic wall cannot be casted. It is not coded correctly but if you want this functionality you can use this:

Lua:
local area = {
    min = {x = 1000, y = 1000, z = 7}, --Top left of square area to not allow wall
    max = {x = 1001, y = 1001, z = 7}, --Bottom right of square area to not allow wall
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

function onCastSpell(cid, var)
    if getTilePzInfo(cid) then
        doPlayerSendCancel(cid, 'You cannot use this rune here.')
        return false
    end
   
    if isInRange(variantToPosition(var), area.min, area.max) then
        doPlayerSendCancel(cid, 'You cannot m-wall this area.')
        return false
    end
   
    return doCombat(cid, combat, var)
end
 
Nevermind... I just commented the loop wich I did not understood what it was doing and now it's all working fine.
Lua:
    for i = 1, #illegal do
        if isInRange(p, illegal[i][1], illegal[i][2]) then
            doPlayerSendCancel(cid, 'You cannot use this rune here.')
            return false
        end
    end

This loop is missing some position from a table that doesnt exist "illegal".
Im sure this was some area where it would have been impossible to use magic walls. but if you dont need it just remove or comment it out as you did.
 
Use this then because your code is not coded well.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

function onCastSpell(cid, var)
    if getTilePzInfo(cid) or getTilePzInfo(variantToPosition(var)) then
        doPlayerSendCancel(cid, 'You cannot use this rune here.')
        return false
    end
    return doCombat(cid, combat, var)
end
 
Back
Top