Teach me how to script please (could also be useful for others)

Rev707

New member
Joined
Jun 3, 2012
Messages
7
Hello, I am rev707 and this is my first post in this forum.

I am new to the scripting and can't find a completed tutorial on the Internet. I want to ask an (experienced) programmer if he has some time to teach me, that would be great. I already have the basics.

Here is my first question: how can I check if a player makes his first platoon, and then execute some code?

Thanks a lot in advance.
 
This will detect and army made by a player
Have this running right at the beginning of the game, when the player creates an army it will detect it and TestPlatoon will not = 0 anymore and will exit loop.

TestPlatoon = 0

begin loop
        TestPlatoon = get platoon of player 0 nearest {Town[0]} radius 300
        until TestPlatoon !=0
end loop
 
Thanks for the quick response.

So if i understand it right it looks if player zero has a platoon in a radius of 300 from town center zero and then it wil automatically end the loop?

But where do you find the commands you have used here? Are these 'statements'? Do I need to them by heart?

And what should I type if i want the enemy to build planned buildings?

Thanks again,
Rev707
 
the commands are in
C:\Program Files\Lionhead Studios\Black & White 2\Tools\Script Language Documentation
go to the full index it has every command you will ever need.

Yes you are right on how those commands work.

To build planned building is tricky because in the .bwe file you need to select the building or buildings. on the dialog window there will be a planned button on the bottom select that to make it a planned building then place them in a group, for example group 1

Then you need to go to your script and use the command

build all town Town[0] buildings in group 1

or you can create it right in the script by this code. This one will take longer.

Building1 = 0

Building1 = create with angle 0 and scale 1 SCRIPT_OBJECT_TYPE_ABODE ABODE_NUMBER_STORAGE_PIT at {Location1}
 
I had already managed to do it with normal buildings, but I can't seem to find out how to put the walls in a group. Furthermore the full index isn't working, could i solve it with a re-download?
Thanks again for your time
 
I had that problem as well, has far as I know it is impossible to add walls to groups, its one of the many MANY problems with the landscape modeler. sorry I try for about 2 weeks to get wall into groups and never got it to work.
I never had the problem with the index but you may not have a good enough reader for them.
But you can try to re download it.
Anything else you need help with?
 
Yes, is it possible to leave out certain parts of statements?
For example, when you have "build all town Town[0] buildings in group 1" can't you just say "build all town Town[0] buildings"?

And for the Town[0], dont i need to define it as Town[Cnt] = get town with id Cnt?
 
You can't just leave out parts of a statement. there are only a few command that you can do that with.

Town[0] is an array, do you understand arrays?

Town[0] = get town with id 0
Town[1] = get town with id 1
Town[2] = get town with id 2
Town[3] = get town with id 3
Town[4] = get town with id 4
Town[5] = get town with id 5
Town[6] = get town with id 6
Town[7] = get town with id 7
Town[8] = get town with id 8

or this my work I never used it though

cnt = 0
begin loop
  Town[cnt] = get town with id cnt
  cnt++
  until cnt == 8
end loop

It really doesn't matter that much.
 
This the probably one of the hardest parts of making a land.

There is too much here for me to explain, the attachment is a script I made for a land with almost every kind of command there is for armies.
You will need notepad++ to open it. there could be other programs that will work, but most programs seem to mess it up
 
Thanks so much for your help, I have managed to do everything I asked you, you have really been of a great help, and thank you for all your time and effort.

I have to say I never expected such a fast response or even a response at all. I have worked with script languages which seem very logical but there is nobody who really understands it.

I encourage everybody that wants to learn this language to sign up and ask.

And thanks again Willy!
 
No problem at all!
If you have any other questions at all just ask!
I will be more then happy to help.

Two more pieces of advance when making a B&W 2 lands make sure the enemy is really hard :D
Because the real game was made way to easy, the people who still play B&W 2 need land that will take more then one day win.

One more:
I found that local variables WILL change valve sometimes, not often, but they will.
So use global variables for the more important ones. 

 
It will show up on the front page when you upload your land.
I'm looking forward to it.
 
Back
Top