well.. changing to active for both entities worked on the first test run, nada on the 2nd and 3rd... added a distance check in the test block and still nothing. Removed the distance check, still no movement. Added my entire script and got a new intermittent lua error of nil value on line 73 . I'll post my entire script below, but I'm starting to think the lua gods hate me
line 73 error line:
if GetDistance(40,350) <= 14 and PlayerDist < 180 and text_finished == 1 then
entire code for character chad:
local text_lines = {}
local text_finished = 0
function chad_dialog1a_init_name(e,name)
weapon_name[e] = name
end
function chad_dialog1a_main(e)
PlayerDist = GetPlayerDistance(e)
Hide(37)
Spawn(38)
if PlayerDist < 180 and weapon_name[e] == "chad" and text_finished == 0 then
local text_lines_num = 4 -- change to number of text lines.
text_lines[1] = "Welcome to Justice recruit. I'm Chad and"
text_lines[2] = "I've been ordered to give you some combat training.'"
text_lines[3] = "Please meet me at the firing range"
text_lines[4] = "behind the supply building..."
local y = 40
for i = 1, text_lines_num, 1 do
TextCenterOnXColor(50,y,1,text_lines[i], 255,255,0)
y = y + 2
i_num = i + 1
end
if i_num >= text_lines_num then
Prompt ("Press [E] to finish")
if g_KeyPressE > 0 then
Hide(38)
text_finished = 1
end
end
end
if text_finished == 1 and weapon_name[e] == "chad" then
EntObjNoflower = 350 -- flower entity's ID to move AI to
EntObjNo = g_Entity[e]['obj'] -- AI soldier entity number
ai_start_x[e] = g_Entity[EntObjNoflower]['x'] -- flower object's X
ai_start_z[e] = g_Entity[EntObjNoflower]['z'] -- flower object's Z
AISetEntityControl(EntObjNo,AI_MANUAL)
CharacterControlUnarmed(e)
if GetDistance(40,350) > 120 then
SetCharacterToRun(e)
elseif GetDistance(40,350) < 120 then
SetCharacterToWalk(e)
end
AIEntityGoToPosition(EntObjNo,ai_start_x[e],ai_start_z[e])
-- sporadically chad rotates to or ignores player instead of moving to x/z here
end
if GetDistance(40,350) <= 14 and PlayerDist < 180 and text_finished == 1 then ----- nil error here
local text_lines_num = 14 -- change to number of text lines.
text_lines[1] = "Okay, Let's get started with your basic weapons."
text_lines[2] = "You can cyle through your weapons using the middle mouse button.'"
text_lines[3] = "If you haven't already, arm your pistol now with"
text_lines[4] = "the middle mouse wheel..."
text_lines[5] = " "
text_lines[6] = "Now, you can holster your weapon with the number 0 key."
text_lines[7] = "and use the middle mouse wheel to arm yourself again."
text_lines[8] = "Try this now... "
text_lines[9] = " "
text_lines[10] = "Great! You can hold your right mouse button down to"
text_lines[11] = "use your gun's sights. After pressing the [E] key,"
text_lines[12] = "pick a target in the range and shoot it"
text_lines[13] = "while aiming with your right mouse button held down,"
text_lines[14] = "and clicking the left mouse button to fire."
y = 40
for i = 1, text_lines_num, 1 do
TextCenterOnXColor(50,y,1,text_lines[i], 255,255,0)
y = y + 2
i_num = i + 1
end
if i_num >= text_lines_num then
Prompt ("Press [E] to continue")
if g_KeyPressE > 0 then
text_finished = 2
end
end
end
end
function GetDistance(e,v)
if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then
local disx = g_Entity[e]['x'] - g_Entity[v]['x']
local disz = g_Entity[e]['z'] - g_Entity[v]['z']
local disy = g_Entity[e]['y'] - g_Entity[v]['y']
return math.sqrt(disx^2 + disz^2 + disy^2)
end
end
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram