View unanswered posts | View active topics It is currently Fri Mar 29, 2024 12:01 am



Reply to topic  [ 10 posts ] 
 How do you specify no value in a script now? 
Author Message
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post How do you specify no value in a script now?
I seem to remember from writing scripts a while ago that you used to use "" in triggers and such for a script when you wanted it to trigger on anything (like you were getting a route from the CIM that might have a 2nd or 3rd line with just one sector number on it, so the ">" character couldn't be used as a trigger and there really wasn't any good trigger text to use in that situation, so you wanted it to trigger on any line) or you weren't getting any value at all. I am writing a simple single step scouting script, which drops a fig in any sector where there is no fighter and doesn't drop one in a sector you already have a fig in.

I am using the TWXProxy SECTOR.FIGS.OWNER system value to check for the fig owner in that sector, and SECTOR.FIGS.QUANTITY to check for the number of figs in the sector. When I added that to the IF macro code, the script started erroring out like this :

Quote:
Command [TL=00:00:00]Script run-time error in 'THORSINGLESTEPSCOUT.TS': Sector i
ndex out of bounds, line 86

Script terminated: C:\twx_Proxy\scripts\myScripts\ThorSingleStepScout.ts


Line 86 in the script is :
setVar $figsOwner SECTOR.FIGS.OWNER[$currSect]

Here is the part of the code from the script :

Code:
:move
killTrigger error
setTextLineTrigger error :error "You are already in that sector!"
send $route[$r] "*"
waitON "Command [TL="
killTrigger waitON6
send "sd"
waitON "Command [TL="
killTrigger waitON7
setVar $currSect CURRENTSECTOR
setVar $figsOwner SECTOR.FIGS.OWNER[$currSect]
setVar $figsQuant SECTOR.FIGS.QUANTITY[$currSect]

if (CURRENTSECTOR > 10) AND (CURRENTSECTOR <> STARDOCK) AND ($figsQuant = 0) AND ($figsOwner <> "belong to your Corp")
   send "F"
   waitON "How many fighters do you want defending this sector?"
   killTrigger waitON8
   send "1" "*"
   waitON "Should these be (C)orporate fighters or (P)ersonal fighters?"
   killTrigger waitON9
   send "C"
   waitON "Should they be (D)efensive, (O)ffensive or Charge a (T)oll ?"
   killTrigger waitON10
   send "D"
   waitON "Command [TL="
   killTrigger waitON11
end


To check it out and see what value was being saved for SECTOR.FIGS.OWNER I cranked out a few lines of code in a test script, getting SECTOR.FIGS.OWNER and SECTOR.FIGS.QUANTITY and echoing them along with CURRENTSECTOR. The little test script works fine, and here is what it echoes in the game :

Quote:
Command [TL=00:00:00]:[16019] (?=Help)? :
<Re-Display>

Sector : 16019 in uncharted space.
Ports : Skuld Minor, Class 1 (BBS)
Warps to Sector(s) : 6197 - 12529 - 18565 - 19282

Command [TL=00:00:00]:[16019] (?=Help)? :
16019

0
Script terminated: C:\twx_Proxy\scripts\_test1.ts


As you can see, 16019 is the sector number. Then a blank line with no value for SECTOR.FIGS.OWNER and then 0 for SECTOR.FIGS.QUANTITY. When I saw that, I had added OR ($figsOwner = "") thinking that would cover no value being in the database for SECTOR.FIGS.OWNER — but TWXProxy didn't like that either.

It seems that the database doesn't store any value for SECTOR.FIGS.OWNER if there are no figs in the sector. So what would I use to specify 'no value' in a TWX script? Thanks


Wed Jun 11, 2014 7:34 pm
Profile
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Re: How do you specify no value in a script now?
can you post where your script is echoing your values?

I ran your code snippet, and it worked fine when i was in a corp. it laid a fig. I also echoed out your values with:

Code:
echo "*Owner: " $figsOwner
echo "*Quantity: " $figsQuant
echo "*Current Sector: " $currSect
echo "*"

and received what I expected which was correct:

Code:
Owner:
Quantity: 0
Current Sector: 827


I did not received your error you mention.


Thu Jun 12, 2014 10:35 pm
Profile
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post Re: How do you specify no value in a script now?
Hi Tweety, this brings back old memories, you used to answer my script questions on the old twxproxy.com forums years ago - I went by Thor over there. And I see that SupG shows up around here now and again too :shock:

It doesn't mess up when I just have a test script echo the values, I didn't echo them from the single step script anywhere, I just had it get those values and then drop the fig if there isn't a corp fig already in the sector. I just used a quick test script to echo the values, to see what they were showing since I couldn't figure out why the script was erroring out like it was. I could put back in the code for getting the sector owner name and then post the code for the whole script, but it would mean having to mod the script again. The stepper script just didn't like there being no value for owner and it errors out when I run it. I have taken the owner part out of the script and I've just got the script only dropping figs when there are 0 figs in the sector.

That is a workable solution, but not optimal for what I am wanting to do. I rewrote a few lines in the script and had it go to different script blocks depending on if there was no fig in the sector. I suppose I could mod the current script and add in the owner part again and see if it will still error out or not. I am mostly just curious how to specify to a script that the twx database might return a blank value instead of 0/1 or true/false or another type of value - that it might just return blank values.

Actually, thinking about it, it might be best when using a script like this to go exploring to handle anything other than 0 figs in the sector by hand. You might run into enemy figs or alien figs and have to do your work on the fly so to speak :lol:

Ok, I added in some code so that it would get SECTOR.FIGS.OWNER for the current sector, and then drop a fig if there were no figs in the sector, or if $figOwner <> "belong to your Corp". Now it isn't erroring out, it is just dropping a fig in some sectors if there is no fig in the sector and $figOwner doesn't meet the condition, and sometimes it isn't dropping a fig if there are no figs in the sector and $figsOwner isn't meeting the condition. I dumped the script variables and it is showing "" for $figOwner. So I don't know why it drops a fig sometimes and doesn't drop them other times.

Here's the script code, maybe you can take a look at it, run the script like you did the code block I posted above, and see if you can duplicate the error. Thanks

Code:
# Thor's Single Step Scout
# version 0.11
# author : Thor

# This script will single step you to your destination
# This script will wait for user to input trigger text before making next step
# This script automatically does density scan.  During stop in next sector,
# you could do a holo scan, if you saw something on density needing checked
# This script gets your route, and steps through the route one sector at a time

setVar $a 1
setVar $gCount 0
setVar $dataFilePre "gameData\"
setVar $arrayFile $dataFilePre & GAMENAME & "_randSects.txt"
setVar $randSectsGen~randSectsFile $arrayFile
getInput $randSectsGen~count "How many random sectors do you want to generate?"
goSub :makeRandomFile
# :begin
goto :start
PAUSE

:start
setTextOutTrigger go :go #7
PAUSE

:go
killTrigger go
echo "*" "trigger key works!"
if ($gCount = 0)
   add $gCount 1
   goto :makeArray
ELSE
   echo "*" "array populated"
   goto :go2
END
echo "*" "array populated"
PAUSE

:go2
if ($routeCount = 0)
   goto :getRte
ELSE
goto :move
END
PAUSE

:makeArray
readToArray $arrayFile $destArray
goto :go2
PAUSE

:getRte
add $routeCount 1
setVar $r 2
send "^"
waitON ":"
killTrigger waitON1
send "F"
waitON "FM >"
killTrigger waitON2
send CURRENTSECTOR "*"
waitON "TO >"
killTrigger waitON3
send $destArray[$a] "*"
waitON ":"
killTrigger waitON4
send "q"
waitON "Command [TL="
killTrigger waitON5
setVar $current CURRENTSECTOR
getCourse $route $current $destArray[$a]
setVar $r 2
goto :move
PAUSE

:move
killTrigger error
setTextLineTrigger error :error "You are already in that sector!"
send $route[$r] "*"
waitON "Command [TL="
killTrigger waitON6
setVar $currSect CURRENTSECTOR
setVar $figQuant SECTOR.FIGS.QUANTITY[$currSect]
setVar $figOwner SECTOR.FIGS.OWNER[$currSect]
send "sd"
waitON "Command [TL="
killTrigger waitON7

IF ($figQuant = 0) OR ($figOwner <> "belong to your Corp")
   goto :move3
ELSE
   goto :move4
END
PAUSE

:move3
if (CURRENTSECTOR > 10) AND (CURRENTSECTOR <> STARDOCK)
   send "F"
   waitON "How many fighters do you want defending this sector?"
   killTrigger waitON8
   send "1" "*"
   waitON "Should these be (C)orporate fighters or (P)ersonal fighters?"
   killTrigger waitON9
   send "C"
   waitON "Should they be (D)efensive, (O)ffensive or Charge a (T)oll ?"
   killTrigger waitON10
   send "D"
   waitON "Command [TL="
   killTrigger waitON11
end
goto :move4
PAUSE

:move4
IF ($route[$r] = $destArray[$a])
   echo "*" "Getting new Route"
   add $a 1
   setVar $r 2
   setVar $routeCount 0
   setVar $current CURRENTSECTOR
   goto :start
ELSE
   add $r 1
   add $routeCount 1
   setVar $current CURRENTSECTOR
   goto :start
END
PAUSE
   
:error
killAllTriggers
add $r 1
setVar $routeCount 0
setVar $current CURRENTSECTOR
goto :start
PAUSE

:makeRandomFile
include "myInclude\randSectsGen"
PAUSE


Here's the include file code you will need for the include file it wants, you will have to mod it for where to look for the include file, I am using a different include folder for my own include scripts. Have to change the file directory code and such too for where you store these kind of files, I store script data files for my games in a subdirectory of TWXProxy

Code:
      # Thor's multiple Random Sector Generator Include Script
      # author : Thor
      # version 0.1

      # Description
      # This script will generate a list of random sectors, which can
      # be used in other scripts for various uses.      
      
echo "*" $randSectsGen~count

setArray $randSects $randSectsGen~count
setVar $filePre "gameData\"
setVar $file $filePre & GAMENAME & "_randSects.txt"
echo "*" "making random sectors file"
setVar $a 1
setVar $b 1
setVar $c 1
goto :checkFile
PAUSE

:checkFile
fileExists $exists $file
IF ($exists)
   echo "*" "File Exists"
   delete $file & ".bak"
   rename $file $file & ".bak"
   goto :makeArray
ELSE
   goto :makeArray   
END
pause

:makeArray
while ($a <= $count)
   getRnd $randSects[$a] 1 20000
   write $randSectsFile $randSects[$a]
   add $a 1
END
return
PAUSE   


Edit : That's why I hate to mess with a working script, I changed the code back and now it is still doing the sometimes drop a fig sometimes don't in a sector with no figs :(


Fri Jun 13, 2014 1:17 pm
Profile
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Re: How do you specify no value in a script now?
so let me understand your script. basically you want to to go to a random sector and step one sector by one sector. if no fig there, lay one. if there is a enemy fig, kill it? and lay one? or go right to manual control? or have it avoid it?

and are you scanning the density of adjacent sectors to see if the next sector is safe to enter?

there are a bunch of variables you have to consider when writing such a script. are you entering sectors 1-10? or stardock? if so, you don't want to try to lay a fighter since you will get dinged assets on your ship.

another consideration is speed. having so many waits considerably slows down the script. it may not seem like it when its running, but you will notice you get caught more often.

I have not actually used the script you posted other then the first snippet. but i thought i could give you ideas and code snippets of what may work for you. as well as ways to mod your existing code since that is how people learn. improving on what they already wrote.


Fri Jun 13, 2014 4:20 pm
Profile
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post Re: How do you specify no value in a script now?
Hi Tweety. Ya, the script uses the include to get a user specified number of random sectors, as destinations to go to. If you look at the IF conditional (correct term?) for dropping the fig, you see it checks to make sure the sector number is over 10 and not stardock, if it is it shouldn't drop a fig.

That script was mostly just written to use when I'm stepping around in the local game, I got tired of clicking my macro buttons repeatedly - i know, call me lazy :lol:

And on the density scan, that is in there for both safety and to see what adjacent sectors have ports I might want to check out. For convenience, my local game for scripting is unlimited turns, but I have only played in turn limit games in the past and I try to keep an eye on turn usage in my scripts so that I burn the minimum possible and don't waste any with things like always doing a holo scan. On a script like this, I determine whether to do a holo scan personally. A real game use script I guess it might be best to always do a holo scan anyway, to avoid the old trick of rigging a sector to look like it just has a port or something in it when there's actually a trap set.

And I'm with you on all the checks, I usually don't use that many for any script I am planning for real world use in a real game. But it seems to me that TWX Proxy can run out ahead of itself these days on faster machines, although I'm sure my sloppy coding doesn't help any :oops: , so I sometimes add a few more checks than are strictly necessary. Back in the day my scripts were more like automated macros to go for the speed, with the bare minimum of checks to keep from suddenly zipping off across the universe and running into trouble and some checks to try to avoid getting into trouble in the first place lol.

And yes, with that kind of script having no checks and built in responses, I am handling most everything personally when I use it. Just a script I am using locally to cut out having to run the macros all the time for dropping the figs and moving, with the the wait for input I just have to use one simple set of keystrokes. It's definitely not an attempt at a full blown scout script or for mowing or anything like that.


Sat Jun 14, 2014 8:58 pm
Profile
Ensign
User avatar

Joined: Mon Dec 26, 2011 8:41 am
Posts: 206
Unread post Re: How do you specify no value in a script now?
SteveH_66 wrote:
I seem to remember from writing scripts a while ago that you used to use "" in triggers and such for a script when you wanted it to trigger on anything [.....] and there really wasn't any good trigger text to use in that situation, so you wanted it to trigger on any line

If you want to trigger on any line, as far as I know, SetTextLineTrigger on the empty string, like you said, should work.

SteveH_66 wrote:

[.... (tl;dr) .....]

It seems that the database doesn't store any value for SECTOR.FIGS.OWNER if there are no figs in the sector. So what would I use to specify 'no value' in a TWX script? Thanks


If I want to know whether there are no figs in the sector, I look at SECTOR.FIGS.QUANTITY. Don't even look at SECTOR.FIGS.OWNER unless you already know there are more than zero figs in the sector.

(edit: One of the IF statements in your original post has something like IF (...) AND (...) AND (figs.quantity = 0) AND (figs.owner <> something), which makes no sense... that line isn't what's causing the error, but I don't understand why you would want to know who the owner of zero figs is. Anyway, the real problem, according to the error message, is that on line 86 sector.figs.owner[$currSect] doesn't exist. Which would make sense if there are no figs in sector.)

(rambling: I wouldn't expect OWNER to give any useful information when there are no figs in sector, because in that case the owner is undefined. It's not just that there isn't an owner of the figs, it's that there are no figs to own. So to say OWNER="none" or something, when there are no figs to own, would be technically incorrect. The real answer to "who owns the zero figs in this sector" is both everybody and nobody. The only correct value for OWNER in this case is null or undefined, which in twxproxy script is usually represented as an empty string or a 0, unfortunately.)


Last edited by Astrochimp on Sat Jun 21, 2014 3:37 pm, edited 8 times in total.



Thu Jun 19, 2014 6:30 pm
Profile ICQ
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Re: How do you specify no value in a script now?
sorry steve, i kind of wandered off and haven't replied to your message. I will reply.


Fri Jun 20, 2014 4:04 pm
Profile
Chief Warrant Officer
User avatar

Joined: Sat Feb 27, 2016 1:01 am
Posts: 193
Location: Molon Labe
Unread post Re: How do you specify no value in a script now?
That is likely your problem you are setting a variable whether or not there is a record; just put an if > 0 check on the figs quantity:

Code:
setVar $figsOwner SECTOR.FIGS.OWNER[$currSect]


ETA:

oh wow this an old thread.

_________________
The object of life is not to be on the side of the majority, but to escape finding one’s self in the ranks of the insane.” — Marcus Aurelius

TWX Proxy Reference Online


Sat Mar 05, 2016 11:31 pm
Profile ICQ
Commander

Joined: Thu Oct 17, 2002 2:00 am
Posts: 1158
Unread post Re: How do you specify no value in a script now?
So is trolling old threads....


Sun Mar 06, 2016 12:04 pm
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1131
Location: Augusta, GA
Unread post Re: How do you specify no value in a script now?
Heh, since we're on this old topic...
The original issue Steve had was index out of bounds. If line 86 is really the one he indicated, then it's caused by $currSect not being a valid value between 1 and SECTORS. And if you look at the code from his snippet, you'll see that he pulls $currSector from the following lines:
Code:
waitON "Command [TL="
killTrigger waitON7
setVar $currSect CURRENTSECTOR
The CURRENTSECTOR system value is determined when TWX sees the completed command line, but as you can see, the command line may not be complete when this waitOn trigger fires. So this should instead be a TEXTLINETRIGGER, guaranteeing that the full command line would have been seen (since it fires on CRLF), and so CURRENTSECTOR will be valid and updated.

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


Sun Mar 20, 2016 8:06 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 26 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 STSoftware.