Page 1 of 1

Tacedit - TCL corner

Posted: 2002-06-27 15:05:00
by Snake Man
TCL scripting topics for Tacedit!

When you post pieces of TCL code here, you must use the CODE feature of this forum software. Meaning:

(code)
blabla my code rocks!
(/code)

And replace () with [] to make it work, that was just an example. Or you can use the CODE button in the forum software.

So first example tacedit tcl scripts you can find from the latest package. Codec made fine job with the PAK ADDER script and there are also two little less complicated ones too.

If you guys have any specific tasks you always wanted tacedit to do, now would be good idea to post ideas here, some code geeks might write script up for you.

Let the scripting start!

Re: Tacedit - TCL corner

Posted: 2002-06-27 15:14:00
by codec
Some simple stuff...

How to iterate through all objectives currently defined.
code:

Code: Select all

foreach oid [objective list] {
    # do something with each objective.
    printout "Objective $oid is at " [objective get $oid x y]
}
Similar thing for units
code:

Code: Select all

foreach uid [unit list] {
    # do something with each unit.
    printout "Unit $uid is at " [unit get $uid x y]
}

Re: Tacedit - TCL corner

Posted: 2002-06-29 11:59:00
by brewskie
Hmmm, is there any possible way to change the formations of ground units? 99.9% of the time they move in column formation, .05% in line, .05% in wedge. Is this just wishful thinking, Pi in the virtual sky.

Re: Tacedit - TCL corner

Posted: 2002-07-04 13:52:00
by Snake Man
code:

Code: Select all

 

set num 0

set olist [lsort -integer [objective list]]
foreach var $olist {
	set fish [objective name $var]
	set cat NoName
	if {[lsearch $fish $cat] !=-1} { 
	objective delete $var
	incr num 1
	}	
}


printout "Deleted $num NoNames"
 
This nicely removes all objectives named "NoName".

PMC TFW
Snake Man

Re: Tacedit - TCL corner

Posted: 2002-07-04 14:31:00
by Widowmaker
nice
I just finnished deleting
all nonames in Iceland manually...

geezz :)

Widmak

Re: Tacedit - TCL corner

Posted: 2002-07-13 03:12:00
by Snake Man
code:

Code: Select all

printout "Europe Theater Airbase list :"

foreach var [lsort -integer [objective list [objective type 1]]] {
	if {[objective get $var control] == 2} {printout "Allied: " [objective name $var]}
	if {[objective get $var control] == 6} {printout "Russian: " [objective name $var]}

}
Thats how I listed all airbases from Europe theater, team 2 being allied and team 6 being the east/russians.

Pretty useless piece of code, but...

PMC TFW
Snake Man

Re: Tacedit - TCL corner

Posted: 2002-07-13 18:01:00
by Snake Man
PMC Korea Campaigns

The example fully playable campaigns with the TCL scripts that were used to create them. Available for download in here PMC_PMCKorea_TCL_Theater_v0.2.rar updated 08-06-10

Install instructions included in the readme txt.

PMC TFW
Snake Man

Re: Tacedit - TCL corner

Posted: 2002-07-13 21:24:00
by Widowmaker
Very nice
absolutely recomendable..

take your swimsuit with ya.. ;)

Widmak

Re: Tacedit - TCL corner

Posted: 2002-09-02 21:41:00
by Washout
Hi

Has anyone got a link to the TCL web site - I've decided I need to know more about the language and need a place to start.

Later


Chris

Re: Tacedit - TCL corner

Posted: 2002-09-03 08:14:00
by Snake Man
quote:Originally posted by Washout:
Has anyone got a link to the TCL web site
http://resource.tcl.tk/resource/doc/manual/

Thats wat I've been using, its not the whole site link but ...

PMC TFW
Snake Man

Re: Tacedit - TCL corner

Posted: 2002-09-09 15:48:00
by Washout
Hi All

Wit Julian providing the bones and most of the meat here's a TCL script which list the numeric values held in the objective's name field:
code:

Code: Select all

foreach obj [lsort -integer [objective list]] {
   set name [objective get $obj name]
    printout "Objective $obj" numbered "$name"
}
Later


Chris

Re: Tacedit - TCL corner

Posted: 2002-12-23 19:27:00
by krfrge
Has anyone doen a script to place ports? I am struggling with this problem.

Thanks

Re: Tacedit - TCL corner

Posted: 2003-03-12 18:35:00
by Falcas
Hello all,

Does anybody know the code for placing a SAM unit on an Airfield?

Thx

Falcas

Re: Tacedit - TCL corner

Posted: 2003-03-12 20:27:00
by Snake Man
quote:Originally posted by Falcas:
Does anybody know the code for placing a SAM unit on an Airfield?
There is AAA 2 Airbases and SAM 2 SAM sites scripts in the Tacedit scripts.

PMC TFW
Snake Man

Posted: 2007-11-12 12:02:27
by Closter
Bump!

Re: Tacedit - TCL corner

Posted: 2007-11-12 18:10:27
by marvin157th
Snake Man wrote:
quote:Originally posted by Falcas:
Does anybody know the code for placing a SAM unit on an Airfield?
There is AAA 2 Airbases and SAM 2 SAM sites scripts in the Tacedit scripts.

PMC TFW
Snake Man
I'm curious.. Is this just a laziness code?? Or does this perfectly place objects at an airbase so they are not on the runway etc?

I usually manually place them, but sometimes they like to sit on the runway. :(

Posted: 2007-11-12 18:32:35
by Snake Man
Its placed on the same coordinates as the objective, F4 campaign engine then moves it where it sees proper fit. I have never seen air defense units on the runways or taxiways this way, never.

Re: Tacedit - TCL corner

Posted: 2009-03-02 21:04:03
by Sherlock
I have a couple of tcl questions....

In the creation of named squadrons on airbases, it is of the form:

Code: Select all

# AIRBASE NAME - num / ID

#
# Seoul - #### / 1056
set abnum 1056
What is the "num" above (where does it come from?) and is the "ID" the campaign ID or the objective ID from TacEdit?

Re: Tacedit - TCL corner

Posted: 2009-03-02 21:57:32
by Snake Man
Hum I believe it was the objective ID minus one hundred or something like that (I cant recall it right now, I'd have to dig up the info somewhere).

Are you using create.Squadron.tcl script to place squadrons? Because that takes the tacedit airbase ID directly without any adjustments.

Re: Tacedit - TCL corner

Posted: 2009-03-02 22:40:16
by Sherlock
Snake Man wrote:Hum I believe it was the objective ID minus one hundred or something like that (I cant recall it right now, I'd have to dig up the info somewhere).

Are you using create.Squadron.tcl script to place squadrons? Because that takes the tacedit airbase ID directly without any adjustments.
Yes, I am working with create.Squadron.tcl but I want to be able to give a specific name to each squadron (like you did for ODS historic 1991), not just let the tcl script increment the squadron name by 1. Haven't written my own tcl scripts before so starting from scratch.

Re: Tacedit - TCL corner

Posted: 2009-03-06 17:00:24
by Sherlock
My question is as follows:

Is there a way to input the number of hours for reinforcement via the tcl scripts when creating the squadrons, battalions, etc?

For instance here is the line from the ODS tcl scripts that creates a E-8 JSTARS and names it:

Code: Select all

# jstars e-8
set newid [unit create 398]
unit set $newid bflags 3 control [objective get $abnum control] x [objective get $abnum x] y [objective get $abnum y] name 4411 unitflags 32 destx [expr [objective get $abnum x] +1] desty [expr [objective get $abnum y] +1]
Can some additional command be added to this (or another line) to add the reinforcement time in automatically so I don't have to go back into tacedit and do it manually?

Re: Tacedit - TCL corner

Posted: 2009-03-06 18:14:32
by Sherlock
Sherlock wrote:My question is as follows:

Is there a way to input the number of hours for reinforcement via the tcl scripts when creating the squadrons, battalions, etc?

For instance here is the line from the ODS tcl scripts that creates a E-8 JSTARS and names it:

Code: Select all

# jstars e-8
set newid [unit create 398]
unit set $newid bflags 3 control [objective get $abnum control] x [objective get $abnum x] y [objective get $abnum y] name 4411 unitflags 32 destx [expr [objective get $abnum x] +1] desty [expr [objective get $abnum y] +1]
Can some additional command be added to this (or another line) to add the reinforcement time in automatically so I don't have to go back into tacedit and do it manually?
I figured this out. This is how you do it:

Code: Select all

# jstars e-8
set newid [unit create 398]
unit set $newid bflags 3 control [objective get $abnum control] x [objective get $abnum x] y [objective get $abnum y] name 4411 reinf 8 unitflags 32 destx [expr [objective get $abnum x] +1] desty [expr [objective get $abnum y] +1]
the "reinf #" goes right after the name field.

Re: Tacedit - TCL corner

Posted: 2009-03-06 22:06:55
by Sherlock
Next question.

I'm wanting to input the units speciality (Air to Air or Air to Ground) via the tcl script as well.

I've tried adding the following to the line:

Specialty 2

as in:

Code: Select all

set newid [unit create 398]
unit set $newid bflags 3 control [objective get $abnum control] x [objective get $abnum x] y [objective get $abnum y] name 4411 reinf 8 unitflags 32 destx [expr [objective get $abnum x] +1] desty [expr [objective get $abnum y] +1] Specialty 2
Thinking that Air-to-Ground is "2" while none is "0" and Air-to-Air is "1". The Specialty setting is not on the Unit Properties tab (2nd tab) but is on the 3rd tab (Squadron tab) of the unit for tacedit.

It didn't work. Any ideas on what it takes to do this?

Re: Tacedit - TCL corner

Posted: 2009-03-07 05:05:24
by Sherlock
Sherlock wrote:Next question.

I'm wanting to input the units speciality (Air to Air or Air to Ground) via the tcl script as well.

I've tried adding the following to the line:

Specialty 2

as in:

Code: Select all

set newid [unit create 398]
unit set $newid bflags 3 control [objective get $abnum control] x [objective get $abnum x] y [objective get $abnum y] name 4411 reinf 8 unitflags 32 destx [expr [objective get $abnum x] +1] desty [expr [objective get $abnum y] +1] Specialty 2
Thinking that Air-to-Ground is "2" while none is "0" and Air-to-Air is "1". The Specialty setting is not on the Unit Properties tab (2nd tab) but is on the 3rd tab (Squadron tab) of the unit for tacedit.

It didn't work. Any ideas on what it takes to do this?
got it with the help of GinRummy at the 69th vfw....
The syntax is:

unit squadron set $newid speciality 1 airbaseid 72

Re: Tacedit - TCL corner

Posted: 2009-03-07 09:27:25
by Snake Man
Thanks for posting those tips.

Re: Tacedit - TCL corner

Posted: 2010-01-19 10:23:15
by Snapper
Hi guys,
I have a newe question during my campaign work:
Is it possible to change the Team settings at date xx.xx.xx from "neutral" to "at war" with TCL. I searched the PMC Korea campaign but can't find something like that. How can I create such a trigger like Lead Pursuit did in the Korea campy where china enters the war?

Edit:
Found a pice of code within one of Sherlocks posts about the iran campi.

Code: Select all

// CIS joins the war
//
#IF_EVENT_PLAYED 11
#ELSE
#IF_SUPPLY 6 L 40
#CHANGE_RELATIONS 4 6 1
#PLAY_MOVIE 108
#DO_EVENT 11
#ELSE
#IF_FORCE_RATIO A 6 2 L 2
#CHANGE_RELATIONS 4 6 1
#PLAY_MOVIE 108
#DO_EVENT 11
#ENDIF
I want a short time for peacetime operations at the begin of my campaign before OPFOR starts the war.


Cheers

Snapper

Re: Tacedit - TCL corner

Posted: 2010-01-19 16:06:27
by Snake Man
This is actually a trigger question, not TCL one. Check the trigger pages from PMC Editing Wiki and there is one start of hostilities trigger setup pretty close to this. Also PMC Afghanistan should have triggers like what you are asking.

Let me know (in some appropriate trigger topic) if you could not find solution from the wiki.

Re: Tacedit - TCL corner

Posted: 2010-08-06 04:41:10
by Snake Man
New PMC Korean TCL Campaigns has been released, it includes the latest TCL scripting from me. I'm actually very happy if not even proud of how the division placement script came out. With one function call, you can place whole division of ground units, no more twiddling your thumbs adding battalion by battalion :)

Also I have created PMC Editing Wiki: TacEdit TCL page.

More information will be added there when I get around to it, all tips and requests would be very welcome.

Re: Tacedit - TCL corner

Posted: 2010-08-08 21:03:45
by Sherlock
Going through all the objectives in the Iran theater and comparing them to the default Korea objectives. I've noticed that Iran objectives pretty much all have fuel = 0 while Korea objectives have fuel = 235. Also, in Korea the bflags = 2 while Iran bflags = 0.

I'd like to use tcl to set these objectives fields. I know I'd use something like codec's input above about:

Code: Select all

foreach oid [objective list] {
    # do something with each objective.
    printout "Objective $oid is at " [objective get $oid x y]
}
But I'm not very experienced with tcl. Any help out there from anyone?

Thanks in advance.

Re: Tacedit - TCL corner

Posted: 2010-08-08 21:31:58
by Snake Man
You have really good question, I did search on forum & wiki and didn't find anything which was surprising. This was in my personal notes which should be immediately be dumped into the wiki (I know).

Code: Select all

# O B J E C T I V E  fields
# ----------------
# Type - the CT Id 
# Id - the objective ID 
# X - X location 
# Y - Y location 
# Z - elevation 
# SpotTime - last time this was spotted 
# spotted - spotted flags 
# bflags - basic flags 
# Control - which teams controls this 
# CampId - campaign id 
# lastrep - ?? 
# Flags - flags 
# Supply - supply status 
# Fuel - fuel status 
# Losses - losses 
# FCount - feature count 
# Priority - priority of the ibjective 
# Name - number index into the name table 
# Parent - parent id 
# Owner - owner of the objective 
# Nlinks - how many links it has 
# HasRadar - true if it has radar  
So this would perhaps work as:

Code: Select all

    foreach oid [objective list] {
        objective set $oid fuel 235
        objective set $oid bflags 2
        printout "Objective $oid fuel is " [objective get $oid fuel]
        printout "Objective $oid bflags is " [objective get $oid bflags]
    }
Try it out and see if it works?

Re: Tacedit - TCL corner

Posted: 2010-08-08 22:14:18
by Sherlock
I added supply to the commands you provided so now my script looks like:

Code: Select all

foreach oid [objective list] {
    objective set fuel 235
    objective set bflags 2
    objective set supply 235
    printout "Objective $oid fuel is " [objective get $oid fuel]
    printout "Objective $oid bflags is " [objective get $oid bflags]
    printout "Objective $oid supply is " [objective get $oid supply]
}

But I am getting the following error:
**ERROR**
expected integer but got "fuel"
while executing
"objective set fuel 235"
("foreach" body line 2)
invoked from within
"foreach oid [objective list] {
objective set fuel 235
objective set bflags 2
objective set supply 235
printout "Objective $oid fuel is..."
(file "C:/Program Files/Lead Pursuit/Battlefield Operations/Theaters/Iran/campaign/set_bflags_&_fuel.tcl" line 1)

Re: Tacedit - TCL corner

Posted: 2010-08-08 22:52:36
by Snake Man
I updated my earlier post, if that doesn't work let me know and I'll figure it out tomorrow.

Re: Tacedit - TCL corner

Posted: 2010-08-09 00:24:43
by Sherlock
Snake Man wrote:I updated my earlier post, if that doesn't work let me know and I'll figure it out tomorrow.
Worked like a champ! Thanks! Here's what I ended up with in total:

Code: Select all

foreach oid [objective list] {
    objective set $oid fuel 235
    objective set $oid bflags 2
    objective set $oid supply 235
    printout "Objective $oid fuel is " [objective get $oid fuel]
    printout "Objective $oid bflags is " [objective get $oid bflags]
    printout "Objective $oid supply is " [objective get $oid supply]
}

Re: Tacedit - TCL corner

Posted: 2010-08-11 21:41:55
by Sherlock
I have question regarding the PMC Theater buiding TCL scripts. Specifically, the script called "fDivision.tcl". This script basically is divided into two parts, the "bluefor" part and the "opfor" part. This script also makes use of the "fBrigade_Battaltions.tcl" script to create the Division-->Brigade-->Battalion units, populate that structure with units (armor, mech, infantry, etc) and create their relationship within each structured unit.

Within the "fDivision.tcl" script is a series of commands like:

Code: Select all

createBrigade $objid 113 45
This line appears to feed information to the "fBrigade_Battaltions.tcl" script which has the following process definition in it:

Code: Select all

# create brigade and 5 battalions
proc createBrigade { objid brgtype battype } {
...
Here is my question: It appears that the "CreateBrigade" process uses the data contained in the "fDivision.tcl". So in the snippet of code above taken from the "fDivision.tcl" script, are the numbers which follow the "createBrigade $objid" the assigned unit "name" and the unit "type"? For example, in the line above the type is "45" which is the Armored XXI-M1A1 unit? And the "113" is the unit "name", i.e., the "113th Division"?

Re: Tacedit - TCL corner

Posted: 2010-08-11 22:10:50
by demer928
Not Good to set every objective Fuel\Supply to 235 in Campaign.Not even neccesary in TE!!!!
Don't think they Actually eat the cookie's so to speak.Ummmmmmmm...!!!Let's look at it this way.
If you remove ALL the Weapon's from an AC in F4Browse....is it still flyable for the (player)??Yes,the Code will alway's give the (player) Weapon's.Same go's for GU's I believe.Maybe ED_1 has some insight's on this for AF.....Dunno!

demer

Re: Tacedit - TCL corner

Posted: 2010-08-12 03:10:00
by Snake Man
Sherlock wrote:are the numbers which follow the "createBrigade $objid" the assigned unit "name" and the unit "type"? For example, in the line above the type is "45" which is the Armored XXI-M1A1 unit? And the "113" is the unit "name", i.e., the "113th Division"?
No, they are brigade type and battalion type.

So you can quite easily change armored brigade to contain not M1A1 tank but M48 tank battalions.

Re: Tacedit - TCL corner

Posted: 2010-09-04 20:17:21
by demer928
Just a hint for CCC:


# I R A N b a t a l l i o n s


# variables for batallions
# controlling team
set cntrl 2

# batallion name
set bname 1

# orders
set ordr 1[/color](Very important if you want your GU's kind of Scripted at the start i.e. The GTM has someplace to start)

# aobj id
set assign 0

# batallion type
set battype 2523 (M1A1 in this example)
#set roster
set roster 4294934391

(This is prob'ly going to be a hard thing to "Get our Head's Around"!!!! Hustler posted to try and, better explain why this NEED'S to match the Unit you are using from the Database. I'll leave it to him to further that knowledge in the Falcon community.Suffice it to say that the VU2 Engine and, in fact, the "Code" is a huge and complex Calculator that rely's more on numerical data than Name's!!!!)


set xc 370
set yc 951

source "C:\\TCL\\Iran\\create.brig.bat.sub.no.offset.tcl"

and in:
"C:\\TCL\\Iran\\create.brig.bat.sub.no.offset.tcl"


# batallion 1st
set bat1 [unit create $battype]
unit batallion set $bat1 bflags 0 roster $roster control $cntrl x $xc y $yc campid $bat1 name $bname unitflags 0 reinf 0 destx 0 desty 0unit batallion set $bat1 aobj $assign morale 100 orders $ordr

incr bname 1


:wink:
demer

Re: Tacedit - TCL corner

Posted: 2010-09-18 20:05:24
by demer928
Sherlock wrote:
Snake Man wrote:I updated my earlier post, if that doesn't work let me know and I'll figure it out tomorrow.
Worked like a champ! Thanks! Here's what I ended up with in total:
Here is a snippet of what I ended up having to do for Iran:

Code: Select all

#Set Obj Flag's Iran


#Note to myself "types"
#AIRBASE                 1
#AIRSTRIP                2
#ARMYBASE                3
#BEACH                   4
#BORDER                  5
#BRIDGE                  6
#CHEMICALPLANT           7
#CITY                    8
#COMMANDCONTROL          9
#DEPOT                   10
#FACTORY                 11
#FORD                    12
#FORTIFICATION           13
#HILLTOP                 14
#JUNCTION                15
#NUCLEARPLANT            17
#PASS                    18
#PORT                    19
#POWERPLANT              20
#TOWN                    28
#VILLAGE                 29
#SAMSITE                 31


set olist [lsort -real [objective list [objective type 6]]]

foreach oid $olist {
    objective set $oid fuel 10
    objective set $oid supply 5
	objective set $oid priority 15
	objective set $oid flags 688128
	objective set $oid bflags 2
}

set olist [lsort -real [objective list [objective type 1]]]

foreach oid $olist {
    objective set $oid fuel 235
    objective set $oid supply 235
	objective set $oid priority 10
	objective set $oid flags 4965632
	objective set $oid bflags 11
}

printout "Feck you, have a nice day..Hmmpf,Dam Onion's HAHAHA!!!."
If you notice the Flag's are Decimal but, TacEdit\Code read's it as HexDex sxooooooo!!!!!! you have to convert it!!!

Hope this helps,
demer