Weapon ODF troubles - And now LUA issues, too
Moderator: Moderators
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Weapon ODF troubles - And now LUA issues, too
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:
However, it doesn't work; the turrets fire at me even if I'm farther away from them, and they don't wait. Am I changing the wrong values?
Hidden/Spoiler:
Last edited by Fiodis on Sun May 23, 2010 1:38 pm, edited 1 time in total.
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: Weapon ODF troubles
MinRange = "0"
OptimalRange = "0.5"
MaxRange = "1"
ExtremeRange = "1"
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...
OptimalRange = "0.5"
MaxRange = "1"
ExtremeRange = "1"
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...
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Weapon ODF troubles
I have a feeling you're right....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...
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:
Hidden/Spoiler:
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: Weapon ODF troubles - And now LUA issues, too
GetEntityClass() wants a string and you are giving it a variable, at least I think that is the problem
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Weapon ODF troubles - And now LUA issues, too
Isn't that line supposed to check if teleporter's class is equal to rep_bldg_in_blueturret?
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: Weapon ODF troubles - And now LUA issues, too
if so then it looks fine to me
-
CressAlbane
- Master Bounty Hunter

- Posts: 1519
- Joined: Fri Dec 18, 2009 8:02 am
- Projects :: CTF Arenas
- Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı
Re: Weapon ODF troubles - And now LUA issues, too
Is this supposed to be rep_bldg_inf_blueturret ?rep_bldg_in_blueturret
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: Weapon ODF troubles - And now LUA issues, too
i dont see that typo anywhere...
- StarkillerMarek
- Rebel Colonel

- Posts: 611
- Joined: Wed Aug 12, 2009 4:42 pm
- Location: I may be back.
Re: Weapon ODF troubles - And now LUA issues, too
Fiodis just wrote it in his post. He didn't make that mistake in the Lua.Fiodis wrote:Isn't that line supposed to check if teleporter's class is equal to rep_bldg_in_blueturret?
-
CressAlbane
- Master Bounty Hunter

- Posts: 1519
- Joined: Fri Dec 18, 2009 8:02 am
- Projects :: CTF Arenas
- Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı
Re: Weapon ODF troubles - And now LUA issues, too
/slap
I feel dumb.
I feel dumb.
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Weapon ODF troubles - And now LUA issues, too
Ah - could this be the problem?
myers73 wrote:can a local variable that is defined in one function be called in another function?
Would I have to put one function inside the other?[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:But this won't work as expected:Code: Select all
function sayHello() local message = "Hello" showMsg = function() print("showMsg() says: ", message) end showMsg() endCode: Select all
function sayHello() local message = "Hello" end showMsg = function() print("showMsg() says: ", message) end showMsg()
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: Weapon ODF troubles - And now LUA issues, too
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
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Weapon ODF troubles - And now LUA issues, too
This, however:
Gets me this:
Am I nesting it wrong?
Hidden/Spoiler:
Code: Select all
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-
501st_commander
- Master Bounty Hunter

- Posts: 1570
- Joined: Wed Dec 10, 2008 7:48 pm
Re: Weapon ODF troubles - And now LUA issues, too
Code: Select all
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
)
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: Weapon ODF troubles - And now LUA issues, too
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.
