• 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!

Bomberman

taha94

New Member
Joined
Jun 12, 2009
Messages
168
Reaction score
0
Location
Sweden
I have a Pacman script that keeps bugging is there anyone who can help me??

Error in console
Code:
[04/08/2012 18:43:49] [Error - MoveEvents Interface] 
[04/08/2012 18:43:49] data/movements/scripts/pacman.lua:onStepIn
[04/08/2012 18:43:49] Description: 
[04/08/2012 18:43:49] data/movements/scripts/pacman.lua:47: attempt to call global 'isCreatureInArea' (a nil value)
[04/08/2012 18:43:49] stack traceback:
[04/08/2012 18:43:49] 	data/movements/scripts/pacman.lua:47: in function <data/movements/scripts/pacman.lua:20>

This is what i have in movements.xml
Code:
<movevent type="StepIn" actionid="5301" event="script" value="pacman.lua" />
 <movevent type="StepIn" actionid="7392" event="script" value="pacman.lua" />

And my pacman script

PHP:
-- Pacman script: Controller [TGY] 
pressedTiles = {}
gameStarted = false
dif = 1

local function pacmanCounter(text, start, col, dif)
	if start then 
		gameStarted = true
		doCreateMonster("Pacman Ghost", {x = 270, y = 2019, z = 9})
		if dif > 1 then
			doCreateMonster("Pacman Ghost", {x = 280, y = 2019, z = 9}) 
		end
		if dif > 2 then
			doCreateMonster("Pacman Ghost", {x = 275, y = 2019, z = 9}) 
		end
	end
	doSendAnimatedText({x = 275, y = 2024, z = 9}, text, col)
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if false == isPlayer(cid) then
		return
	end
	
	if item.actionid == 5301 and item.itemid == 426 then
		-- HANDLE TILE
		if not gameStarted then
			--doPlayerPopupFYI(cid, "x")
			doTeleportThing(cid, fromPosition, true)
			return true
		end
		doTransformItem(item.uid, 425)
		table.insert(pressedTiles, position)
		local cnt = #pressedTiles
		doSendAnimatedText(position, (cnt).."/84", TEXTCOLOR_GREEN)
		if cnt > 83 then
			doTeleportThing(cid, {x = 271, y = 2016, z = 8}, true)
			doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
			local prize = 5
			if dif == 2 then prize = 10 end
			if dif == 3 then prize = 20 end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Game Tokens!")
			doPlayerAddItem(cid,6527,prize)
		end
	elseif item.actionid == 7392 then
		-- HANDLE JOINING PERSON
		local c = isCreatureInArea({x = 270, y = 2019, z = 9},{x = 280, y = 2029, z = 9}) -- Getting crss inside
		for _,v in pairs(c) do
			if isPlayer(v) then
				doTeleportThing(cid, fromPosition, true)
				return true
			end
		end
		-- Nobody is inside, check ticket/pick it - check exhaust first
		--doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
		if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
			doTeleportThing(cid, fromPosition, true)
			doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
			return true
		end
		if getPlayerItemCount(cid, 6527) < 1 then
			doTeleportThing(cid, fromPosition, true)
			doPlayerPopupFYI(cid, "You need 1 Game Token to play.")
			return true
		end
		doPlayerRemoveItem(cid, 6527, 1)
		setPlayerStorageValue(cid, 7948, os.time() + 900)
		-- Set difficulity variabele
		dif = 1
		if item.uid == 7396 then
			dif = 2
		elseif item.uid == 7397 then
			dif = 3
		end
		-- Clean the area and reset the tiles now
		for _,v in pairs(c) do
			doRemoveCreature(v)
		end
		for _,v in pairs(pressedTiles) do
			doItemSetAttribute(doCreateItem(426, v),"aid", 5301)
		end
		pressedTiles = {}
		gameStarted = false
		doTeleportThing(cid, {x = 275, y = 2024, z = 9}, true)
		pacmanCounter("3", false, TEXTCOLOR_RED, dif)
		addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
		addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
		addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
	end


	return true
end
 
put this in data\lib file 050-function.lua

Lua:
function isCreatureInArea(fromPos, toPos)
	local t = {}
	for z=fromPos.z, toPos.z do
		for y=fromPos.y, toPos.y do
			for x=fromPos.x, toPos.x do
				local v = getTopCreature({x=x,y=y,z=z})
				if v.itemid == 1 and table.find({1,2,3}, v.type) then
					table.insert(t, v.uid)
				end
			end
		end
	end
	return t
end

reb + :p
 
Yeah thanks it works, but when i walk on the tiles they dont get pressed in, so it's hard to know wich tiles are left to step on. Do you know how to fix that?
 
Last edited:
Bump!! When i walk on the tiles, they do not get pressed in. Also you can walk on a tile multiple times..
A normal pacman game has like 80 tiles and you have to walk on them.. On mine you can walk on 2 tiles 10 times and it will be 80 automatic.
 
Last edited:
Try to exchange
Lua:
        doTransformItem(item.uid, 425)
        table.insert(pressedTiles, position)

With something like that
Lua:
for i = 1, X do
    pos = {x=x+i, y=y, z=z, stackpos=0}
    table.insert(tiles, pos)
end
--and then
doTransformItem(getThingfromPos(tiles[i]).uid, 426)
table.insert(tiles, item.itempos)
 
So something like this?

PHP:
-- Pacman script: Controller [TGY] 
pressedTiles = {}
gameStarted = false
dif = 1

local function pacmanCounter(text, start, col, dif)
	if start then 
		gameStarted = true
		doCreateMonster("Pacman Ghost", {x = 270, y = 2019, z = 9})
		if dif > 1 then
			doCreateMonster("Pacman Ghost", {x = 280, y = 2019, z = 9}) 
		end
		if dif > 2 then
			doCreateMonster("Pacman Ghost", {x = 275, y = 2019, z = 9}) 
		end
	end
	doSendAnimatedText({x = 275, y = 2024, z = 9}, text, col)
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if false == isPlayer(cid) then
		return
	end
	
	if item.actionid == 5301 and item.itemid == 426 then
		-- HANDLE TILE
		if not gameStarted then
			--doPlayerPopupFYI(cid, "x")
			doTeleportThing(cid, fromPosition, true)
			return true
		end
		doTransformItem(item.uid, 425)
		table.insert(pressedTiles, position)
		local cnt = #pressedTiles
		doSendAnimatedText(position, (cnt).."/84", TEXTCOLOR_GREEN)
	for i = 1, X do
    pos = {x=x+i, y=y, z=z, stackpos=0}
    table.insert(tiles, pos)
end
--and then
doTransformItem(getThingfromPos(tiles[i]).uid, 426)
table.insert(tiles, item.itempos)
		if cnt > 83 then
			doTeleportThing(cid, {x = 271, y = 2016, z = 8}, true)
			doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
			local prize = 5
			if dif == 2 then prize = 10 end
			if dif == 3 then prize = 20 end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Crystal coincs!")
			doPlayerAddItem(cid,2160,prize)
		end
	elseif item.actionid == 7392 then
		-- HANDLE JOINING PERSON
				local c = isCreatureInArea({x = 270, y = 2019, z = 9},{x = 280, y = 2029, z = 9}) -- Getting crss inside
		for _,v in pairs(c) do
			if isPlayer(v) then
				doTeleportThing(cid, fromPosition, true)
				return true
			end
		end
		-- Nobody is inside, check ticket/pick it - check exhaust first
		--doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
		if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
			doTeleportThing(cid, fromPosition, true)
			doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
			return true
		end
		if getPlayerItemCount(cid, 2160) < 5 then
			doTeleportThing(cid, fromPosition, true)
			doPlayerPopupFYI(cid, "You need 1 cc to play.")
			return true
		end
		doPlayerRemoveItem(cid, 2160, 1)
		setPlayerStorageValue(cid, 7948, os.time() + 900)
		-- Set difficulity variabele
		dif = 1
		if item.uid == 7396 then
			dif = 2
		elseif item.uid == 7397 then
			dif = 3
		end
		-- Clean the area and reset the tiles now
		for _,v in pairs(c) do
			doRemoveCreature(v)
		end
		for _,v in pairs(pressedTiles) do
			doItemSetAttribute(doCreateItem(426, v),"aid", 5301)
		end
		pressedTiles = {}
		gameStarted = false
		doTeleportThing(cid, {x = 275, y = 2024, z = 9}, true)
		pacmanCounter("3", false, TEXTCOLOR_RED, dif)
		addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
		addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
		addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
	end


	return true
end
 
Last edited:
[11/02/2013 18:29:33] [Error - TalkAction Interface]
[11/02/2013 18:29:34] In a timer event called from:
[11/02/2013 18:29:34] data/talkactions/scripts/bomb.lua:eek:nSay
[11/02/2013 18:29:34] Description:
[11/02/2013 18:29:34] (luaDoTileQueryAdd) Tile not found

[11/02/2013 18:29:35] [Error - TalkAction Interface]
[11/02/2013 18:29:35] In a timer event called from:
[11/02/2013 18:29:35] data/talkactions/scripts/bomb.lua:eek:nSay
[11/02/2013 18:29:35] Description:
[11/02/2013 18:29:35] (luaDoTileQueryAdd) Tile not found

How Can fix it, when i use z
 
Back
Top