Page 1 of 1

Scripting questions

Posted: Mon Aug 10, 2009 12:59 pm
by fiddler_on_the_roof
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

Re: Scripting questions

Posted: Mon Aug 10, 2009 1:05 pm
by Frisbeetarian
1) From the Battlefront2_scripting_system.doc in the documentation
This property is the config (ODF) name of the Object.

Re: Scripting questions

Posted: Mon Aug 10, 2009 1:15 pm
by Fiodis
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.

Re: Scripting questions

Posted: Mon Aug 10, 2009 1:57 pm
by fiddler_on_the_roof
Fiodis 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, thanks
Frisbeetarian wrote:1) From the Battlefront2_scripting_system.doc in the documentation
This property is the config (ODF) name of the Object.
ok, so i would just type(for example)

Code: Select all

OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
What about question 3?

Re: Scripting questions

Posted: Mon Aug 10, 2009 2:53 pm
by Fiodis
fiddler_on_the_roof wrote:ok, so i would just type(for example)

Code: Select all

OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
No.

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
)
Also, "human" isn't a recognized team. To check if a player is human and not AI, use

Code: Select all

IsCharacterHuman(variable_of_character)
EDIT - Nice, 1,700th post. Sith Lord rank! :D

Re: Scripting questions

Posted: Mon Aug 10, 2009 2:54 pm
by [RDH]Zerted
2) Yes. There are tons of ways to do it.
3) Your question makes no sense. What is human?

Re: Scripting questions

Posted: Mon Aug 10, 2009 3:07 pm
by Frisbeetarian
Fiodis wrote:
fiddler_on_the_roof wrote:ok, so i would just type(for example)

Code: Select all

OnFlagPickUpConfig(function(flag, human) rep_inf_ep3_sniper)
No.

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
)
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.

@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"
)

Re: Scripting questions

Posted: Mon Aug 10, 2009 3:28 pm
by Fiodis
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:

Code: Select all

if GetObjectClass(character) == "rep_inf_ep3_sniper" then

Re: Scripting questions

Posted: Mon Aug 10, 2009 3:33 pm
by Frisbeetarian
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.
I'm not sure what you mean by knocking on his code.
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.

Re: Scripting questions

Posted: Wed Aug 19, 2009 3:16 am
by fiddler_on_the_roof
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?

Code: Select all

example:
SetClassProperty("rep_inf_ep3_rifleman", "PointsToUnlock", [b]+12[/b])
(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

Re: Scripting questions

Posted: Wed Aug 19, 2009 9:43 am
by [RDH]Zerted
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:

Code: Select all

unlockPoints = 5
OnSomethingHappens...(function(thing,some)
    unlockPoints = unlockPoints + 12
    SetClassProperty("rep_inf_ep3_rifleman", "PointsToUnlock", unlockPoints)
end)

Re: Scripting questions

Posted: Wed Aug 19, 2009 12:36 pm
by fiddler_on_the_roof
ok, thanks

so if you just put each new function, or If on a new indent, each one needs an end? What about the )?

Re: Scripting questions

Posted: Wed Aug 19, 2009 12:54 pm
by Frisbeetarian
For every "(" you need a ")".

Re: Scripting questions

Posted: Wed Aug 19, 2009 3:00 pm
by fiddler_on_the_roof
ok, thanks

so if I had

Code: Select all

                  OnSomething(function(some, thing)
                           --i would need to end it like this
                 )
        end
and if i had

Code: Select all

           OnSomething(function(some, thing)
                    
                     Ifsomething  == something then return end
                     --it would end like this?

                 )
           end
    end

Re: Scripting questions

Posted: Wed Aug 19, 2009 3:36 pm
by [RDH]Zerted
"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
OnEnterRegionName(function(player)
ShowMessageText("Hello")
end, "startRegion")
or written in a different way (but does the exact same thing)
local sayHello = function(player)
ShowMessageText("Hello")
end

OnEnterRegionName( sayHello, "startRegion" )
An if statement:
if something == something2 then return end

Re: Scripting questions

Posted: Fri Aug 21, 2009 10:13 am
by fiddler_on_the_roof
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)

Re: Scripting questions

Posted: Fri Aug 21, 2009 7:40 pm
by [RDH]Zerted
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'?

Re: Scripting questions

Posted: Sat Aug 22, 2009 8:09 am
by fiddler_on_the_roof
[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'?
blue, ok.

red-nevermind, i read something wrong.

thanks