• 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] Server crashes when I use the Lua script. [Solved]

tosse12

Panchira Project Member
Joined
Jun 10, 2007
Messages
864
Reaction score
9
Location
Sweden
Hi.

My server are crashing when Im using my action script.
The action script is exacly the same as any other lever script just that the item id is : 388/389 (inactive lavahole / active lavahole) but when I use the inactive lavahole the server crash.

I am using tfs 0.3.5

Lua script:
Code:
function onUse(cid, item, frompos, item2, topos)
 -- Lava hole--
  stonepos = {x=9848, y=9857, z=10, stackpos=1}
  getstone = getThingFromPos(stonepos)
	if item.itemid == 388 and item.uid == 1014 then
		doRemoveItem(getstone.uid, 1304)
		doTransformItem(item.uid, 339)
	elseif item.itemid == 389 and item.uid == 1014 then
		doCreateItem(1304, 1, stonepos)
		doTransformItem(item.uid, 338)
        else
                doPlayerSendCancel(cid, "Sorry, not possible.")
        end
        return 1
end

action.xml
Code:
<action uniqueid="1014" event="script" value="quest/DIQ_lever.lua"/>
Anyone know how to fix it? Rep+ to those who helped me.
 
Last edited:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {id = 2111, pos = {x = , y= , z=}}

	if (item.itemid == 388) then
		doRemoveItem(getTileItemById(config.id, config.pos).uid)
		doTransformItem(item.uid, item.itemid + 1)
	elseif (item.itemid == 389) then
		doCreateItem(config.id, 1, config.pos)
		doTransformItem(item.uid, item.itemid - 1)
	end
	return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {id = 2111, pos = {x = , y= , z=}}

	if (item.itemid == 388) then
		doRemoveItem(getTileItemById(config.id, config.pos).uid)
		[B][COLOR="Red"]doTransformItem(item.uid, item.itemid + 1)[/COLOR][/B]
	elseif (item.itemid == 389) then
		doCreateItem(config.id, 1, config.pos)
		[B][COLOR="Red"]doTransformItem(item.uid, item.itemid - 1)[/COLOR][/B]
	end
	return true
end
Code:
doTransformItem(item.uid, tonumber("194".. (item.itemid == 1945 and 6 or 5)))
? :D

cykokitten style:
Code:
local config = {
	id = 2111,
	pos = {x = 100, y = 100, z = 7}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
return
	true,
	item.itemid == 388 and
		doRemoveItem(getTileItemById(config.id, config.pos).uid)
	or item.itemid == 389 and
		doCreateItem(config.id, 1, config.pos),
	doTransformItem(item.uid, tonumber("194".. (item.itemid == 1945 and 6 or 5)))
end
Actually the entire script could be "shortened" into 1 line, but what's the use of it?
 
Last edited:
I like readable & short scripts. Actually your style is for me unreadable. It hurts my eyes, sorry. :(
 
I am getting this error :/
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/extream/quest/DIQ_lever2.lua:onUse

attempt to index a number value
stack traceback:
        [C]: in function 'getTileItemById'
        data/actions/scripts/extream/quest/DIQ_lever2.lua:9: in function <data/a
ctions/scripts/extream/quest/DIQ_lever2.lua:5>
I used cykokitten style script :D
 
Oh, forgot to test it too xD

Edit:
Still same Error message
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/extream/quest/DIQ_lever2.lua:onUse

attempt to index a number value
stack traceback:
        [C]: in function 'getTileItemById'
        data/actions/scripts/extream/quest/DIQ_lever2.lua:11: in function <data/
actions/scripts/extream/quest/DIQ_lever2.lua:5>
 
Last edited:
I fixed it myself.
Code:
doRemoveItem(getTileItemById(config.id, config.pos).uid)
The "config.id" and "config.pos" are on the wrong place :D
It shall look like this:
Code:
doRemoveItem(getTileItemById(config.pos, config.id).uid)

it's working perfetct now, and I am giving rep+ to both of you for helping me :D

I like readable & short scripts. Actually your style is for me unreadable. It hurts my eyes, sorry. :(


Well, to be honest, it hurts my eyes too, don't understand the
Code:
doTransformItem(item.uid, tonumber("194".. (item.itemid == 1945 and 6 or 5)))
 
Last edited:
Back
Top