Here's the code, by the way.
Code:
//===========================================================================
//===========================================================================
// ArtRage Script File.
//===========================================================================
//===========================================================================
//===========================================================================
// Version Block - Script version and ArtRage version:
//===========================================================================
<Version>
ArtRage Version: ArtRage 3 Studio Pro
ArtRage Build: 3.5.1
Professional Edition: No
Script Version: 1
</Version>
//===========================================================================
// Header block - Info about the painting/person who generated this script:
//===========================================================================
<Header>
// === Project data
Painting Name: "untitled"
Painting Width: 900
Painting Height: 321
Painting DPI: 299
Mask Edge Map Width: 954
Mask Edge Map Height: 862
// === Author data
Author Name: "Ti-Chen Feng"
Script Name: "MultiMerge"
Comment: "Merges visible Paint, Text, and Sticker layers while keeping hidden layers."
Script Type: ""
Script Feature Flags: 0
</Header>
//===========================================================================
// Script data follows:
//===========================================================================
<Events>
int nUp
int nDown
int nTop = LayerCount()-1
int nBot = 0
flag fCopy = YES
flag fMerge = NO
fCopy = YesNoBox("Retain copy of merged layers?")
//Procedure: Starting from top layer and working down, loop through layers:
// ignore invisible layers; ignore group (1,2,3) layers.
//Find first eligible layer (visible && paint/text/sticker)
for ( nUp=nTop; nUp>nBot; nUp-- ) {
if( LayerVisible(nUp) && ( LayerType(nUp)==0 || LayerType(nUp)>3 ) ) break
}
//Find second eligible layer (visible && paint/text/sticker); merge it
for ( nDown=nUp-1; nDown>=nBot; nDown--) {
if( LayerVisible(nDown) && ( LayerType(nDown)==0 || LayerType(nDown)>3 ) ) {
//If requested, duplicate nUp and nDown
if( fCopy ) {
Wait: 0 EvType: Command CommandID: CID_DuplicateSpecificLayer ParamType: uint32 Value: { nUp }
Wait: 0 EvType: Command CommandID: CID_DuplicateSpecificLayer ParamType: uint32 Value: { nDown }
Wait: 0 EvType: Command CommandID: CID_MoveSpecificLayer ParamType: LayerTwoOp Value: { nDown, nDown+1 }
nUp=nUp+2
nTop++
}
//eep! merge
Wait: 0 EvType: Command CommandID: CID_MoveSpecificLayer ParamType: LayerTwoOp Value: { nDown, nUp-1 }
Wait: 0 EvType: Command CommandID: CID_MergeSpecificLayerDown ParamType: uint32 Value: { nUp }
//update values
nUp--
nDown--
fMerge = YES
break
}
}
//Begin main loop: same thing we just did, except without duplicating nUp
//(Yeah, this is pretty strange programming; I probably should used a function call or an if statement.)
for ( nDown=nDown; nDown>=nBot; nDown--) {
if( LayerVisible(nDown) && ( LayerType(nDown)==0 || LayerType(nDown)>3 ) ) {
if( fCopy ) {
Wait: 0 EvType: Command CommandID: CID_DuplicateSpecificLayer ParamType: uint32 Value: { nDown }
Wait: 0 EvType: Command CommandID: CID_MoveSpecificLayer ParamType: LayerTwoOp Value: { nDown, nDown+1 }
nUp++
}
//eep! merge
Wait: 0 EvType: Command CommandID: CID_MoveSpecificLayer ParamType: LayerTwoOp Value: { nDown, nUp-1 }
Wait: 0 EvType: Command CommandID: CID_MergeSpecificLayerDown ParamType: uint32 Value: { nUp }
//update values
nUp--
}
}
//For charm's sake, set the merged layer name
if( fCopy && fMerge ) Wait: 0 EvType: Command CommandID: LayerName Idx: nUp Name: "Merge Layer"
//110803