• 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.X magic wall rune

changos

Member
Joined
Feb 13, 2012
Messages
75
Solutions
5
Reaction score
22
Hello otland community
i try to mix these both scripts but i get error i try several times/ways but i cant do it

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


function onCastSpell(cid, var)
  if isInArea(getThingPosition(cid), fromPosition1, toPosition1) or isInArea(getThingPosition(cid), fromPosition2, toPosition2) then
          return false, doPlayerSendCancel(cid, "You cannot use any runes in event zone.")
end
    return doCombat(cid, combat, var)
end

Lua:
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

    function countPos(cid, pos, tempo)
        if tempo > 0 and getTileItemById(pos, 1497) then
            doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
            addEvent(countPos, 1000, cid, pos, tempo-1)
        else
            return doSendMagicEffect(pos, 2)
        end
    end

    function onCastSpell(cid, var)
        doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
        countPos(cid, var.pos, 20)
        doCombat(cid, combat, var)
    end

i get those errors

[10/11/2018 23:16:23] [Error - LuaInterface::loadFile] data/spells/scripts/support/magic wall rune.lua:34: 'end' expected (to close 'function' at line 28) near 'countPos'
[10/11/2018 23:16:23] [Error - Event::checkScript] Cannot load script (data/spells/scripts/support/magic wall rune.lua)
[10/11/2018 23:16:23] data/spells/scripts/support/magic wall rune.lua:34: 'end' expected (to close 'function' at line 28) near 'countPos'



the first script is to prevent the mw on events and the second show the time remaining of the mw
and i try to modify the countdoown to appear in description of the mw with third script but i didnt succeed, i want the mw cannot be used in event zone, and it show the mw timer on desc, if not is in desc of mw then with antimated text its good for me, i hope u can helpme, Thanks n sorry for my bad english

OTX 2.44 SE based on tfs 0.4
 
Solution
Hello otland community
i try to mix these both scripts but i get error i try several times/ways but i cant do it

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


function onCastSpell(cid, var)
  if isInArea(getThingPosition(cid), fromPosition1, toPosition1) or isInArea(getThingPosition(cid), fromPosition2, toPosition2) then
          return false, doPlayerSendCancel(cid, "You cannot use any runes in event zone.")
end
    return doCombat(cid, combat, var)
end

Lua:
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat...
Hello otland community
i try to mix these both scripts but i get error i try several times/ways but i cant do it

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


function onCastSpell(cid, var)
  if isInArea(getThingPosition(cid), fromPosition1, toPosition1) or isInArea(getThingPosition(cid), fromPosition2, toPosition2) then
          return false, doPlayerSendCancel(cid, "You cannot use any runes in event zone.")
end
    return doCombat(cid, combat, var)
end

Lua:
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

    function countPos(cid, pos, tempo)
        if tempo > 0 and getTileItemById(pos, 1497) then
            doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
            addEvent(countPos, 1000, cid, pos, tempo-1)
        else
            return doSendMagicEffect(pos, 2)
        end
    end

    function onCastSpell(cid, var)
        doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
        countPos(cid, var.pos, 20)
        doCombat(cid, combat, var)
    end

i get those errors

[10/11/2018 23:16:23] [Error - LuaInterface::loadFile] data/spells/scripts/support/magic wall rune.lua:34: 'end' expected (to close 'function' at line 28) near 'countPos'
[10/11/2018 23:16:23] [Error - Event::checkScript] Cannot load script (data/spells/scripts/support/magic wall rune.lua)
[10/11/2018 23:16:23] data/spells/scripts/support/magic wall rune.lua:34: 'end' expected (to close 'function' at line 28) near 'countPos'



the first script is to prevent the mw on events and the second show the time remaining of the mw
and i try to modify the countdoown to appear in description of the mw with third script but i didnt succeed, i want the mw cannot be used in event zone, and it show the mw timer on desc, if not is in desc of mw then with antimated text its good for me, i hope u can helpme, Thanks n sorry for my bad english

OTX 2.44 SE based on tfs 0.4
Try this I guess.
Lua:
local event_areas = {
    {{x = 1000, y = 1000, z = 7}, {x = 1000, y = 1000, z = 7}}, -- {{from},{to}}
    {{x = 1000, y = 1000, z = 7}, {x = 1000, y = 1000, z = 7}}
}

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

function countPos(cid, pos, tempo)
    if tempo > 0 and getTileItemById(pos, 1497) then
        doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
        addEvent(countPos, 1000, cid, pos, tempo-1)
    else
        return doSendMagicEffect(pos, 2)
    end
end

function onCastSpell(cid, var)
    local cid_pos = getThingPosition(cid)
    for i = 1, #event_areas do
        if isInArea(cid_pos, event_areas[i][1], event_areas[i][2]) then
            doPlayerSendCancel(cid, "You cannot use any runes in event zone.")
            return false
        end
    end
   
    doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
    countPos(cid, var.pos, 20)
    doCombat(cid, combat, var)
    return true
end
 
Solution
Hi, sorry for reviving this old thread but it's better if I post this here. I want to do this same thing for the Wild Growth Rune, but the problem is that the timer still running after using machete to break the Wild Growth Wall. @Xikini, this is how script looks, what can I do to fix the machete problem? Or to directly stop timer if the wall dissapears for any reason.

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1499)

function countPos(cid, pos, tempo)
    if tempo > 0 and getTileItemById(pos, 1499) then
        doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
        addEvent(countPos, 1000, cid, pos, tempo-1)
    else
        return doSendMagicEffect(pos, 2)
    end
end

function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
        return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
    end
 
    doCreatureSay(cid, 'ROOT', TALKTYPE_ORANGE_1)
    countPos(cid, var.pos, 45)
    doCombat(cid, combat, var)
    return true
end
 
Last edited:
Hi, sorry for reviving this old thread but it's better if I post this here. I want to do this same thing for the Wild Growth Rune, but the problem is that the timer still running after using machete to break the Wild Growth Wall. @Xikini, this is how script looks, what can I do to fix the machete problem? Or to directly stop timer if the wall dissapears for any reason.

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1499)

function countPos(cid, pos, tempo)
    if tempo > 0 and getTileItemById(pos, 1499) then
        doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
        addEvent(countPos, 1000, cid, pos, tempo-1)
    else
        return doSendMagicEffect(pos, 2)
    end
end

function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
        return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
    end
 
    doCreatureSay(cid, 'ROOT', TALKTYPE_ORANGE_1)
    countPos(cid, var.pos, 45)
    doCombat(cid, combat, var)
    return true
end
pretty sure you can just change this line to work as intended, and it'll solve your issue
Lua:
if tempo > 0 and getTileItemById(pos, 1499) then
change to
Lua:
if tempo > 0 and getTileItemById(pos, 1499) > 0 then
 
pretty sure you can just change this line to work as intended, and it'll solve your issue
Lua:
if tempo > 0 and getTileItemById(pos, 1499) then
change to
Lua:
if tempo > 0 and getTileItemById(pos, 1499) > 0 then
Shouldnt be getTileItemById(pos, 1499).uid ?
 
Tried with booth, but is not working
View attachment 53806

@Xikini @Deatthraz
Thx for responding ☺️

When adding
Code:
if tempo > 0 and getTileItemById(pos, 1499).uid  > 0 then

the timer of the magic wall and the wild growth rune stop working, but, booth runes throw the wall spell
Try this.. and show us what the console looks like.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1499)

function countPos(cid, pos, tempo)
	print("------------")
	print("tempo = " .. tempo)
	print("wild growth = " .. getTileItemById(pos, 1499).uid)
    if tempo > 0 and getTileItemById(pos, 1499).uid > 0 then
		print("Counter is continuing..")
        doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
        addEvent(countPos, 1000, cid, pos, tempo-1)
    else
		print("Counter finished.")
        return doSendMagicEffect(pos, 2)
    end
end

function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
        return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
    end
 
    doCreatureSay(cid, 'ROOT', TALKTYPE_ORANGE_1)
    countPos(cid, var.pos, 45)
    doCombat(cid, combat, var)
    return true
end
 
Last edited:
@Xikini

View attachment 53817

booth runes are throwing the wall but the timer is not counting :)
I've only edited wild growth script, magic wall is still the same
Huh. the @Xikini didn't ping me. 🤔

I understand the problem.
The countPos function is being called before the wild-growth is being spawned from the onCombat function

So, we just need to delay it slightly.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1499)

function countPos(cid, pos, tempo)
	print("------------")
	print("tempo = " .. tempo)
	print("wild growth = " .. getTileItemById(pos, 1499).uid)
	if tempo > 0 and getTileItemById(pos, 1499).uid > 0 then
		print("Counter is continuing..")
		doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
		addEvent(countPos, 1000, cid, pos, tempo-1)
	else
		print("Counter finished.")
		return doSendMagicEffect(pos, 2)
	end
end

function onCastSpell(cid, var)
	local pos = variantToPosition(var)
	if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
		return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
	end
	
	doCreatureSay(cid, 'ROOT', TALKTYPE_ORANGE_1)
	addEvent(countPos, 0, cid, var.pos, 45)
	doCombat(cid, combat, var)
	return true
end
 
Amazing! All is working good, this happen when throw and cut the roots with machete:
imagen_2021-01-17_063924.png

But there's a problem with my magic wall. It does not start the count, this is how I have it:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

function countPos(cid, pos, tempo)
    if tempo > 0 and getTileItemById(pos, 1497) then
        doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
        addEvent(countPos, 1000, cid, pos, tempo-1)
    else
        return doSendMagicEffect(pos, 2)
    end
end

function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
        return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
    end
   
    doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
    countPos(cid, var.pos, 20)
    doCombat(cid, combat, var)
    return true
end

@Xikini
 
Amazing! All is working good, this happen when throw and cut the roots with machete:
View attachment 53818

But there's a problem with my magic wall. It does not start the count, this is how I have it:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

function countPos(cid, pos, tempo)
    if tempo > 0 and getTileItemById(pos, 1497) then
        doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
        addEvent(countPos, 1000, cid, pos, tempo-1)
    else
        return doSendMagicEffect(pos, 2)
    end
end

function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
        return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
    end
   
    doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
    countPos(cid, var.pos, 20)
    doCombat(cid, combat, var)
    return true
end

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

function countPos(cid, pos, tempo)
	if tempo > 0 and getTileItemById(pos, 1497).uid > 0 then
		doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
		addEvent(countPos, 1000, cid, pos, tempo-1)
	else
		return doSendMagicEffect(pos, 2)
	end
end

function onCastSpell(cid, var)
	local pos = variantToPosition(var)
	if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
		return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
	end
	
	doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
	addEvent(countPos, 0, cid, var.pos, 20)
	doCombat(cid, combat, var)
	return true
end
 
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

function countPos(cid, pos, tempo)
if tempo > 0 and getTileItemById(pos, 1497).uid > 0 then
doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
addEvent(countPos, 1000, cid, pos, tempo-1)
else
return doSendMagicEffect(pos, 2)
end
end

function onCastSpell(cid, var)
local pos = variantToPosition(var)
if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
end

doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
addEvent(countPos, 0, cid, var.pos, 20)
doCombat(cid, combat, var)
return true
end

Same result :(
counter finished.png
 
UGH. your spells are doing the weird glitchy shit that 0.4 suffers from.

We just gotta rename the variables to be different.

Wild Growth
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1499)

local function wildGrowthCounter(cid, pos, tempo)
	if tempo > 0 and getTileItemById(pos, 1499).uid > 0 then
		doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
		addEvent(wildGrowthCounter, 1000, cid, pos, tempo-1)
	else
		return doSendMagicEffect(pos, 2)
	end
end

function onCastSpell(cid, var)
	local pos = variantToPosition(var)
	if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
		return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
	end
	
	doCreatureSay(cid, 'ROOT', TALKTYPE_ORANGE_1)
	addEvent(wildGrowthCounter, 0, cid, var.pos, 45)
	doCombat(cid, combat, var)
	return true
end
Magic Wall
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1497)

local function magicWallCounter(cid, pos, tempo)
	if tempo > 0 and getTileItemById(pos, 1497).uid > 0 then
		doSendAnimatedText(pos, tempo, TEXTCOLOR_YELLOW)
		addEvent(magicWallCounter, 1000, cid, pos, tempo-1)
	else
		return doSendMagicEffect(pos, 2)
	end
end

function onCastSpell(cid, var)
	local pos = variantToPosition(var)
	if getTileInfo(getThingPos(cid)).protection or getTileInfo(pos).protection then
		return not doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)
	end
	
	doCreatureSay(cid, 'WALL', TALKTYPE_ORANGE_1)
	addEvent(magicWallCounter, 0, cid, var.pos, 20)
	doCombat(cid, combat, var)
	return true
end
 
Niceeeee! Now is perfect 🥳
Thanks a lot again, @Xikini
It's technically not perfect, because someone could cut down the wild growth, and have another person throw a new wild-growth in the same spot (within the 0-1 second timer inbetween numbers), you'll get a double timer counting down. xD

But yeah, it's decent as-is.
 
Back
Top