Help with OnEnterRegion script

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
wishihadaname
Captain
Captain
Posts: 493
Joined: Fri Dec 28, 2007 2:10 pm
Projects :: The Corellian Resistance
Games I'm Playing :: Halo Reach and LOTRO
Location: Look to your left.... no, your other left....

Help with OnEnterRegion script

Post by wishihadaname »

I am attempting to use a region to give an info popup but for some reason its not working. The first argument is invalid even though I copied it direcly from a shipped script. Could someone look over this bit of code for the mistake I made? I'm rather lost.
Hidden/Spoiler:
ActivateRegion("Info2")
infopopup2 = OnEnterRegion(
function(region, player)
if IsCharacterHuman(character) then
ShowObjectiveTextPopup("level.TCR.objectives.info.2")
SetProperty("cp6", "Team", 1)
end
end,
"Info2"
)
Here is Mav's example script just for comparison
Hidden/Spoiler:
ActivateRegion("regionname")
testfunction = OnEnterRegion(
function(region, player)
if [whatever callbacks you want] then
whatvever you want to happen
end
end,
"regionname"
)
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: Help with OnEnterRegion script

Post by DarthD.U.C.K. »

you can only use the paramaters the function returns. your callback uses "character" as parameter but you never assigned anything to that variable. the function onneterregion returns the unit in the variable "player". therefore you should either let the function return "character" or use "player" as parameter for the ischaracterhuman callback.
User avatar
wishihadaname
Captain
Captain
Posts: 493
Joined: Fri Dec 28, 2007 2:10 pm
Projects :: The Corellian Resistance
Games I'm Playing :: Halo Reach and LOTRO
Location: Look to your left.... no, your other left....

Re: Help with OnEnterRegion script

Post by wishihadaname »

thanks for the help, got it to work.
CalvaryCptMike
Captain
Captain
Posts: 476
Joined: Sat Feb 19, 2011 3:10 pm
Projects :: Nothing--absolutely nothing
Location: Freed by alien robots, now living on Mars
Contact:

Re: Help with OnEnterRegion script

Post by CalvaryCptMike »

I've been having the same problem, could you please specify what exactly it would look like?
ActivateRegion("Info2")
infopopup2 = OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
ShowObjectiveTextPopup("level.TCR.objectives.info.2")
SetProperty("cp6", "Team", 1)
end
end,
"Info2"
)
Would that be it? :?
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: Help with OnEnterRegion script

Post by DarthD.U.C.K. »

yes, thats how it must look like, like i said.
CalvaryCptMike
Captain
Captain
Posts: 476
Joined: Sat Feb 19, 2011 3:10 pm
Projects :: Nothing--absolutely nothing
Location: Freed by alien robots, now living on Mars
Contact:

Re: Help with OnEnterRegion script

Post by CalvaryCptMike »

Okay, thx I get it now!
Post Reply