• 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 Need someone to look over my peice of code

Gaddhuve

Member
Joined
May 6, 2011
Messages
76
Solutions
1
Reaction score
19
Hi guys!

I have been trying to play around some in LUA scripting to make me a start of a cut scene code. However this peice of code does not work.

The idea is that when a player walk on a tile two NPCs will appear and start talking. I use the addEvent function for the delay between the NPC who speaks. The problem is once the player steps on the tile two NPCs appear and they say their lines all at once, so the delay function does not work the way I have set it up. The doRemoveCreature works fine but not the doCreatureSay

Lua:
local t = {

	text = 'Reincarnated. Finally!',
	text1 = 'Arise my warrior!',

	text2 = 'Stop this madness!',
	text3 = 'We are too late...',	
-------------------------------------------------
	npc = 'Ferumbras', 
	storage = 667800, 
	pos = {x=1017, y=1023, z=7},
-------------------------------------------------
	npc1 = 'Fordring',
	pos1 = {x=1024, y=1022, z=7}
	
}
 
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getPlayerStorageValue(cid, t.storage) == -1 then
		setPlayerStorageValue(cid, t.storage, 1)		
		
	local v = doCreateNpc(t.npc, t.pos)
		doCreatureSay(v, t.text, TALKTYPE_SAY)
		addEvent(doCreatureSay(v, t.text1, TALKTYPE_SAY), 5000, v)
		addEvent(doRemoveCreature, 9000, v)
		
		
	local f = doCreateNpc(t.npc1, t.pos1)
		addEvent(doCreatureSay(f, t.text2, TALKTYPE_SAY), 3000, f)		
		addEvent(doCreatureSay(f, t.text3, TALKTYPE_SAY), 6500, f)	
		addEvent(doRemoveCreature, 9000, f)
		
		
	end
end

So basically. Does anyone know how to set up the addEvent with the doCreatureSay function?

Thanks for reading!
 
Lua:
--Local v = Ferumbras // Local f = Fordring--
--Player Step On Tile // Ferumbras apears.. Says text and text1.. Dissapears.
-- Fordring appears // says text2 and text3.. dissapears..

local t = {
 
	--Text To Say--
	text = 'Reincarnated. Finally!', -- Npc 1
	text1 = 'Arise my warrior!', -- Npc 1
	text2 = 'Stop this madness!', -- Npc 2
	text3 = 'We are too late...', -- Npc 2
	
	
	-- NPC 1 --
	npc = 'Ferumbras', 
	storage = 667800, 
	pos = {x=1017, y=1023, z=7},
	
	-- NPC 2 --
	npc1 = 'Fordring',
	pos1 = {x=1024, y=1022, z=7},
 
}
 
			--Storage and Stepping On The Tile--
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getPlayerStorageValue(cid, t.storage) == -1 then
		setPlayerStorageValue(cid, t.storage, 1)		
 
 
			--Creating NPC 1--
	local v = doCreateNpc(t.npc, t.pos)
		doCreatureSay(v, t.text, TALKTYPE_SAY)
			addEvent(doCreatureSay(v, t.text1, TALKTYPE_SAY), 5000, v)
			addEvent(doRemoveCreature, 9000, v)
 
			--Creating NPC 2--
	local f = doCreateNpc(t.npc1, t.pos1)
			addEvent(doCreatureSay(f, t.text2, TALKTYPE_SAY), 3000, f)		
			addEvent(doCreatureSay(f, t.text3, TALKTYPE_SAY), 6500, f)	
			addEvent(doRemoveCreature, 9000, f)
		
		return true
	end
end
 
Appreciate the help but something is not right. So I tried making a bit simpler script where just one NPC would pop up and say two texts with a certain delay. Came up with this:

Lua:
local t = {
	npc = 'Alma', 
	text = 'Welcome home.',
	text2 = 'How was your day?',	
	storage = 667879, --- When stepped on tile storage is added.
	pos = {x=1019, y=1027, z=6}
}
 
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getPlayerStorageValue(cid, t.storage) == -1 then
		setPlayerStorageValue(cid, t.storage, 1)
		local v = doCreateNpc(t.npc, t.pos)
		doCreatureSay(v, t.text, TALKTYPE_SAY)
		addEvent(doCreatureSay(t.text1, TALKTYPE_SAY), 15000, v)		
		addEvent(doRemoveCreature, 22000, v)
	end
end

When running the script the NPC pops up, says 'text' and then the 'text2' right after.

In my console I get this:
Code:
lua Scrupt Error: [MoveEvents Interface]
data/movements/cutscene/scene2.lua:onStepIn
luaDoCreatureSay<>. Creature not found
luaAddEvent<>. Callback parameter should be a function
 
Last edited:
Back
Top