| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| Printing alien spaces (example script) https://mail.black-squirrel.com/viewtopic.php?f=15&t=18164 |
Page 1 of 1 |
| Author: | Singularity [ Fri Dec 01, 2006 5:21 pm ] |
| Post subject: | |
Code: # --------------------------------------------------------- # A simple script to spit out a list of known alien spaces # for a subzero game to a file. This file will be in your # base (root) TWXPROXY directory. # # All we do is loop thru every sector in the universe, check # our database for the name of the constellation for each # sector and if it's a certain name, spit it to a file. This # approach can be used for a lot of things, this is useful if # you forget the sector numbers. # # December 1st, 2006 - By Singularity (Dnyarri) # --------------------------------------------------------- # Set a variable named $file. GAMENAME is a constant that holds # the assigned name of the game. The amp char means 'and' and # the rest is tacked on so you get something like # "mygame-subzero_spaces.txt". setVar $file GAMENAME & "-subzero_spaces.txt" # Erase the file to clear old versions. delete $file # Initialize the loop at 11 setVar $idx 11 # While the loop index is less than the sector count of the uni while ($idx <= SECTORS) # Get the sector from the DB. No choice here because the constellation # entry has no SECTOR value getSector $idx $sec # Here we're going to trim out some things that can throw us off setVar $constellation $sec.CONSTELLATION stripText $constellation " (unexplored)" stripText $constellation "." # Is the constellation one of the famous 3 spaces? if ($constellation = "Ascian Wanderers Space") OR ($constellation = "SubterFuge Space") OR ($constellation = "Ferrengi Space") # It is! # Here we make a padding variable. Makes it easier to read # the file output by spacing things out better. getLength $idx $sector_size if ($sector_size = 1) setVar $pad " " elseif ($sector_size = 2) setVar $pad " " elseif ($sector_size = 3) setVar $pad " " elseif ($sector_size = 4) setVar $pad " " elseif ($sector_size = 5) setVar $pad " " else setVar $pad " " end # Write it all to the file defined above as $file. write $file $idx & $pad & $constellation # End of the earlier constellation "if" test. end # Add 1 to the index value so we can test the next sector. add $idx 1 # End of the while loop. end # --------------------------------------------------------- # We're done! echo ANSI_14 & "**Done!*" # Give us back a prompt send " * " # End the script halt # --------------------------------------------------------- |
|
| Author: | Thrawn [ Fri Dec 01, 2006 7:03 pm ] |
| Post subject: | |
Thanks Sing. That is most helpful. Being new to learning script, i am assuming in the line: if ($constellation = "Ascian Wanderers Space") OR ($constellation = "SubterFuge Space") OR ($constellation = "Ferrengi Space") We can substitute the Aliens per edit then? So for example, I have BORG in Dark Frontier, so I'd have: if ($constellation = "BORG Space") OR ($constellation = "Ferrengi Space") Also, the line: # "mygame-subzero_spaces.txt". setVar $file GAMENAME & "-subzero_spaces.txt" Can be modified to that particular game? So if I had Dark Frontier, I could have: # "mygame-darkfrontier_spaces.txt". setVar $file GAMENAME & "-darkfrontier_spaces.txt" Just learning and asking to get a better understanding of the dynamics. |
|
| Author: | Zentock [ Fri Dec 01, 2006 8:37 pm ] |
| Post subject: | |
Thrawn you may want to consider only useing the first 6 characters of an alien races name counting spaces as a character, and dont swap names just continue to add more to the command line as you run into more aliens, the script wont error out if it does not find the specific alien races that are not even in the game. |
|
| Author: | Promethius [ Fri Dec 01, 2006 9:35 pm ] |
| Post subject: | |
The alien sectors always have "Space" regardless of the race. Filter the constellation for "Space" and make sure it filters out "uncharted". I know Sings example was to show coding examples and the documentation he did will help people. Always know that different people will script differently and you can learn from everyone - from the newest to the most experienced. Code: # get sector names setVar $start 11 While ($start <= Sectors) getsector $start $chkSector if ($chkSector.EXPLORED = Yes) getwordpos $chkSector.Constellation $pos "uncharted" if ($pos = 0) getwordpos $chkSector.Constellation $pos "Space" if ($pos > 0) echo ANSI_12 "**" $chkSector.Constellation " in sector: " $start end end end add $start 1 end halt |
|
| Author: | Thrawn [ Fri Dec 01, 2006 10:50 pm ] |
| Post subject: | |
Zentock wrote: Thrawn you may want to consider only useing the first 6 characters of an alien races name counting spaces as a character, and dont swap names just continue to add more to the command line as you run into more aliens, the script wont error out if it does not find the specific alien races that are not even in the game. Ok I will keep that in mind. Thank you for the reply. |
|
| Author: | Singularity [ Fri Dec 01, 2006 11:37 pm ] |
| Post subject: | |
Prome... I don't play in a lot of alien games, but I think you're right. It'll always have "Space" in the name of the constellation. Not sure if there are any counter-examples... ie: places that aren't alien spaces but still have "Space" in it. Will be on the lookout. In the meantime I made the change and now it seems to work in quite a few alien games... Code: # --------------------------------------------------------- # A simple script to spit out a list of known alien spaces # for a game to a file. This file will be in your base # (root) TWXPROXY directory. # # All we do is loop thru every sector in the universe, check # our database for the name of the constellation for each # sector and if it's a certain name, spit it to a file. This # approach can be used for a lot of things, this is useful if # you forget the sector numbers. # # December 1st, 2006 - By Singularity (Dnyarri) # --------------------------------------------------------- # Set a variable named $file. GAMENAME is a constant that holds # the assigned name of the game. The amp char means 'and' and # the rest is tacked on so you get something like # "mygame-alien_spaces.txt". setVar $file GAMENAME & "-alien_spaces.txt" # Erase the file to clear old versions. delete $file # Initialize the loop at 11 setVar $idx 11 # While the loop index is less than the sector count of the uni while ($idx <= SECTORS) # Get the sector from the DB. No choice here because the constellation # entry has no SECTOR value getSector $idx $sec # Here we're going to trim out some things that can throw us off setVar $constellation $sec.CONSTELLATION stripText $constellation " (unexplored)" stripText $constellation "uncharted space" stripText $constellation "." # With all of this, is it a particular alien "space" ? getWordPos $constellation $pos "Space" if ($pos > 0) # It is! # Here we make a padding variable. Makes it easier to read # the file output by spacing things out better. getLength $idx $sector_size if ($sector_size = 1) setVar $pad " " elseif ($sector_size = 2) setVar $pad " " elseif ($sector_size = 3) setVar $pad " " elseif ($sector_size = 4) setVar $pad " " elseif ($sector_size = 5) setVar $pad " " else setVar $pad " " end # Write it all to the file defined above as $file. write $file $idx & $pad & $constellation # End of the earlier constellation "if" test. end # Add 1 to the index value so we can test the next sector. add $idx 1 # End of the while loop. end # --------------------------------------------------------- # We're done! echo ANSI_14 & "**Done!*" # Give us back a prompt send " * " # End the script halt # --------------------------------------------------------- |
|
| Author: | ElderProphet [ Sat Dec 02, 2006 12:13 am ] |
| Post subject: | |
Nice scripts fellas. Incidently, you can make the TW server resend the current prompt with #128. It's one of those neat, undocumented, man-am-I-a-geek tricks. Traitor told me +EP+ |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|