Scripts / [SOLVED] pb to make a very simple killquests.lua example

Author
Message
Brother
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location:
Posted: 2nd Apr 2023 14:23
Hi,
I'm new to Lua scripting and I have a -probably simple- problem in the killquests.lua script.

I'm trying to make a simple scene to do different tests and I can't make it.

In my scene I included:
a starting position
a quest giver (numbered 1)
a house to avoid zombies look at me and the quest giver
2 zombies numbered 3 and 4

I followed the instructions in youtube video post #27 regarding building quests with killquests.lua

I changed the quest giver AI to killquests.lua
I looked carefully at the number of entities

When I test, compile progress but finally I have error 501.

I'm frustrated because this is the simplest example I've made and I can't seem to get it to work.

Is it possible that it comes from the length of the directory name?
(d:\steam\steamapps\common\GameGuru\Files\scriptbank\killquests.lua)

Thanks in advance.

I am attaching several elements (image and lua script)
for information I put pointer.png in two directories, scriptbank and stuff to do several tests.

cheers
I am not english so xcuse my syntax, grammary or anything else wich could occure some ununderstanding

The author of this post has marked a post as an answer.

Go to answer

Attachments

Login to view attachments
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Apr 2023 15:33 Edited at: 3rd Apr 2023 15:34
sounds like you are missing the image(s) or they are not in the correct path for the script to find them.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Brother
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location:
Posted: 3rd Apr 2023 17:20
Hi Smallg (very honored to have your answer, you are a reference for me).

Yes, logically that must be the reason, but when I look at my tree structure with windows explorer, it looks correct to me.

So I will create a file with a unique name and watch where it is created.

Thank you for putting me back on the path of logic.

I'll check and let you know what happens.

Have a nice evening Smallg.

SYS.
I am not english so xcuse my syntax, grammary or anything else wich could occure some ununderstanding
PM
Brother
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location:
Posted: 3rd Apr 2023 21:20
Thanks Smallg,

With your help I managed to progress.

I had read a post saying that scripts start in the "scriptbank" directory
But that's wrong, they start their execution in the "Files" directory.

Once the path was corrected the script worked better and I keep control of GameGuru, thank you Smallg!

I now come to another error raised by the procedure addQuestTarget(

Yet I have specified the entity numbers of the two zombies.

Do I have to change the first lines of the killquests.lua program to declare the targets?

Thanks for any help.

SYS
I am not english so xcuse my syntax, grammary or anything else wich could occure some ununderstanding
PM
Brother
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location:
Posted: 3rd Apr 2023 21:23 Edited at: 4th Apr 2023 07:22
Error message:

files

killquests.lua attached to my questgiver
quests = {}
questTargets = {}
questCounter = 0

maxTargets = 10

currentQuest = 0

pointerImage = 0
pointerSprite = 0

mouseOn = 0

haveBuiltQuests = 0
questBuildDelay = 0

--[[
Quest modes:
inactive
offer
active
returning
handingIn
complete
--]]

function killquests_init(e)
--[[
-- My changes
file = io.open("test20230403.txt", "w");
-- sets the default output file
io.output(file)
io.write("\n")
io.close(file)
-- le fichier est créé dans:
-- D:\steam\steamapps\common\Game Guru\Files
-- end of my changes
--]]
-- My wrong line
-- pointerImage = LoadImage ( "pointer.png" )
-- correction
pointerImage = LoadImage ( "scriptbank\\stuff\\pointer.png" )
pointerSprite = CreateSprite ( pointerImage )

SetSpriteSize ( pointerSprite , 5 , -1 )
SetSpriteOffset ( pointerSprite , 2, 0)
end

function killquests_main(e)

if haveBuiltQuests == 0 then
questBuildDelay = questBuildDelay + 1
if questBuildDelay > 1 then
haveBuiltQuests = 1
quest = newQuest(1,"Greetings, I am Bernard II of Lardtown. Son of Bernard I of Potato." ,
"There are soldiers to the north east bothering me," ,
"Please kill them for me, I will pay you well." ,
"Thank you, You have done this land a great service" ,
"Now, about your reward...",
"I'm afraid I may of slightly oversold the whole rewards thing, sorry.")

addQuestTarget(quest,3)
addQuestTarget(quest,4)

[[--
quest = newQuest(7,"Hello there adventurer, I am Boris, brother of Bernard II" , "I am heading west but some nasty looking zombies block my path." , "You look like you could take care of them. Would you help me?." , "You have my eternal thanks for your bravery." , "If I had any money I would certainly pay you well.", "Unfortunately all I can offer is my thanks. Farewell.")
addQuestTarget(quest,8)
addQuestTarget(quest,9)
addQuestTarget(quest,10)
addQuestTarget(quest,11)

quest = newQuest(127,"Hello, please kill the annoying wizard guys" , "I am just a zombie who is hungry" , "I like Star Wars." , "Thank you, those guys were very annoying" , "Now I can go kill everyone in the town", "Merry Christmas")
addQuestTarget(quest,125)
addQuestTarget(quest,126)
]]

end
end

if mouseOn == 1 then
SetSpritePosition ( pointerSprite , g_MouseX , g_MouseY )
else
SetSpritePosition ( pointerSprite , 200 , 200 )
end

if currentQuest > 0 then
checkQuest()
end

if currentQuest == 0 or quests[currentQuest]['mode'] == "returning" then
for c = 1, questCounter do
if quests[c]['mode'] == "inactive" or quests[c]['mode'] == "returning" then
if GetPlayerDistance(quests[c]['giver']) < 100 then
Prompt ( "Press E To talk")
RotateToPlayer(quests[c]['giver'])
if g_KeyPressE == 1 then
if quests[c]['mode'] == "inactive" then
quests[c]['mode'] = "offer"
else
quests[c]['mode'] = "handingIn"
end
currentQuest = 0
ActivateMouse()
mouseOn = 1
end
end
elseif quests[c]['mode'] == "offer" then
HideHuds()
SetPlayerWeapons(0)
Panel(25,40,75,60)
TextCenterOnXColor(50,45,1,quests[c]['text1'],100,255,100)
TextCenterOnXColor(50,50,1,quests[c]['text2'],100,255,100)
TextCenterOnXColor(50,55,1,quests[c]['text3'],100,255,100)
Panel(30,60,40,70)
Panel(60,60,70,70)

buttonOver = 0

if g_MouseX > 30 and g_MouseX < 40 and g_MouseY > 60 and g_MouseY < 70 then
TextCenterOnXColor(35,65,1,"Accept",255,255,0)
buttonOver = 1
else
TextCenterOnXColor(35,65,1,"Accept",150,150,0)
end
if g_MouseX > 60 and g_MouseX < 70 and g_MouseY > 60 and g_MouseY < 70 then
TextCenterOnXColor(65,65,1,"Decline",255,0,0)
buttonOver = 2
else
TextCenterOnXColor(65,65,1,"Decline",150,0,0)
end

if g_MouseClick == 1 then
ShowHuds()
SetPlayerWeapons(1)
if buttonOver == 1 then
quests[c]['mode'] = "active"
DeactivateMouse()
mouseOn = 0
currentQuest = c
end
if buttonOver == 2 then
quests[c]['mode'] = "inactive"
DeactivateMouse()
mouseOn = 0
end
end
elseif quests[c]['mode'] == "handingIn" then
HideHuds()
SetPlayerWeapons(0)
currentQuest = 0
Panel(25,40,75,60)
TextCenterOnXColor(50,45,1,quests[c]['text4'],100,255,100)
TextCenterOnXColor(50,50,1,quests[c]['text5'],100,255,100)
TextCenterOnXColor(50,55,1,quests[c]['text6'],100,255,100)
Panel(45,60,55,70)

buttonOver = 0

if g_MouseX > 45 and g_MouseX < 55 and g_MouseY > 60 and g_MouseY < 70 then
TextCenterOnXColor(50,65,1,"Complete",255,255,0)
buttonOver = 1
else
TextCenterOnXColor(50,65,1,"Complete",150,150,0)
end


if g_MouseClick == 1 then
ShowHuds()
SetPlayerWeapons(1)
if buttonOver == 1 then
quests[c]['mode'] = "complete"
DeactivateMouse()
mouseOn = 0
end
end

end
end
end

end

function checkQuest()

count = 0

for c = 1, maxTargets do
if questTargets[currentQuest][c] ~= nil then
if g_Entity[questTargets[currentQuest][c]]['health'] > 0 then
count = count + 1
end
end
end

Panel ( 5 , 5 , 25 , 15)

if count == 0 then
TextCenterOnXColor(15,10,1,"Return to quest giver",255,255,0)
if quests[currentQuest]['mode'] == "active" then
quests[currentQuest]['mode'] = "returning"
end
else
TextCenterOnXColor(15,10,1, count .. " targets remain",255,100,100)
end

end

function newQuest( questGiver , text1, text2, text3, text4 , text5, text6)
questCounter = questCounter + 1
quests[questCounter] = {}
quests[questCounter]['mode'] = "inactive"
quests[questCounter]['giver'] = questGiver
quests[questCounter]['text1'] = text1
quests[questCounter]['text2'] = text2
quests[questCounter]['text3'] = text3
quests[questCounter]['text4'] = text4
quests[questCounter]['text5'] = text5
quests[questCounter]['text6'] = text6
return questCounter
end

function addQuestTarget(questID , targetID)

if questTargets[questID] == nil then
questTargets[questID] = {}
end

for c = 1, maxTargets do
if questTargets[questID][c] == nil then
questTargets[questID][c] = targetID
return
end
end
end

function setActiveQuest(questID)
end

function setActiveQuestMode(questID)
end
I am not english so xcuse my syntax, grammary or anything else wich could occure some ununderstanding

Attachments

Login to view attachments
PM
Brother
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location:
Posted: 4th Apr 2023 13:56
Hi,

Maybe there is a problem if there is only one quest.
Maybe my example is too minimal.

So I'm going to try again with the 3 quests in the example.

I have reviewed the video and the lines at the beginning are not to be filled in.
So I take the example given on the video in the strict sense.
(by correcting the directory)

I will let you know as soon as I finish the tests.

THANKS.
I am not english so xcuse my syntax, grammary or anything else wich could occure some ununderstanding
PM
Brother
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location:
Posted: 4th Apr 2023 20:12 Edited at: 5th Apr 2023 01:24
This post has been marked by the post author as the answer.
Thank you smallg, now I can continue my projects.

I am not english so xcuse my syntax, grammary or anything else wich could occure some ununderstanding

Attachments

Login to view attachments
PM

Login to post a reply

Server time is: 2024-04-24 11:39:00
Your offset time is: 2024-04-24 11:39:00