• 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 Whats wrong with this script?

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
7,030
Solutions
256
Reaction score
2,118
Location
Norway
GitHub
Znote
Tryed a script example, but it was from a XML server, I changed some values and tryed it out, etc GetThingFromPos to GetThingPos, but then I got another message:

Code:
[04/07/2008  19:25:50] Lua Script Error: [Action Interface] 
[04/07/2008  19:25:50] data/actions/scripts/overlord_stonebomb.lua:onUse

[04/07/2008  19:25:50] attempt to index a nil value
[04/07/2008  19:25:50] stack traceback:
[04/07/2008  19:25:50] 	[C]: in function 'doCreateItem'
[04/07/2008  19:25:50] 	data/actions/scripts/overlord_stonebomb.lua:23: in function <data/actions/scripts/overlord_stonebomb.lua:1>

Here is the script:
Code:
function onUse(cid, item, frompos, item2, topos)
	wall1 = {x=910, y=995, z=9, stackpos=1}
	wall1 = {x=911, y=995, z=9, stackpos=1}
	wall1 = {x=912, y=995, z=9, stackpos=1}
	wall1 = {x=910, y=996, z=9, stackpos=1}
	wall1 = {x=910, y=997, z=9, stackpos=1}
	wall1 = {x=911, y=997, z=9, stackpos=1}
	wall1 = {x=912, y=997, z=9, stackpos=1}
	wall1 = {x=912, y=996, z=9, stackpos=1}
	wall1 = {x=911, y=996, z=9, stackpos=1}
	getwall1 = getThingPos(wall1)
	getwall2 = getThingPos(wall2)
	getwall3 = getThingPos(wall3)
	getwall4 = getThingPos(wall4)
	getwall5 = getThingPos(wall5)
	getwall6 = getThingPos(wall6)
	getwall7 = getThingPos(wall7)
	getwall8 = getThingPos(wall8)
	getwall9 = getThingPos(wall9)

	if item.uid == 7882 and item.itemid == 1354 then
		doCreateItem(1492,1,wall1)
		doCreateItem(1492,1,wall2)
		doCreateItem(1492,1,wall3)
		doCreateItem(1492,1,wall4)
		doCreateItem(1492,1,wall5)
		doCreateItem(1492,1,wall6)
		doCreateItem(1492,1,wall7)
		doCreateItem(1492,1,wall8)
		doCreateItem(1355,1,wall9)
		doTransformItem(item.uid,item.itemid-1)
	elseif item.uid == 7882 and item.itemid == 1355 then
		doPlayerSendCancel(cid,"You can not use this object.")	
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	return 1
end

Any ideas?

This was the result when using this script:
resultscript.jpg

All the energy fields shoud be removed, and placed fire fields there instead, and the blue stone shoud be replaced with a red stone
 
Last edited:
I dont know if I'am correct but I'll give you my opinion...

* Maybe you don't have the function in your OT or in your LIB. :blink:

Maybe you don't have 'doCreateItem' function, check your LIB and if is not there, is that :p
 
Im using TFS 0.2.13, and when checking the lua functions, TFS do got this function o_O
 
Wel i rewrite your code and it looks like that:
Code:
function createItems(ids,count,pos)
--ids: {123,123...}
--count: {1,2,3,4...}
--pos: {{x=1...},{x=2..},...}
	if(#pos==#count and #count==#ids)then
		for i=1,#ids do
			doCreateItem(ids[i],count[i],tiles[i])
		end
		return true
	else
		debugPrint('Wrong count of elements in one of arrays')
		return false
	end
end

function onUse(cid, item, frompos, item2, topos)

local pos={{x=910, y=995, z=9}, {x=910, y=996, z=9}, {x=910, y=997, z=9}, 
{x=911, y=995, z=9}, {x=911, y=996, z=9}, {x=911, y=997, z=9},
{x=912, y=995, z=9}, {x=912, y=996, z=9}, {x=912, y=997, z=9}}
local ids={1492, 1492, 1492, 1492, 1492, 1492, 1492, 1492, 1355}
local count={1, 1, 1, 1, 1, 1, 1, 1, 1}

	if item.uid == 7882 and item.itemid == 1354 then
		createItems(ids,count,pos)
		doTransformItem(item.uid,item.itemid-1)
	elseif item.uid == 7882 and item.itemid == 1355 then
		doPlayerSendCancel(cid,"You can not use this object.")	
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	return 1
end

I have no idea why you want to do this:
Code:
	getwall1 = getThingPos(wall1)
	getwall2 = getThingPos(wall2)
	getwall3 = getThingPos(wall3)
	getwall4 = getThingPos(wall4)
	getwall5 = getThingPos(wall5)
	getwall6 = getThingPos(wall6)
	getwall7 = getThingPos(wall7)
	getwall8 = getThingPos(wall8)
	getwall9 = getThingPos(wall9)
and do not use it later? Unnecessary i think. And all these pos of walls are in one variable wall1. And that cause error i think.
 
ahh I will test that out! Thanks :p


sry for slightly inactivity, on vacation... :p
 
Tryed a script example, but it was from a XML server, I changed some values and tryed it out, etc GetThingFromPos to GetThingPos, but then I got another message:

Code:
[04/07/2008  19:25:50] Lua Script Error: [Action Interface] 
[04/07/2008  19:25:50] data/actions/scripts/overlord_stonebomb.lua:onUse

[04/07/2008  19:25:50] attempt to index a nil value
[04/07/2008  19:25:50] stack traceback:
[04/07/2008  19:25:50] 	[C]: in function 'doCreateItem'
[04/07/2008  19:25:50] 	data/actions/scripts/overlord_stonebomb.lua:23: in function <data/actions/scripts/overlord_stonebomb.lua:1>

Here is the script:
Code:
function onUse(cid, item, frompos, item2, topos)
	[b]wall1 = {x=910, y=995, z=9, stackpos=1}
	wall1 = {x=911, y=995, z=9, stackpos=1}
	wall1 = {x=912, y=995, z=9, stackpos=1}
	wall1 = {x=910, y=996, z=9, stackpos=1}
	wall1 = {x=910, y=997, z=9, stackpos=1}
	wall1 = {x=911, y=997, z=9, stackpos=1}
	wall1 = {x=912, y=997, z=9, stackpos=1}
	wall1 = {x=912, y=996, z=9, stackpos=1}
	wall1 = {x=911, y=996, z=9, stackpos=1}[/b]
	getwall1 = getThingPos(wall1)
	getwall2 = getThingPos([b]wall2[/b])
	getwall3 = getThingPos(wall3)
	getwall4 = getThingPos(wall4)
	getwall5 = getThingPos(wall5)
	getwall6 = getThingPos(wall6)
	getwall7 = getThingPos(wall7)
	getwall8 = getThingPos(wall8)
	getwall9 = getThingPos(wall9)

	if item.uid == 7882 and item.itemid == 1354 then
		doCreateItem(1492,1,wall1)
		doCreateItem(1492,1,[b]wall2[/b])
		doCreateItem(1492,1,wall3)
		doCreateItem(1492,1,wall4)
		doCreateItem(1492,1,wall5)
		doCreateItem(1492,1,wall6)
		doCreateItem(1492,1,wall7)
		doCreateItem(1492,1,wall8)
		doCreateItem(1355,1,wall9)
		doTransformItem(item.uid,item.itemid-1)
	elseif item.uid == 7882 and item.itemid == 1355 then
		doPlayerSendCancel(cid,"You can not use this object.")	
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	return 1
end

Any ideas?

This was the result when using this script:
resultscript.jpg

All the energy fields shoud be removed, and placed fire fields there instead, and the blue stone shoud be replaced with a red stone

You see now?

If not... you have only wall1 everywhere and later your checking for wall2 thing, which doesnt exist.

----
Oh and btw, I dont see use for this:
Code:
	getwall1 = getThingPos(wall1)
	getwall2 = getThingPos(wall2)
	getwall3 = getThingPos(wall3)
	getwall4 = getThingPos(wall4)
	getwall5 = getThingPos(wall5)
	getwall6 = getThingPos(wall6)
	getwall7 = getThingPos(wall7)
	getwall8 = getThingPos(wall8)
	getwall9 = getThingPos(wall9)
You can delete it.
 
Back
Top