I want to make NPC which will heal player under 65 hp and also he will delete conditions such poisonous. Here is the code:
And error message in ot console:
Signed,
Rudixx
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()
npcHandler:onThink()
talk = math.random(1,40)
if talk == 1 then
selfSay("Long life to the king!")
end
end
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return FALSE
end
if msgcontains(msg, 'heal') and getCreatureHealth(cid) < 65 then
selfSay("You're hurt, let me heal you.")
heal = 65 - getCreatureHealth(cid)
doCreatureAddHealth(cid, heal)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) >= 65 then
selfSay("You aren\'t looking really bad, |PLAYERNAME|. I only help in cases of real emergencies. Raise your health simply by eating food.")
end
end
return TRUE
end
keywordHandler:addKeyword({'food'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Food is very important for your health. If you are hurt in a fight with a monster, select \'Use\' on food such as cheese, ham or meat to eat it. This will slowly refill yourhealth.'})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Monsters are a constant threat to this village. You would tremendously help us by fighting them, starting with rats in the sewers, then turning to spiders or wolves.'})
keywordHandler:addKeyword({'rats'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A single rat doesn\'t pose a grave danger to you, but be careful not to get cornered by many of them. They could still kill you.'})
keywordHandler:addKeyword({'kill'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'If you get killed, you will revive in this temple. However, you will lose experience and also equipment, which can be quite painful. Take good care of yourself!'})
keywordHandler:addKeyword({'sewers'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The sewers are right below this village. North of this temple, you find a sewer grate which leads down, but there are also many small huts in the village which areconnected to the sewers.'})
keywordHandler:addKeyword({'spiders'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'If you face spiders, beware of the poisonous ones. If you are poisoned, you will constantly lose health. Come to me and I\'ll heal you from poison.'})
keywordHandler:addKeyword({'wolves'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Wolves can only be found outside of the village. If you want to know where their dens are, best talk to Dallheim or Zerbrus at the bridges.'})
keywordHandler:addKeyword({'dallheim'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'May the gods bless our loyal guardsmen! Day and night they stand watch on our bridges, ensuring that it is not passed by dangerous monsters!'})
keywordHandler:addKeyword({'zerbrus'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'May the gods bless our loyal guardsmen! Day and night they stand watch on our bridges, ensuring that it is not passed by dangerous monsters!'})
keywordHandler:addKeyword({'poisonous'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Poison is very dangerous! Don\'t ever drink green liquids, they are poisonous and will make you lose health!'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'How can I help you? I can tell you about specific citizens if you tell me their name. I can also give you general hints about Tibia.'})
keywordHandler:addKeyword({'citizens'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Only a few people live in our village, most of them being merchants. You can either ask them for a trade or about various other topics, like the names of other citizens, their job or Tibia in general.'})
keywordHandler:addKeyword({'merchants'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You can buy and sell goods from merchants. To do so, simply talk to them and ask them for a trade. They will gladly show you their offers and also the things they buy from you.'})
keywordHandler:addKeyword({'trade'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I don\'t have any goods for trade, but if you ask one of the merchants, he or she will gladly show you what you can buy or sell.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Me? Oh, I am just a humble monk. Ask me if you need help or healing.'})
keywordHandler:addKeyword({'monk'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sacrifice my life to serve the good gods of Tibia and help newcomers to this world.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'That\'s where we are. The world of Tibia. In a village called Rookgaard, to be precise, with many monsters, quests and citizens around.'})
keywordHandler:addKeyword({'rookgaard'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The gods have chosen this isle as the point of arrival for the newborn souls. The citizens will help you if you ask them.'})
keywordHandler:addKeyword({'quests'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, I can handle my tasks myself, thank you. If you are looking for something to do, you should listen to the local citizens and ask them for quests. You could also help usfight monsters.'})
keywordHandler:addKeyword({'gods'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'They created Tibia and all life on it. Visit our academy and learn about them.'})
keywordHandler:addKeyword({'academy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The academy is just to the north of here. Talk to Seymour, the teacher, if you want to learn more things about the world of Tibia. Also, you can try out a few basicthings in the cellar of the academy.'})
keywordHandler:addKeyword({'seymour'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Seymour is a loyal follower of the king and a teacher in the academy.'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Well, King Tibianus of course. The island of Rookgaard belongs to his kingdom.'})
keywordHandler:addKeyword({'hints'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'If you don\'t know the meaning of an icon on the right side, move the mouse cursor on it and wait a moment.'})
keywordHandler:addKeyword({'cipfried'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yes? How can I help you?'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My name is Cipfried.'})
keywordHandler:addKeyword({'willie'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Willie is a farmer, just like his cousin Billy. His farm is located to the left of the temple. You can buy and sell food there.'})
keywordHandler:addKeyword({'billy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'He is a farmer, just like his cousin Willie. He doesn\'t talk to everybody, though.'})
keywordHandler:addKeyword({'gold'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You can earn a fair amount of gold by fighting monsters and picking up the things they carry. Many citizens are buying some of that loot, simply ask around.'})
keywordHandler:addKeyword({'equipment'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You can buy equipment from the merchants in this village once you earned some gold. Some monsters also carry equipment pieces with them.'})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
And error message in ot console:
Code:
Cipfried.lua:31: '<eof>' expected near 'end'
Signed,
Rudixx