# Sept 2023
# Set an empty (or not exported) Object name (not a sub object) with:
#  #SCRIPT# DIR 
# It will run that batch file. IE:
# #SCRIPT# C:\Program Files\MarbleCLAY\Plugin\RunBatchScript.txt
# When entering the #SCRIPT# path\file.txt into the object name field, hit enter to update the name change after changing the name.
# The default assetpath will be the path this file is located.
# 
# If #SCRIPT# is not set, the default will be this file:
# C:\MarbleCLAY\Plugin\RunBatchScript.txt 

# runbatchscript for MarbleClay PlayStation export.
# RSD Export/Obj batch script version 2 (May 2023)
# No warranty or liablity, very hacky stuff! Use at own risk.

# No defaulting of values below, all parameter values must appear!

# !assetpath C:\Documents and Settings\NetYaroze\Desktop
# This should be the first line executed!
# Spaces are fine in path, but dont put in quotes or a last back slash.
# Path can be change anytime, and the following commands will process in that folder.

# !rsdexport RootObjectName 1234567.rsd 1.0 0/1/2
# Names are Alphanumeric, no path included, no spaces, filename must be 7.3 formatted or less, 1.0 is the scale value, 0/1/2 can either be: 1:launch No$PSX,  0:Create TMD but skip No$PSX, or 2:ask
# See RSDExporter.txt for more information.
# !objexport is the same, except there is no launchpsx - note: no normals are exported.

#  !echo off / on
# Default is on, each DOS command's output will be displayed in a message popup, if off, it wont. 


# !quit or !exit
# stops, and quits execution


# Everything else will be DOS commands and each passed to DOS, run in the current (!assetpath) location.
# Your commands can be log your output by >>file.log,  >NUL  2>NUL to null or everything will be displayed with !echo on.

#Recommendations :
# Using folders and files with no spaces, ASCII char's and DOS (or 7.3) filenames.
# Use echo on to see command and output when editing this script.
# You can not save this script while MarbleClay is running this script! Wait for it to end first.
# CD (chdir) will have no effect after that line has exectuted, you must use the !assetpath command.
# WARNING - strongly advise not deleting anything via this script, instead use move, if you have to run delete, always fully qualify individual files to avoid removing wrong files.
# Sometimes the message boxes from MarbleClay will be behind the application and it will look like it's locked up or crashed, it hasn't just hit Alt + Tab to find it, Also you'll see two MarbleClay windows in the toolbar, click the 2nd one.
# If you run a command and it's halted or pause (ie awaiting input), it will need to be killed via process explorer, for the script to finish.

#turn logging off  
@echo starting - wait a few seconds.
!echo off


# rm,cp etc are from https://github.com/skeeto/w64devkit (busybox-w32 : standard unix utilities, including sh)

rm -rf tmd
!assetpath  tmd


#create the frames to animate
!rsdexport wood wood.rsd 10.0  1
!objexport wood wood.obj 1.0  

!echo on  
@echo finished: see C:\MarbleCLAY\Sample\tmd\