• 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 help with script

Elaney

Member
Joined
Jan 1, 2009
Messages
1,561
Reaction score
12
Location
Sweden
Code:
function onUse(cid, item, fromPos, item2, toPos)

local switchUniqueID = 19000  -- uniqueID of switch
	local switchID = 1945
	local switch2ID = 1946
	local wallpos = {x=1145, y=1231, z=9, stackpos=1}
	
	local wallchk = getThingfromPos(wallpos)
	
	if item.uid == switchUniqueID and item.itemid == switchID and wallchk.itemid == 3362 then
			doSendMagicEffect(wallchk,10)
			doRemoveItem(wallchk.uid,1)
			doTransformItem(item.uid,item.itemid+1)
			addEvent(onTimer1, 1*60*1000)
	elseif item.uid == switchUniqueID and item.itemid == switch2ID then
			doTransformItem(item.uid,item.itemid-1)
	end 
return TRUE
end

function onTimer1()

wallnewpos = {x=1145, y=1231, z=9} 
		doCreateItem(3362,1,wallnewpos)
end

well i want the code to work, but right now the only thing that dosnt work is the adEvent timer. anything can se something wrong with that part?
 
LUA:
local config =
{
    wallPos = {x=1145, y=1231, z=9, stackpos=1}, -- Wall Position
    leverPos = {x=100, y=100, z=7}, -- Lever Position
    timeToCreate = 10 -- Seconds
}

function onUse(cid, item, fromPos, item2, toPos)
    if (item.itemid == 1945) and (item.uid == 19000) then
        doRemoveItem(3362, config.wallPos)
        doSendMagicEffect(config.wallPos, CONST_ME_POFF)
        doCreatureSay(leverPos, "The wall has been removed!", TALKTYPE_ORANGE_1)
        addEvent(doCreateWall, config.timeToCreate * 1000)
    elseif item.itemid == 1946 then
        doPlayerSendCancel(cid, "The wall has already been removed.")
    return TRUE
    end
end

function doCreateWall()
local wall = getThingfromPos(config.wallPos, 3362)
local Lever = getThingfromPos(config.LeverPos, 1946)
    if wall.uid < 0 then
        doCreateItem(wall.uid)
        doSendMagicEffect(config.wallPos, CONST_ME_TELEPORT)
        doTransformItem(Lever.uid, 1945)
    end
end
 
Last edited:
still not working.

Edit #2 dosnt even remove the wall anymore ;p

Waiting for edit #3.

still looking :P

Code:
[19/08/2009 23:48:48] Lua Script Error: [Action Interface] 
[19/08/2009 23:48:48] data/actions/scripts/quests/newwall.lua:onUse

[19/08/2009 23:48:48] luaDoRemoveItem(). Item not found

[19/08/2009 23:48:48] Lua Script Error: [Action Interface] 
[19/08/2009 23:48:48] data/actions/scripts/quests/newwall.lua:onUse

[19/08/2009 23:48:48] luaDoCreatureSay(). Creature not found

[19/08/2009 23:48:58] Lua Script Error: [Action Interface] 
[19/08/2009 23:48:58] in a timer event called from: 
[19/08/2009 23:48:58] data/actions/scripts/quests/newwall.lua:onUse

[19/08/2009 23:48:58] attempt to index a number value
[19/08/2009 23:48:58] stack traceback:
[19/08/2009 23:48:58]     [C]: in function 'getThingfromPos'
[19/08/2009 23:48:58]     data/actions/scripts/quests/newwall.lua:22: in function <data/actions/scripts/quests/newwall.lua:21>
 
Last edited by a moderator:
same errors
Code:
[20[COLOR=#66cc66]/[/COLOR]08[COLOR=#66cc66]/[/COLOR]2009 18:54:14[COLOR=#66cc66]][/COLOR] Lua Script Error: [COLOR=#66cc66][[/COLOR]Action Interface[COLOR=#66cc66]][/COLOR] 
[LEFT] [COLOR=#66cc66][[/COLOR]20[COLOR=#66cc66]/[/COLOR]08[COLOR=#66cc66]/[/COLOR]2009 18:54:14[COLOR=#66cc66]][/COLOR] data[COLOR=#66cc66]/[/COLOR]actions[COLOR=#66cc66]/[/COLOR]scripts[COLOR=#66cc66]/[/COLOR]quests[COLOR=#66cc66]/[/COLOR]newwall.lua:onUse

[COLOR=#66cc66][[/COLOR]20[COLOR=#66cc66]/[/COLOR]08[COLOR=#66cc66]/[/COLOR]2009 18:54:14[COLOR=#66cc66]][/COLOR] luaDoRemoveItem[COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR]. Item [COLOR=#b1b100]not[/COLOR] found

[COLOR=#66cc66][[/COLOR]20[COLOR=#66cc66]/[/COLOR]08[COLOR=#66cc66]/[/COLOR]2009 18:54:14[COLOR=#66cc66]][/COLOR] Lua Script Error: [COLOR=#66cc66][[/COLOR]Action Interface[COLOR=#66cc66]][/COLOR] 
[COLOR=#66cc66][[/COLOR]20[COLOR=#66cc66]/[/COLOR]08[COLOR=#66cc66]/[/COLOR]2009 18:54:14[COLOR=#66cc66]][/COLOR] data[COLOR=#66cc66]/[/COLOR]actions[COLOR=#66cc66]/[/COLOR]scripts[COLOR=#66cc66]/[/COLOR]quests[COLOR=#66cc66]/[/COLOR]newwall.lua:onUse

[COLOR=#66cc66][[/COLOR]20[COLOR=#66cc66]/[/COLOR]08[COLOR=#66cc66]/[/COLOR]2009 18:54:14[COLOR=#66cc66]][/COLOR] luaDoCreatureSay[COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR]. Creature [COLOR=#b1b100]not[/COLOR] found              [/LEFT]
Updated to 0.2.5 btw ;P
 
Last edited by a moderator:
LUA:
local config =
{
    wallPos = {x=1145, y=1231, z=9, stackpos=1}, -- Wall Position
    leverPos = {x=100, y=100, z=7}, -- Lever Position
    timeToCreate = 10 -- Seconds
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local wallCheck = getTileItemById(cid, config.wallPos)
    if (item.itemid == 1945) and (item.uid == 19000) then
        doRemoveItem(3362, wallCheck)
        doSendMagicEffect(config.wallPos, CONST_ME_POFF)
        doCreatureSay(leverPos, "The wall has been removed!", TALKTYPE_ORANGE_1)
        addEvent(doCreateWall, config.timeToCreate * 1000)
    elseif item.itemid == 1946 then
        doPlayerSendCancel(cid, "The wall has already been removed.")
    return TRUE
    end
end

local function doCreateWall()
local Lever = getTileItemById(config.LeverPos, 1946)
    if wallCheck.uid < 0 then
        doCreateItem(wallCheck.uid)
        doSendMagicEffect(config.wallPos, CONST_ME_TELEPORT)
        doTransformItem(Lever.uid, 1945)
    end
end
 
LUA:
[21/08/2009 14:12:21] Lua Script Error: [Action Interface] 
[21/08/2009 14:12:21] data/actions/scripts/quests/newwall.lua:onUse

[21/08/2009 14:12:21] attempt to index a number value
[21/08/2009 14:12:21] stack traceback:
[21/08/2009 14:12:21] 	[C]: in function 'getTileItemById'
[21/08/2009 14:12:21] 	data/actions/scripts/quests/newwall.lua:9: in function <data/actions/scripts/quests/newwall.lua:8>
 
LUA:
function onUse(cid, item, fromPos, item2, toPos)
	local wallpos = {x=1145, y=1231, z=9, stackpos=1}
	local wallchk = getThingfromPos(wallpos)
	
	local function onTimer1(p)
		local wallpos = {x=1145, y=1231, z=9, stackpos=1}
		local wallchk = getThingfromPos(wallpos)
		
		if wallchk.itemid == 0 then
		doCreateItem(3362,1,wallpos)
		end
	end
	
	if wallchk.itemid == 3362 then
		doSendMagicEffect(wallpos,10)
		doRemoveItem(wallchk.uid,1)
		addEvent(onTimer1, 1*60*1000, p)
	end 
	
	if item.itemid == 1945 then
		doTransformItem(item.uid,item.itemid+1)
	else
		doTransformItem(item.uid,item.itemid-1)
	end
	
return true
end
idk, i'm hurry :D if no, then try with stackpos=255
 
Back
Top