www.ClassicTW.com
https://mail.black-squirrel.com/

Using Terminal Menu's in a script
https://mail.black-squirrel.com/viewtopic.php?f=15&t=31623
Page 1 of 1

Author:  SteveH_66 [ Mon May 30, 2011 5:19 pm ]
Post subject:  Using Terminal Menu's in a script

Decided recently to try to get back into the game, and scripting, and I am trying to write a simple script to plot a course. I was told to use the TWX database whenever possible for speed, and I found a Terminal Menu command that seems like it might work just need to know how you incorporate it into scripts.

The command is TWX_PLOTCOURSE

I tried it out through TWX itself, using the data menu, and it came up and asked for a 'from sector' and a 'to sector'. Is there a way to use it in a script so that you can getInput from the user and then have TWX_PLOTCOURSE either echo the course or save it as a variable that can be worked on?

Say for example to use the script as an include and then have it save the course as a variable, which you could then call up from the main script and process the variable as needed to grab the data out.

I know if you don't have a big database, like you haven't run your ZTM yet, you will run into situations when you can't get the course from the database. So I am going to go ahead and work on the code section to get the data straight from the game's computer menu. Just wanted to put this in for speed whenever it could get the data from the database.

Thanks

Author:  Singularity [ Mon May 30, 2011 5:31 pm ]
Post subject:  Re: Using Terminal Menu's in a script

Yea, you can either use the in-game CIM and computer calculations, or you can use getCourse to plot a course internally and output the results.

Author:  SteveH_66 [ Mon May 30, 2011 6:16 pm ]
Post subject:  Re: Using Terminal Menu's in a script

Thanks Singularity. When I use getCourse in a script, it just returns the length of the course, what I wanted was the actual sectors along the route.

So I was going to have the script go to the Computer Prompt in the game, plot a course and capture the lines as they came out, then strip out the > and ( ) and be left with the numbers (after I used mergeText to combine the lines). Thanks for reminding me about CIM, the CIM would probably be faster I'm guessing.

I was just thinking that TWX_PLOTCOURSE might work if it saved the course as one variable and then dumped that to the screen when you used the menu's in TWX under 'data' and selected 'plot course' or whatever it was.

My idea if TWX_PLOTCOURSE worked like that was to pluck out each sector in the route, and use them to populate an array, then you could use it for various things - such as keeping track of your route so like if you are moving and don't want to run up on an enemy sector you could have your script run scans and check the next sector in your route to see if there's anything in there.

I know there are scripts out there that already have that in there, like world trade and world SSM scripts with protection, was just using it as a simple scripting exercise to try to get back into the swing of things, my skills are a *bit* rusty :lol:

Author:  Singularity [ Mon May 30, 2011 6:53 pm ]
Post subject:  Re: Using Terminal Menu's in a script

getDistance returns the distance, getCourse returns the entire course as an array.

http://www.navhaz.com/files/script.html#CMD_16

Author:  SteveH_66 [ Mon May 30, 2011 8:19 pm ]
Post subject:  Re: Using Terminal Menu's in a script

Thanks Sing! I was using TWX IDE to write the script, because it has short descriptions of the commands in it. The part about getCourse populating an Array wasn't in the IDE short description though. I guess I better keep the twx script help file open for reference while I'm writing scripts, until I get the commands refreshed in my mind better :oops: Actually, probably be better to keep that open all the time since my memory isn't what it used to be :lol:

Author:  ElderProphet [ Tue May 31, 2011 6:27 pm ]
Post subject:  Re: Using Terminal Menu's in a script

That's a good point about TWX IDE. It includes the command syntax, but not the notes or examples. For those, refer to the script reference.

And of course, the scripters here are usually eager to offer advice and examples.

Author:  SteveH_66 [ Wed Jun 01, 2011 12:26 am ]
Post subject:  Re: Using Terminal Menu's in a script

yes EP I can't count (well my counting isn't that good but I'm sure I could make a count, it's a lot :lol: ) how many times you or Sing or other scripters have helped out just with my newb questions alone. I would be lost without this place! And I can't speak for the other amateur scripters out there but I really appreciate the time and effort that you, Sing and the other skilled scripters that come here have given to help amateurs like me :D Thanks for that time and effort you all put into helping out.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/