I'm trying to make a turret fire at you only if you stand up against it for a while. To this aim, I've decreased LockOnTime to 3.0, LockOnRange to 1.0, and some other tweaks:
these tell the AI how far away to target with each gun. you could also give the turret a slow projectile, and have it transition to zero damage, but I have a feeling you are making an LUA gun...
Re: Weapon ODF troubles
Posted: Sun May 23, 2010 1:12 pm
by Fiodis
myers73 wrote:you could also give the turret a slow projectile, and have it transition to zero damage, but I have a feeling you are making an LUA gun...
I have a feeling you're right....
Thanks for the ExtremeRange. It worked.
EDIT: But the lua code didn't. I may as well continue this thread rather than start a new one, as the issue pertains to the same weapon.
Hidden/Spoiler:
[code] getturretcoordinates = OnCharacterDispenseControllable(
function(dropper, thing)
if GetEntityClass(thing) == FindEntityClass("rep_bldg_inf_blueturret") then
SetObjectTeam(thing, 3)
local bluematrix = GetEntityMatrix(thing)
elseif GetEntityClass(thing) == FindEntityClass("rep_bldg_inf_goldturret") then
SetObjectTeam(thing, 3)
local goldmatrix = GetEntitMatrix(thing)
end
end
)
turretswitchandmatrixget = OnObjectDamage(
function(tobeteleported, teleporter)
if GetEntityClass(teleporter) == FindEntityClass("rep_bldg_inf_blueturret") then
local movedguy = GetCharacterUnit(tobeteleported)
SetEntityMatrix(movedguy, goldmatrix)
elseif GetEntityClass(teleporter) == FindEntityClass("rep_bldg_inf_goldturret") then
local movedguy = GetCharacterUnit(tobeteleported)
SetEntityMatrix(movedguy, bluematrix)
end
end
)[/code][/size]
I get this in the error log:
Hidden/Spoiler:
[code]Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `GetEntitMatrix' (a nil value)
stack traceback:
(none): in function <(none):60>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetEntityClass' (string expected, got nil)
stack traceback:
[C]: in function `GetEntityClass'
(none): in function <(none):72>
[/code]
I'm trying to make it so that when the player is shot by the gold turret, he's moved to the blue one, and vice versa. In-game, though, nothing happens when he's shot. I'm pretty sure I got the GetEntityClass part right....
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Sun May 23, 2010 2:30 pm
by myers73
GetEntityClass() wants a string and you are giving it a variable, at least I think that is the problem
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Sun May 23, 2010 2:37 pm
by Fiodis
Isn't that line supposed to check if teleporter's class is equal to rep_bldg_in_blueturret?
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Sun May 23, 2010 2:40 pm
by myers73
if so then it looks fine to me
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 24, 2010 3:58 pm
by CressAlbane
rep_bldg_in_blueturret
Is this supposed to be rep_bldg_inf_blueturret ?
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 24, 2010 4:09 pm
by myers73
i dont see that typo anywhere...
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 24, 2010 5:34 pm
by StarkillerMarek
Fiodis wrote:Isn't that line supposed to check if teleporter's class is equal to rep_bldg_in_blueturret?
Fiodis just wrote it in his post. He didn't make that mistake in the Lua.
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 24, 2010 5:36 pm
by CressAlbane
/slap
I feel dumb.
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 31, 2010 10:28 am
by Fiodis
Ah - could this be the problem?
myers73 wrote:can a local variable that is defined in one function be called in another function?
[RDH]Zerted wrote:Only if that other function was created in the same scope/level as the local variable. As an example, this is ok:
function sayHello()
local message = "Hello"
end
showMsg = function()
print("showMsg() says: ", message)
end
showMsg()
Would I have to put one function inside the other?
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 31, 2010 2:56 pm
by myers73
yes, just write it into one big function with the two functions inside of it. these are deployable turrets right? if not then just use an OnEnterRegion() teleport
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 31, 2010 6:19 pm
by Fiodis
This, however:
Hidden/Spoiler:
[code] combinedfunctions = OnCharacterDispenseControllable(
function(dropper, thing)
if GetEntityClass(thing) == FindEntityClass("rep_bldg_inf_blueturret") then
SetObjectTeam(thing, 3)
local bluematrix = GetEntityMatrix(thing)
elseif GetEntityClass(thing) == FindEntityClass("rep_bldg_inf_goldturret") then
SetObjectTeam(thing, 3)
local goldmatrix = GetEntitMatrix(thing)
end
end
turretswitchandmatrixget = OnObjectDamage(
function(tobeteleported, teleporter)
if GetEntityClass(teleporter) == FindEntityClass("rep_bldg_inf_blueturret") then
local movedguy = GetCharacterUnit(tobeteleported)
SetEntityMatrix(movedguy, goldmatrix)
elseif GetEntityClass(teleporter) == FindEntityClass("rep_bldg_inf_goldturret") then
local movedguy = GetCharacterUnit(tobeteleported)
SetEntityMatrix(movedguy, bluematrix)
end
end
)
)[/code][/size]
C:\BF2_ModTools\data_FTG\_BUILD\Common\..\..\..\ToolsFL\Bin\luac.exe: ..\..\common\scripts\FTG\FTGc_con.lua:93: `)' expected (to close `(' at line 83) near `turretswitchandmatrixget'
ERROR[scriptmunge scripts\FTG\FTGc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\FTG\FTGc_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
combinedfunctions = OnCharacterDispenseControllable(
function(dropper, thing)
if GetEntityClass(thing) == FindEntityClass("rep_bldg_inf_blueturret") then
SetObjectTeam(thing, 3)
local bluematrix = GetEntityMatrix(thing)
elseif GetEntityClass(thing) == FindEntityClass("rep_bldg_inf_goldturret") then
SetObjectTeam(thing, 3)
local goldmatrix = GetEntitMatrix(thing)
end
end
)
turretswitchandmatrixget = OnObjectDamage(
function(tobeteleported, teleporter)
if GetEntityClass(teleporter) == FindEntityClass("rep_bldg_inf_blueturret") then
local movedguy = GetCharacterUnit(tobeteleported)
SetEntityMatrix(movedguy, goldmatrix)
elseif GetEntityClass(teleporter) == FindEntityClass("rep_bldg_inf_goldturret") then
local movedguy = GetCharacterUnit(tobeteleported)
SetEntityMatrix(movedguy, bluematrix)
end
end
)
^would work
Re: Weapon ODF troubles - And now LUA issues, too
Posted: Mon May 31, 2010 8:54 pm
by myers73
no it wont, the local variables have to be defined at at the same level, so the two functions have to be part of a bigger function.