Scripting questions
Moderator: Moderators
-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Scripting questions
1-How is the filter "config" used?
--what do you enter to get a match for it.
2-Is it possible to make an objective sequence just for one team, so that if you were on the other team, it would skip those objectives?
would it just be If GetObjectTeam(human) == 1 then return end ?
3-for the getobjectteam and stuff, can i use human? (^^)
thanks
--what do you enter to get a match for it.
2-Is it possible to make an objective sequence just for one team, so that if you were on the other team, it would skip those objectives?
would it just be If GetObjectTeam(human) == 1 then return end ?
3-for the getobjectteam and stuff, can i use human? (^^)
thanks
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Scripting questions
1) From the Battlefront2_scripting_system.doc in the documentation
This property is the config (ODF) name of the Object.
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Scripting questions
If you want, say, Conquest objectives for one team and a specialized set for the other, you could do that. I'd have to think about it more, and my brain is not quite in the mood for thinking right now, but I'm not sure you'd even need to check the player's team.
Oh wait...I think you might. Yeah. Like I said, I'm not in thinking mode right now.
Oh wait...I think you might. Yeah. Like I said, I'm not in thinking mode right now.
-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Scripting questions
ok, thanksFiodis wrote:If you want, say, Conquest objectives for one team and a specialized set for the other, you could do that. I'd have to think about it more, and my brain is not quite in the mood for thinking right now, but I'm not sure you'd even need to check the player's team.
Oh wait...I think you might. Yeah. Like I said, I'm not in thinking mode right now.
ok, so i would just type(for example)Frisbeetarian wrote:1) From the Battlefront2_scripting_system.doc in the documentationThis property is the config (ODF) name of the Object.
Code: Select all
OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Scripting questions
No.fiddler_on_the_roof wrote:ok, so i would just type(for example)Code: Select all
OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
You would type something like:
Code: Select all
OnFlagPickUp(
function(flag, character)
characterodf = GetObjectClass(character)
if characterodf == "rep_inf_ep3_sniper" then
*type code here*
end
)Code: Select all
IsCharacterHuman(variable_of_character)
Last edited by Fiodis on Mon Aug 10, 2009 2:56 pm, edited 2 times in total.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Scripting questions
2) Yes. There are tons of ways to do it.
3) Your question makes no sense. What is human?
3) Your question makes no sense. What is human?
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Scripting questions
Don't knock what he had, he had the right idea, he just forgot the comma, the quotes, and the "end," and he also called the filter the wrong name. Yours works too, his way is just better. And you forgot an extra "end" for your if statement.Fiodis wrote:No.fiddler_on_the_roof wrote:ok, so i would just type(for example)Code: Select all
OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
You would type something like:Code: Select all
OnFlagPickUp( function(flag, character) characterodf = GetObjectClass(character) if characterodf == "rep_inf_ep3_sniper" then *type code here* end )
@fiddler_on_the_roof
The filter name is "Class" not config. When the document says "Class: config" it means Class is the filter name and the argument used is the config. You would also put quotes around the config as it is a string. Of course, you also need a comma after the function (which needs an "end" as Fiodis pointed out). It would read something like this:
Code: Select all
OnFlagPickUpClass(
function(flag, character)
*type code here*
end,
"odf_file_name"
)- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: Scripting questions
I'm not sure what you mean by knocking on his code.
What I typed up was a rough outline, so of course it wouldn't be complete. You could do what Frisbeetarian suggested, but you would still need to include an ODF check for the character variable:
What I typed up was a rough outline, so of course it wouldn't be complete. You could do what Frisbeetarian suggested, but you would still need to include an ODF check for the character variable:
Code: Select all
if GetObjectClass(character) == "rep_inf_ep3_sniper" then- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Scripting questions
No you don't that's the point of filters. You might want to go read up on the scripting document yourself. The whole idea of having the filter is so that the game only uses the code for those specific configs.
Rightly named, the filter filters out unnecessary units so that the game does less work.
Rightly named, the filter filters out unnecessary units so that the game does less work.
I was just saying that instead of fixing his code, you gave him a totally different way around it. A less efficient way at that.I'm not sure what you mean by knocking on his code.
-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Scripting questions
ok, thanks.
i have 2 more questions.
1--how are the "ends" and the parentheses used to end stuff? I mean when do you put them in and how many.
2--is it possible to add a certain amount of points it takes to unlock a unit each time something happens, but so that you only need one bit of code?
(for every time something happens, it adds 12 more points till you unlock a unit instead of writing out each time the new unlock limit)
thanks
i have 2 more questions.
1--how are the "ends" and the parentheses used to end stuff? I mean when do you put them in and how many.
2--is it possible to add a certain amount of points it takes to unlock a unit each time something happens, but so that you only need one bit of code?
Code: Select all
example:
SetClassProperty("rep_inf_ep3_rifleman", "PointsToUnlock", [b]+12[/b])thanks
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Scripting questions
The end ends the function parameter. OnFlagPickUpClass is a function which takes another function and a string as parameters/arguments. The comma after the end separates the two parameters. It is easier to tell where you need ends if you indent each new block/scope level.
I don't think there is any way to get the current unlock point for a unit class, but you could use a variable:
I don't think there is any way to get the current unlock point for a unit class, but you could use a variable:
Code: Select all
unlockPoints = 5
OnSomethingHappens...(function(thing,some)
unlockPoints = unlockPoints + 12
SetClassProperty("rep_inf_ep3_rifleman", "PointsToUnlock", unlockPoints)
end)-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Scripting questions
ok, thanks
so if you just put each new function, or If on a new indent, each one needs an end? What about the )?
so if you just put each new function, or If on a new indent, each one needs an end? What about the )?
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Scripting questions
For every "(" you need a ")".
-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Scripting questions
ok, thanks
so if I had
and if i had
so if I had
Code: Select all
OnSomething(function(some, thing)
--i would need to end it like this
)
endCode: Select all
OnSomething(function(some, thing)
Ifsomething == something then return end
--it would end like this?
)
end
end- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Scripting questions
"so if I had..." you would be wrong. You basically took the code I gave you and made it wrong. This is basic programming stuff. Just like every sentence ends with a period (or colon or question mark, etc...) so must every opening keyword or character: (, {, [, or function end with its corresponding character or keyword: ), }, ], or end. The openings and closing levels cannot be mixed. Meaning that when you 'open' something, everything inside it must be closed before the original thing is closed. In your code exmaples, you put the closing ) before the function's end. Since the starting/opening ( is before the function, it must be closed after the function. Thus the ) must come after the end.
Look at the colors
Look at the colors
or written in a different way (but does the exact same thing)OnEnterRegionName(function(player)
ShowMessageText("Hello")
end, "startRegion")
An if statement:local sayHello = function(player)
ShowMessageText("Hello")
end
OnEnterRegionName( sayHello, "startRegion" )
if something == something2 then return end
-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Scripting questions
ok, thanks.
two more questions.
for objectives, you can have the "ObjectiveGoTo", how would you make a new one, like
"ObjectiveNew"?
what about rules?(similar as before, how to make a new set)
two more questions.
for objectives, you can have the "ObjectiveGoTo", how would you make a new one, like
"ObjectiveNew"?
what about rules?(similar as before, how to make a new set)
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Scripting questions
Look through the game's campaign script. There are a few campaign missions where you have to go to a certain location. See how they create their Goto objectives.
What do you mean by 'rules'?
What do you mean by 'rules'?
-
fiddler_on_the_roof
- 1st Lieutenant

- Posts: 460
- Joined: Wed Nov 12, 2008 5:28 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Scripting questions
blue, ok.[RDH]Zerted wrote:Look through the game's campaign script. There are a few campaign missions where you have to go to a certain location. See how they create their Goto objectives.
What do you mean by 'rules'?
red-nevermind, i read something wrong.
thanks
