View unanswered posts | View active topics It is currently Fri May 01, 2026 10:41 pm



Reply to topic  [ 8 posts ] 
 proSSSend.ts (SS send of .ts scripts) 
Author Message
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post proSSSend.ts (SS send of .ts scripts)
The script below will send a text ( .ts not .cts ) file to corpies over sub space. If the file being sent exists in the corpies script dir, the script (being ran by the receiving corpie) will add a time stamp to the front of the file and leave the original file in the dir intact.

Code:
# proSSScript.ts by Promethius
# Into the wild:  10/06/2008
# Please leave the above intact and
# if you make changes, please note them
# if you give this script out.

# The script will send a .ts file located in your scripts dir over
# SS. 

# A corpie should have a copy of this script to receive with, but
# is not required.  The corpie will have to merge lines with <> with
# the line above it deleting "<> " if he does not have the script.

# The script will NOT overwrite a file of the same name, it will place
# the current system time (hhmmss) in front of the file name.

# The sender should not abort SS once it is started or very
# bad things could happen if it breaks out of SS!!!!"

# After send completion, the receiver will get a message on how
# many lines were sent and how many were written.  To eliminate
# any confusion:  if lines sent = 200, lines written MUST = 200.

echo ANSI_10 "*Are you (" ANSI_15 "S" ANSI_10 ")ending or (" ANSI_15 "R" ANSI_10 ")eceiving the file? s/r*"
getConsoleInput $sendReceive SINGLEKEY
lowerCase $sendReceive

if ($sendReceive = "r")
  goto :receiveScript
elseif ($sendReceive = "s")
  goto :sender
end

halt

:sender
echo ANSI_10 "*Wait on receiver (he has a copy of this script)? y/n"
getConsoleInput $wait SINGLEKEY
lowerCase $wait

:getFileName
echo ANSI_10 "**Enter the .TS file to send on SS*"
echo ANSI_10 "NOTE:  This will go to ALL corpies!!!*"
getConsoleInput $scriptToSend
fileexists $exists (".\scripts\" & $scriptToSend)
if ($exists)
   goto :goodFileName
else
   echo ANSI_12 "** !!! Bad file name, Press Any Key **"
   echo ANSI_12 "*File Name: " ".\scripts\" & $scriptToSend " :*"
   getConsoleInput $anyKey SINGLEKEY
   goto :getFileName
end

:goodFileName
send "'"
# setup triggers to make sure sub space is working
# a 3 second (3000 ms) delay trigger fires if there is a problem
setTextTrigger goodSenderRadio :goodSenderRadio "Sub-space radio"
setDelayTrigger badSenderRadio :badSenderRadio 3000
pause
:badSenderRadio
  # something is bad, halt the script
  echo ANSI_12 "*Something went wrong - no sub-space radio detected! Halting**"
  halt
:goodSenderRadio
killtrigger badSenderRadio
# send a SS text to make sure the receiver is ready
send "*ProSSScript v1.0 by Promethius*"
send "Waiting on Receiver script to fire.*"
# waiting on receiver's text
setTextTrigger receiverOn :receiverOn "ProSSScript Receiver Active"
setTextTrigger aborted :aborted "Sub-space comm-link terminated"
pause
:aborted
# ID10T error - they hit the enter key and aborted SS!!!
  echo ANSI_12 "**SS Link Terminated - Halting Script!**"
  halt
:receiverOn
killtrigger aborted
send "Receiver detected*"

send "[++] " $scriptToSend " [--]*"
read ".\scripts\" & $scriptToSend $line 1
setVar $i 1
setVar $numLinesSent 0
while ($line <> EOF)
   :cutter
    getLength $line $len
    setVar $cutCount 0
    add $numLinesSent 1
   if ($len > 65)
      While ($len > 65)
         add $cutCount 1
         cutText $line $tline[$cutCount] 1 65
         cutText $line $line 66 999
         getLength $line $len
      end

      setVar $cCounter 1
      while ($cCounter <= $cutCount)
         if ($cCounter = 1)
            send " " $tline[$cCounter] "*"
         else
            send "<+> " $tline[$cCounter] "*"
         end
         add $cCounter 1
       end
      getLength $line $len
      if ($len > 0)
         send "<+> " $line "*"
      end
   else
        send " " $line "*"
   end
   add $i 1
   read ".\scripts\" & $scriptToSend $line $i
end
send " # File: " $scriptToSend " - sent: " $numLinesSent " Lines *"
send "**  "

halt


:receiveScript
setVar $lineCounter 0
send "'"
setTextTrigger goodReceiverRadio :goodReceiverRadio "Sub-space radio"
setDelayTrigger badReceiverRadio :badReceiverRadio 3000
pause
:badReceiverRadio
  echo ANSI_12 "*Something went wrong - no sub-space radio detected! Halting**"
  halt
:goodReceiverRadio
killtrigger badReceiverRadio
# send our announcement to the sender and wait for reply
send "'ProSSScript Receiver Active*"
# setup a trigger in case we started our script before the sender
setTextTrigger onFirst :onFirst "ProSSScript v1.0"
# receive a reply from the sender that he detected our announcement
setTextTrigger onSecond :onSecond "Receiver detected"
pause

:onFirst
killtrigger onSecond
send "'ProSSScript Receiver Active*"
goto :scriptName
:onSecond
killtrigger onFirst

:scriptName
setTextLineTrigger scriptSave :scriptSave "[++] "
pause
:scriptSave
getword currentline $from 2
getText currentline $scriptName "[++] " " [--]"
:scriptStart
setTextLineTrigger lineIn :lineIn "R " & $from
pause
:lineIn

getwordPos currentLine $pos "# File: " & $scriptName & " - sent:"
if ($pos > 0)
   getText currentline $linesSent "sent: " " Lines"
   goto :scriptEnd
end

cutText currentLine $dataLine 10 999
write "testfile.txt" $dataLine
getwordpos $dataLine $pos "<+> "
if ($pos > 0)
   stripText $dataLine "<+> "
   setVar  $lines[$lineCounter] $lines[$lineCounter] & $DataLine
else
   add $lineCounter 1
   setVar $lines[$lineCounter] $dataLine
end
goto :scriptStart

:scriptEnd
killalltriggers
setVar $i 1
fileExists $exists ".\scripts\" & $scriptName
if ($exists)
   echo ANSI_12 "***            !!! WARNING !!!*"
   echo ANSI_12 "*  A file of that name already exists!!!!"
   getTime $timeStamp "hhmmss"
   echo ANSI_12 "** Saving as " $timeStamp & $scriptName "**"
   setVar $scriptName $timeStamp & $scriptName
end

while ($i <= $lineCounter)
  write ".\scripts\" & $scriptName $lines[$i]
  add $i 1
end
echo ANSI_10 "**File written to .\scripts\" $scriptName "**"
echo ANSI_14 $lineCounter ANSI_10 " lines written of " ANSI_14 $linesSent ANSI_10 " sent.**"


_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Mon Oct 06, 2008 6:41 pm
Profile ICQ
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: proSSSend.ts (SS send of .ts scripts)
Very nice Prom. I wrote one of these as well, and it works great, but I was never happy with the fact that only text files can be transferred. I wrote mine to break down a file into char codes, and these char codes were sent over a private hail. Private hail so SS isn't clogged up, and line breaks are guaranteed to follow word breaks (also in multiline SS/Fed).

But I digress... neither one of the read commands (read / readToArray) will properly preserve #10 or #13 (hex 0A / 0D). Read does much better than readToArray at it, but even it reports #10 as #13, and a few other quirks. It almost transferred a jpeg, but didn't come close to transferring a .cts file.

Keep thinking outside the box,
+EP+

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Tue Oct 07, 2008 10:23 pm
Profile WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: proSSSend.ts (SS send of .ts scripts)
Could always just UUencode the file first...

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Wed Oct 08, 2008 12:14 am
Profile ICQ WWW
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: proSSSend.ts (SS send of .ts scripts)
Even a UUEncoded file would have hex values of 0A and 0D, which Read would interpret as LF and CR respectively. Read actually uses ReadLn, and this is where theses assumptions (#10 = CR+LF) are made. I've actually rewritten the Read command to improve performance, but I think it would be a pain to try and make it faithfully represent CR and LF independantly.

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Wed Oct 08, 2008 6:40 am
Profile WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: proSSSend.ts (SS send of .ts scripts)
Yea, but I don't think CR/LFs in uuencode actually matter, do they? So you could just strip the file of them and decode. It all stems from the problem that EOL varies from OS to OS, and is usually best treated as a single character during transmission so it can be re-interpreted on the other side.

I've had encoding problems before on other things, normally I just pre-encode the file. Convert troubling data to something else. Either as an outside step or as part of an option, then just convert it back on the other side.

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Wed Oct 08, 2008 8:01 am
Profile ICQ WWW
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: proSSSend.ts (SS send of .ts scripts)
ElderProphet wrote:
Very nice Prom. I wrote one of these as well, and it works great, but I was never happy with the fact that only text files can be transferred. I wrote mine to break down a file into char codes, and these char codes were sent over a private hail. Private hail so SS isn't clogged up, and line breaks are guaranteed to follow word breaks (also in multiline SS/Fed).

But I digress... neither one of the read commands (read / readToArray) will properly preserve #10 or #13 (hex 0A / 0D). Read does much better than readToArray at it, but even it reports #10 as #13, and a few other quirks. It almost transferred a jpeg, but didn't come close to transferring a .cts file.

Keep thinking outside the box,
+EP+


It would be nice to be able to send a .cts file since the sender might not want to share open source of some scripts - kinda eliminates putting a time out in the script. I think the option of private hail would be a good addition to the script.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Thu Oct 09, 2008 8:01 pm
Profile ICQ
Gunnery Sergeant

Joined: Thu Sep 13, 2007 1:40 pm
Posts: 20
Unread post Re: proSSSend.ts (SS send of .ts scripts)
This is a very interesting idea Prom. How about the same type of script that sends and receives storing in the twx database the warps data. That would be able to share the results of exploring/ztm with a corpie easily.


Tue Oct 14, 2008 11:49 pm
Profile
Ambassador
User avatar

Joined: Mon Feb 09, 2004 3:00 am
Posts: 3141
Location: Kansas
Unread post Re: proSSSend.ts (SS send of .ts scripts)
Smash wrote:
This is a very interesting idea Prom. How about the same type of script that sends and receives storing in the twx database the warps data. That would be able to share the results of exploring/ztm with a corpie easily.


Check this thread: viewtopic.php?f=15&t=21050

While it will not store the ztm, you will still have to import the file into twx, it will send the ztm and receive the ztm over SS and write a file.

_________________
               / Promethius / Enigma / Wolfen /

"A man who has no skills can be taught, a man who has no honor has nothing."


Wed Oct 15, 2008 1:13 am
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.