Scripting List
Moderators: Slitherine Core, BA Moderators
-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
Scripting List
I have no programming experience. I have read the STUB doc and the recent script docs and it comes to mind that there may be a standard format.
Does the sequence matter. Such as does briefing need to be before start turn? Can victory points be pasted anywhere in a script?
I would like a list of necessary functions and if need be, the order of placement. Also a list of optional functions and conflicting functions.
TA
Does the sequence matter. Such as does briefing need to be before start turn? Can victory points be pasted anywhere in a script?
I would like a list of necessary functions and if need be, the order of placement. Also a list of optional functions and conflicting functions.
TA
There are no "necessary" functions, but there are a number of "hardcoded" ones, of which the most important are:
StartTurn(side) : This is executed at the start of each turn, before the player makes his moves. "side" is a local variable that holds the ID of the current turn's side (0 or 1). So you can use if( side == 0 ) ... to do things when it's the player's turn. Note that the first turn == 0. So the first AI turn == 1, the second player's turn == 2, and so on. So player turns are always even and AI turns are always odd. For example use if( GetTurn() == 4 ) ... to do something at the start of the player's third turn.
Tick(side) : this is executed each "tick". I'm not sure how many ticks per second, but that doesn't really matter. It's used to track things in real time, like if you capture a VP it needs to chance side right away. "side" is a local variable that holds the ID of the current turn's side (0 or 1).
DrawScenarioUI() : this function is used to set up the information shown in the objectives info display.
ACHIEVEMENT_<name>() : These functions are used to add achievements. Place the achievement's conditions in here and use "return 1" when those conditions are met in order to award the achievement. These are also executed automatically each tick. Quick example:
The last 2 functions are a bit more complex but not really required to create a nice mission. So when you don't have much experience with scripting/modding it's best to ignore these for now.
StartTurn(side) : This is executed at the start of each turn, before the player makes his moves. "side" is a local variable that holds the ID of the current turn's side (0 or 1). So you can use if( side == 0 ) ... to do things when it's the player's turn. Note that the first turn == 0. So the first AI turn == 1, the second player's turn == 2, and so on. So player turns are always even and AI turns are always odd. For example use if( GetTurn() == 4 ) ... to do something at the start of the player's third turn.
Tick(side) : this is executed each "tick". I'm not sure how many ticks per second, but that doesn't really matter. It's used to track things in real time, like if you capture a VP it needs to chance side right away. "side" is a local variable that holds the ID of the current turn's side (0 or 1).
DrawScenarioUI() : this function is used to set up the information shown in the objectives info display.
ACHIEVEMENT_<name>() : These functions are used to add achievements. Place the achievement's conditions in here and use "return 1" when those conditions are met in order to award the achievement. These are also executed automatically each tick. Quick example:
Code: Select all
FUNCTION ACHIEVEMENT_MyNewAchievement()
{
// if player has captured 3 VPs, award achievement
if( GetGlobal("vps") == 3 )
{
return 1 ;
}
// return 0 when achievement conditions are not met
return 0 ;
}-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
Thanks
I guess I was looking for a list of don'ts as much as do's. Trying to cut down on the number of "my campaign crashed, why?" posts.
So far the victory locations and ai behavior docs have been nice to have but when I open an existing bsf I'm not sure where to place the new items and what old/conflicting items to delete.
I guess I was looking for a list of don'ts as much as do's. Trying to cut down on the number of "my campaign crashed, why?" posts.
So far the victory locations and ai behavior docs have been nice to have but when I open an existing bsf I'm not sure where to place the new items and what old/conflicting items to delete.
-
pipfromslitherine
- Site Admin

- Posts: 9898
- Joined: Wed Mar 23, 2005 10:35 pm
-
pipfromslitherine
- Site Admin

- Posts: 9898
- Joined: Wed Mar 23, 2005 10:35 pm
As the tutorial states, it's generally best to develop scenarios in a window so you can see any fatal errors which might pop up. If you come across anything you do which causes an error without a helpful message, let me know and I will add in a check, but most things should be covered, as I try and make it as foolproof as I can, as they are the same tools we use!
Cheers
Pip
Cheers
Pip
-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
-
pipfromslitherine
- Site Admin

- Posts: 9898
- Joined: Wed Mar 23, 2005 10:35 pm
Well, it does, but the problem is that the current MP implementation is very twitchy if you make any scripting errors, or even do something which is not 'deterministic' in terms of the playback.
I am currently working on a new approach that will allow for much easier script usage and such, but it's very complex, and we also want to make it backward compatible so it won't force people to restart games. So it's no iminent, but just giving you a heads-up.
Cheers
Pip
I am currently working on a new approach that will allow for much easier script usage and such, but it's very complex, and we also want to make it backward compatible so it won't force people to restart games. So it's no iminent, but just giving you a heads-up.
Cheers
Pip

