Thanks to both of you. Sorry it took me so long to reply. Life got in the way of working on my game!
Totally worked to use the TextCenterOnX command (function? I still don't understand the difference) but I found I needed to add some timers for some simple responses. I got it up and running. Works great now. I feel like I can now have pretty complex conversations with NPCs now! Awesome.
Here's the script. I don't know who wrote it or I would give credit! My modifications.
--Initiates a branched conversation with NPC Character
--Need to be in close proximity to player to initiate
--Player uses m and n keys to select a response
local convo = {}
local timer = {}
local timed = {}
local started = {}
local response = {}
function conversation2_init(e)
Include("ai_cover.lua")
convo[e] = 0
timer[e] = 0
timed[e] = 0
started[e] = 0
response[e] = 0
end
function conversation2_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 then
RotateToPlayer(e)
if convo[e] == 0 then
TextCenterOnX(50,65,3,"Hi. I'm Tim. You survived, huh?",2000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) > timed[e] + 3000 then
convo[e] = 1
timer[e] = 0
end
end
if convo[e] == 1 then
TextCenterOnX(50,64,3,"m- Yes, just barely.")
TextCenterOnX(50,67,3,"n- Yes, but I need some information.")
if g_InKey == "m" then
convo[e] = 100
timer[e] = 0
timed[e] = 0
response[e] = 1
elseif g_InKey == "n" then
convo[e] = 100
timer[e] = 0
timed[e] = 0
response[e] = 2
end
end
if convo[e] == 21 then
TextCenterOnX(50,64,3,"m- Not too bad.")
TextCenterOnX(50,67,3,"n -Yes, it's been tough.")
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) > timed[e] + 500 then
if g_InKey == "m" then
convo[e] = 100
timer[e] = 0
timed[e] = 0
response[e] = 3
elseif g_InKey == "n" then
convo[e] = 100
timer[e] = 0
timed[e] = 0
response[e] = 4
end
end
end
if convo[e] == 22 then
TextCenterOnX(50,64,3,"m- Why arent people fighting against the Militia?")
TextCenterOnX(50,67,3,"n- What should I be aware of?")
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) > timed[e] + 500 then
if g_InKey == "m" then
convo[e] = 100
timer[e] = 0
timed[e] = 0
response[e] = 5
elseif g_InKey == "n" then
convo[e] = 100
timer[e] = 0
timed[e] = 0
response[e] = 6
end
end
end
if response[e] == 1 then
TextCenterOnX(50,65,3,"Tim: Well done. Have you had a hard time of it?",3000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) - timed[e] > 3000 then
convo[e] = 21
response[e] = 0
end
end
if response[e] == 2 then
TextCenterOnX(50,65,3,"Tim: What do you want to know?",3000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) - timed[e] > 3000 then
convo[e] = 22
response[e] = 0
end
end
if response[e] == 3 then
TextCenterOnX(50,65,3,"Tim: Glad to hear it. Many people are counting on you.",4000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) - timed[e] > 3000 then
response[e] = 0
end
end
if response[e] == 4 then
TextCenterOnX(50,65,3,"Well, it is going to get a little harder up the path. Safe travels!", 4000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) - timed[e] > 3000 then
response[e] = 0
end
end
if response[e] == 5 then
TextCenterOnX(50,65,3,"I agreed to abide by their law so I could study the area. I'm not proud of that.", 5000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) - timed[e] > 4000 then
response[e] = 0
end
end
if response[e] == 6 then
TextCenterOnX(50,65,3,"Tim: Be prepared. Mutants in the next valley. The radioactivity has . . . changed them.", 4000)
if timer[e] == 0 then
timed[e] = GetTimer(e)
timer[e] = 1
end
if GetTimer(e) - timed[e] > 3000 then
response[e] = 0
end
end
end
end
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM