Lua code for adding markers [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Lua code for adding markers [Solved]

Post by Fiodis »

I'm trying to make a quick script that adds a marker arrow to a unit when that unit uses a certain weapon, and removes it when the unit uses the weapon again. Unfortunately I'm a bit rusty. I've gotten this far:
Hidden/Spoiler:
[code] IsEntityMarked = 0
mark = OnCharacterDispenseControllable(
function(character, controllable)
if GetEntityClass(controllable) == FindEntityClass("rep_bldg_inf_marker") then
charunit = GetCharacterUnit(character)
if IsEntityMarked = 0 then -- This is line 98.
MapAddEntityMarker(charunit, "hud_objective_icon", 3.0, 1, "YELLOW", true)
IsEntityMarked = 1
elseif IsEntityMarked = 1 then
MapRemoveEntityMarker(charunit)
IsEntityMarked = 0
end
end
end
)[/code][/size]
But the error log complains:
Hidden/Spoiler:
C:\BF2_ModTools\data_FTG\_BUILD\Common\..\..\..\ToolsFL\Bin\luac.exe: ..\..\common\scripts\FTG\FTGc_con.lua:98: `then' expected near `='
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

ERROR[levelpack mission\FTGc_con.req]:Expecting bracket, but none was found.
File : munged\pc\ftgc_con.script.req(1)...

ucft <--
ERROR[levelpack mission\FTGc_con.req]:Expecting bracket, but none was found.
File : munged\pc\ftgc_con.script.req(1)...

ucft <--

2 Errors 0 Warnings
As far as I can see, I've done nothing wrong - but I don't have much faith in my own analysis. Trying to attach the marker to the character, rather than the unit, had the same result.
Last edited by Fiodis on Tue Jan 10, 2012 10:48 pm, edited 1 time in total.
User avatar
Firefang
Major
Major
Posts: 518
Joined: Mon Nov 15, 2010 8:55 pm
Location: California

Re: Lua code for adding markers

Post by Firefang »

When the variable is in an If statement, it needs == instead of = to say "is equal to".

Code: Select all

if IsEntityMarked == 0 then
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Lua code for adding markers

Post by Fiodis »

Ah yes, that should fix it. Thank you; I'll mark this solved.
Post Reply