| Author |
Message |
|
Maniac
Lieutenant J.G.
Joined: Sun Mar 13, 2005 3:00 am Posts: 387 Location: USA
|
 Re: TWX 2.05 Beta
Lonestar and Promethius, While I can't speak for Elder Prophet I can almost guarantee that a "Commify" routine can easily be put in place not in the beta coming out 7/4 but the next release after that. Delphi has a built in Format('Number = %n', [12345.678]); which will put the commas where you need them and also we can format for currency along with just about any other numerical format you would want. The hard part is going to be deciding on a name for the TWX function/routine NumberFormat ? not a good choice because we can also format strings (i.e. right/left justify strings) Commafy? not a good choice either for same reasons above. Format? Don't know if we can use that name as is as it might conflict with the Delphi command. If anyone has any ideas about what we should name this routine please chime in A back of the envelope idea of what the function should be Function CmdFormat(Script : TObject; Params : array of TCmdParam) : TCmdAction; begin var F : Extended; // CMD: Format var value [formatstring] ConvertToFloat(Params[1].Value,TScript(Script).DecimalPrecision,F); // TODO add an optional format string to end of command Params[0].Value:= Format('%n', [F] ); Result:= caNone; end; This should work fairly well as is and can be expanded for error conditions. Can also be used for strings/currency but need a way to pass in the "format string" i.e $formatstring = 'The final tally of collies grabbed is %n' Format $outstring 100000000 $formatstring $outstring would be The final tally of collies grabbed is 100,000,000 Comments, flames and additional ideas are welcome. Maniac SDManson@gmail.com
_________________ Find out just what any people will quietly submit to and you have the exact measure of the injustice and wrong which will be imposed on them. Frederick Douglas
|
| Sat Jun 20, 2009 9:45 pm |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 Re: TWX 2.05 Beta
CommaFormat or CommaStringFormat ? Maybe StringCommaFormat
_________________ 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
|
| Sat Jun 20, 2009 10:50 pm |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 Re: TWX 2.05 Beta
From what I remember of my VB days.. there were alot of formatting functions and options from numeric to String formatting (ie: proper case, proper name, etc). I never thought twx needed this type of functionality simple because it's so easy to do on the fly --including column-padding.
simple function name could be: Format $Source $Destination "BitMask"
BitMask can be anything like:
Format $Source $Destination "#,###" Format $Source $Destination "###.##" Format $Source $Destination "$#,###"
etc ... this is how VB works to some extent, iirc.
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Sun Jun 21, 2009 5:28 am |
|
 |
|
LoneStar
Commander
Joined: Fri Jun 09, 2006 2:00 am Posts: 1401 Location: Canada
|
 Re: TWX 2.05 Beta
Promethius wrote: LS, I should have identified a bit more of what I am doing with the formatting. Basically it is to output into a TWX window, and/or a text file in an easier (for me anyway) format to read. The numeric vars are usually left alone so I don't end up with a crash.
You should really see my Sector Planet STripper script. The output window is some of my best work (see attached). Promethius wrote: The "mess" as I call it comes from:
setVar $inputVar $credits gosub :genFormat setVar $creditsDisp $outPutVar
setVar $inputVar $citTreasury gosub :getFormat setVar $citTreasuryDisp $outPutVar
That is a mess. but that's not how you should use a routine like the one I posted: Code: setVar $inputVar $credits gosub :genFormat Echo "*I have this many Credits: $" $inputVar setVar $inputVar $citTreasury gosub :getFormat Echo "*Treasury Has: $" $inputVar
...no mess. Promethius wrote: If there was a number formatting command within TWX, then the goSubs would be eliminated. A couple of others might be lPad and rPad to pad a string either left or right. Easy to write but still have the goSubs. They are trivial to write, but Functions would be nice. What I would really like are Array sorting and processing commands/functions. ReadToarray is fantastic.. someone emtnioned WriteArray sometime ago.. would be another fantastic addtion.. howeve. I use Multidimensional Array alot.. it would be golden to have the ability to copy 2nd, 3rd, etc.. dimensions to another Array index in one line. or even shift values (a stack in other words).
_________________ ---------------------------- -= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
|
| Sun Jun 21, 2009 5:52 am |
|
 |
|
ElderProphet
Commander
Joined: Tue Oct 07, 2003 2:00 am Posts: 1134 Location: Augusta, GA
|
 Re: TWX 2.05 Beta
Promethius wrote: Code: :genFormat setVar $outputVar "" getLength $inputVar $cutLen while ($cutLen > 3) cutText $inputVar $tmpVar ($cutLen - 2) 3 setVar $outPutVar "," & $tmpVar & $outputVar subtract $cutLen 3 end cutText $inputVar $tmpVar 1 $cutLen setVar $outputVar $tmpVar & $outputVar return Who is the original author of that code? It is extremely well written! What probably makes the most sense is a Format command, with a specifier like "Number" or "Currency". It could later be extended with additional specifiers, like TrimLeft, Exponential, or whatever. Ex.: Format $myNumber $myCurrency CURRENCY +EP+
_________________ Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.
|
| Tue Jun 23, 2009 12:27 am |
|
 |
|
Promethius
Ambassador
Joined: Mon Feb 09, 2004 3:00 am Posts: 3141 Location: Kansas
|
 Re: TWX 2.05 Beta
ElderProphet wrote: Promethius wrote: Code: :genFormat setVar $outputVar "" getLength $inputVar $cutLen while ($cutLen > 3) cutText $inputVar $tmpVar ($cutLen - 2) 3 setVar $outPutVar "," & $tmpVar & $outputVar subtract $cutLen 3 end cutText $inputVar $tmpVar 1 $cutLen setVar $outputVar $tmpVar & $outputVar return Who is the original author of that code? It is extremely well written! What probably makes the most sense is a Format command, with a specifier like "Number" or "Currency". It could later be extended with additional specifiers, like TrimLeft, Exponential, or whatever. Ex.: Format $myNumber $myCurrency CURRENCY +EP+ Thx, every once in a while I get lucky on the coding. I like the example on the possible format command. It would make things easier.
_________________
/ Promethius / Enigma / Wolfen /
"A man who has no skills can be taught, a man who has no honor has nothing."
|
| Tue Jun 23, 2009 4:55 pm |
|
 |
|
The Jackalope
1st Sergeant
Joined: Wed Jun 03, 2009 4:39 pm Posts: 36
|
 Re: TWX 2.05 Beta
Singularity wrote: Quote: You missed my point - there are a lot of people who are not in tw at all because of this. There are a lot of ppl that are not in tw because TWXproxy is too complicated to learn? Really? LOL. That's not what I said. I've never said it's too difficult to learn, what I've been saying is it's tedious and cumbersome. Singularity wrote: Quote: the old-school tw players are for the most part too intimidated to even bother trying. Then that's their problem. I can't solve someone's emotional hangups. Especially by making a simple script language even more complicated. I'm not a babysitter. I never said it was your problem. And I never even came close to implying that you were a babysitter. Singularity wrote: Nevertheless, if you feel that strongly about the language being too complex why don't write a program to do the job better? Or at least does it the way you want?
I don't so much feel strongly about the language being too cumbersome; what I feel a bit strongly about is your reaction to my suggestion that it might be a tad tedious to code with twx. Singularity wrote: Quote: I'm sorry if I'm insulting your program; I didn't write it. Xide wrote it, EP took over the project when Xide left and has maintained it (for free) ever since. my bad. Singularity wrote: Quote: That's fine, maybe I'm not as smart as you guys and I'll never understand the complexities of twx scripting because of my inferior mind, but that's all beside the point. The point is accessibility of the game to new users. To be competitive, twx is a necessity at the moment. Uhm. TWX scripting language is one of the easiest languages in existence to learn. Compared to even BASIC, it's very well-tailored to fit the game and simple tasks. There's very little you could do to make it easier to understand. Functions and objects, while nice for advanced users and complicated blocks of code, certainly would not make it any easier to understand for new ppl. [/quote] See above - I didn't say it was difficult to learn, or at least that's not what I meant. Also see Big D's next post (the one after your post that I'm replying to).
|
| Sun Jun 28, 2009 12:26 pm |
|
 |
|
The Jackalope
1st Sergeant
Joined: Wed Jun 03, 2009 4:39 pm Posts: 36
|
 Re: TWX 2.05 Beta
I'm not really following a lot of what you guys are talking about, so I hope what I'm about to say isn't completely irrelevant now, but as a continuation of my original question about functions and now that I hear it would be difficult or infeasible or whatever to implement them in twx...
What about script parameters? Like the load command taking additional parameters, and scripts accepting command-line parameters? And maybe even a return value? That would be almost as good as functions, and it couldn't be that hard to implement could it? I would try it myself but I don't know enough about twx yet - that's why I'm asking the experts, and I'm not asking anyone to necessarily implement it, I'm just wondering about feasibility. If nothing else, the script parameters could be implemented via environment variables or even temporary files easily enough, couldn't they?
Last edited by The Jackalope on Sun Jun 28, 2009 12:52 pm, edited 1 time in total.
|
| Sun Jun 28, 2009 12:33 pm |
|
 |
|
The Jackalope
1st Sergeant
Joined: Wed Jun 03, 2009 4:39 pm Posts: 36
|
 Re: TWX 2.05 Beta
Singularity wrote: Uhm. TWX scripting language is one of the easiest languages in existence to learn. Compared to even BASIC, it's very well-tailored to fit the game and simple tasks. There's very little you could do to make it easier to understand. Functions and objects, while nice for advanced users and complicated blocks of code, certainly would not make it any easier to understand for new ppl.
I think you're exaggerating quite a lot when you say twx is one of the easiest languages to learn, but whatever - like I said that's not my point. I was thinking of people like myself who are already programmers - I think Big D is saying something similar to this - and don't want to keep track of a zillion savevar and loadvar commands (not to mention the high likelihood of rampant code repetition), and also know that goto is a devil when it comes to understanding and maintaining code. I guess I should mention my heretofore implicit assumption that programmers form a large percentage of TW's potential long-term new user base. I do hope you don't come back with another rant about how easy it is to learn twx, because I think I've repeated several times now that I'm talking about concepts such as ease of use of scripts, so to speak (there's probably one or more computer science terms for what I mean, but I think you should get what I'm saying by now).
|
| Sun Jun 28, 2009 12:47 pm |
|
 |
|
The Jackalope
1st Sergeant
Joined: Wed Jun 03, 2009 4:39 pm Posts: 36
|
 Re: TWX 2.05 Beta
Big D wrote: However if these functions were used improperly by someone that doesn't have good programming skills, it could pose serious issues such as stacks, memory leaks, and system crashes. Doesn't it also depend on how well the functions functionality is implemented in twx? I guess maybe you know twx well enough to see that if functions were 'tacked on' to twx, then such serious issues would result. I don't know Delphi very well either - this type of thing would depend heavily on Delphi's garbage collection I think, which I don't have a clue about.
|
| Sun Jun 28, 2009 12:56 pm |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 Re: TWX 2.05 Beta
Quote: What about script parameters? Like the load command taking additional parameters, and scripts accepting command-line parameters? And maybe even a return value? Load as in the command "load"? You can already do that using saveVar and loadVar. A string in, a string out. Look at how mombot scripts do it. Adding a formal passed parameter would only complicate things, as suddenly people that need more than a single passed string would lose uniformity. Quote: If nothing else, the script parameters could be implemented via environment variables or even temporary files easily enough, couldn't they? Already exists in all of the above. People sometimes use setVar/saveVar and loadVar, others use setSectorParameter for sector-specific info (or just to pass generic info using sector 1). And naturally, file-based routines already exist too. Quote: I think you're exaggerating quite a lot when you say twx is one of the easiest languages to learn, but whatever - like I said that's not my point. I started in BASIC, learned pascal next, assembler, C, C++, Java, C# (ugh), PHP, Python and a myriad of other smaller languages along the way (lol @ TCL/TK). TWXproxy was certainly the easiest I've ever seen. I'm sure others may be easier, I guess LOGO is easier, but for being as effective as it is it certainly is up there. Quote: I was thinking of people like myself who are already programmers - I think Big D is saying something similar to this - and don't want to keep track of a zillion savevar and loadvar commands (not to mention the high likelihood of rampant code repetition), and also know that goto is a devil when it comes to understanding and maintaining code. I guess I should mention my heretofore implicit assumption that programmers form a large percentage of TW's potential long-term new user base. Fair enough, yes. The current syntax does lead to repetition and poor stack management. But both of those are relatively advanced issues, and can be solved thru code control. I wouldn't say those problems make it "difficult to learn," just difficult to keep track of lost bits of code. Massively large and complex scripts can become a problem, but that's solved by breaking the problem down into smaller chunks. Fortunately you can use includes and included routines to largely simplify the code repetition. And for stacks, that's why I document the crap out of my includes. The same has to be done in functions too tho, so they alone would not fix this problem. I've never seen a solution that completely replaces function comments, altho a good IDE comes close. A lot could be done by simply adding a "SerializeArray" command so we could serialize multiple 20k arrays and pass them w/ saveVar. I have a single dimension version that I use occasionally, but the kind of recursion needed to do a multi-dim serialize would make that too slow. Plus there's a complete lack of standardization there between scripters. Quote: I guess I should mention my heretofore implicit assumption that programmers form a large percentage of TW's potential long-term new user base. Perhaps. But from experience most scripters get bored and leave, there's a timeline like "playing and scripting" to "just scripting" to "done." It seems most of the older players can script a little bit, but aren't hardcore programmers. Quote: I do hope you don't come back with another rant about how easy it is to learn twx, because I think I've repeated several times now that I'm talking about concepts such as ease of use of scripts, so to speak (there's probably one or more computer science terms for what I mean, but I think you should get what I'm saying by now). Ease of use of scripts or ease of maintaining a code base? TWXproxy scripts are really easy to use, just run them and go thru the menu and done. Code base, eh, that's hairy. But that's always the case, I mean who hasn't gone back to a program they wrote 6 months later and asked "WTF was I smoking?!?" Quote: Doesn't it also depend on how well the functions functionality is implemented in twx? I guess maybe you know twx well enough to see that if functions were 'tacked on' to twx, then such serious issues would result. I don't know Delphi very well either - this type of thing would depend heavily on Delphi's garbage collection I think, which I don't have a clue about. Functions would have to be passed by value, not reference. And strictly typecast. The ability to segfault a distributed script could lead to some fun drama here, tho. But anyway. It sounds like you're not talking about ease of learning, which was the entire argument before. It sounds like you're talking about ease of maintaining (and thus re-using) code. And yes, functions would help there.
_________________ 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
|
| Sun Jun 28, 2009 1:45 pm |
|
 |
|
The Jackalope
1st Sergeant
Joined: Wed Jun 03, 2009 4:39 pm Posts: 36
|
 Re: TWX 2.05 Beta
Thanks for the thoughtful reply. Obviously I don't know enough about twx, and I guess I should go take a closer look at Mombot... although that's what led me here in the first place. I think that's a good example of one of those massively complex scripts you were talking about, and it doesn't seem to be very well documented, from what I've seen so far.
|
| Mon Jun 29, 2009 5:51 pm |
|
 |
|
Promethius
Ambassador
Joined: Mon Feb 09, 2004 3:00 am Posts: 3141 Location: Kansas
|
 Re: TWX 2.05 Beta
"Perhaps. But from experience most scripters get bored and leave, there's a timeline like "playing and scripting" to "just scripting" to "done." It seems most of the older players can script a little bit, but aren't hardcore programmers"
Sing, that is one of the more accurate assessments I've seen. It seems to follow a challenge path in regard to learning and having fun, to getting maybe too serious about the game, to just enjoying the challenge of scripting, to done.
_________________
/ Promethius / Enigma / Wolfen /
"A man who has no skills can be taught, a man who has no honor has nothing."
|
| Mon Jun 29, 2009 7:59 pm |
|
 |
|
Singularity
Veteran Op
Joined: Thu Jun 02, 2005 2:00 am Posts: 5558 Location: USA
|
 Re: TWX 2.05 Beta
Quote: I think that's a good example of one of those massively complex scripts you were talking about, and it doesn't seem to be very well documented, from what I've seen so far. It's a set of scripts, with lots of external scripts written by different authors. That makes it very difficult to manage, but easy to add on to. There's a lot of trade-offs you have to make, code has to be developed around a particular priority which means a lot of other things get tossed aside. Functions wouldn't make that any easier tho, take a look at the code base for joomla or phpBB (wordpress is better written, but still a bit messy). PHP has functions and objects, doesn't stop the code from being a mess. That's one of the advantages of having a single coder work the project, since it's easier to keep things clean. If TWXproxy goes SVN it may get a lot of new features, but it will certainly get a lot harder to understand too. As always tho documentation is up to the coder, and not everyone loves line by line commenting. I comment the crap out of my code, if you look at any of my public scripts you'll see how I do it. I do that thru my private stuff too, mostly because I tend to make incremental changes over time and would get lost if I didn't. I'm a comment whore. Managing a code base over time is one of the biggest challenges in compsci today. Well that and multi-thread processing models, hehe. I'd love to see TWXproxy go multi-thread, an 8 core chip could BFS like mad. I could plot ztm courses based on the current known map, rather than an advancing multi-pass algo. I bet I could cut a full ztm in half w/ that. Quote: Sing, that is one of the more accurate assessments I've seen. It seems to follow a challenge path in regard to learning and having fun, to getting maybe too serious about the game, to just enjoying the challenge of scripting, to done. Nod. Yea, I think it's all about the challenge aspect. People come in, start playing and the game is a challenge. A decent programmer will quickly rise thru the ranks, reaching a point where there's not much challenge left any more. Best games I've ever had were against other scripters, were the entire game was about adapting script techniques, counter-adapting, etc. I might die a lot in those games, but they're fun. Entire techniques can evolve from those kind of games, but after a few of those you get way past the regular player base. I mean how many people have a 2 man pwarp-furb unlim team SST? Or have a planet SST that gets ore as it goes, can stairstep flee, and adjust cannon settings every move? Not many, so when some guy tries to run turboSST in a week-old unlim without realizing they're in midgame... they quickly get creamed without any recourse. At some point, scripting is the only challenge left. Then that gets boring and real life takes over. There are a couple challenges left for me, some of the bigger ones that are insanely CPU intensive. If I ever solve those, I'd be done.
_________________ 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
|
| Tue Jun 30, 2009 12:10 am |
|
 |
|
Promethius
Ambassador
Joined: Mon Feb 09, 2004 3:00 am Posts: 3141 Location: Kansas
|
 Re: TWX 2.05 Beta
EP, are we still on for an 07/04 release date?
_________________
/ Promethius / Enigma / Wolfen /
"A man who has no skills can be taught, a man who has no honor has nothing."
|
| Wed Jul 01, 2009 12:44 am |
|
 |
|
Who is online |
Users browsing this forum: Google [Bot] and 31 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
|
|