![]() |
SE4 Scripting in Python (templatizer again)
This might not sound very impressive, but I just wrote a program that can negate a number... http://forum.shrapnelgames.com/image...s/rolleyes.gif
Why'd you do that, you might ask? Well, I'm working on an expression evaluator. OK, you ask again, why are you doing THAT? Well, this expression evaluator is going to be used in a sort of Uber-Tech-Gridder program which combines the flexibility of editing text files (ask Gandalf Parker or any other Linux junkie http://forum.shrapnelgames.com/images/icons/icon12.gif ) with the power of something like Krsqk's Component Generator. OK, it won't generate tech *grids* - it will only work in one dimension - but there will be a lot of flexibility; basically you will be able to do what Aaron's promised for SE5 with the SE4 data files - something like this: </font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Start Level := 1 End Level := 12 Name := Anti - Proton Beam [level] Description := Focused energy beam used as a medium range weapon. Pic Num := 18 Tonnage Space Taken := 30 Tonnage Structure := 30 Cost Minerals := [50 + 25 * level] Cost Organics := 0 Cost Radioactives := [10 + 10 * level] Vehicle Type := Ship\Base\Sat\WeapPlat\Drone Supply Amount Used := 5 Restrictions := None General Group := Weapons Family := 2000 Roman Numeral := [level] Custom Group := 0 Number of Tech Req := 1 Tech Area Req 1 := Energy Stream Weapons Tech Level Req 1 := [level] Number of Abilities := 0 Weapon Type := Direct Fire Weapon Target := Ships\Planets\Ftr\Sat\Drone Weapon Damage At Rng := [max(15 + level * 5 - range * 10, 0)] Weapon Damage Type := Normal Weapon Reload Rate := 1 Weapon Display Type := Beam Weapon Display := 1 Weapon Modifier := 0 Weapon Sound := apbeam.wav Weapon Family := 1</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">And the beauty of my approach is that it will apply not only to Components.txt, but also to Facility.txt and anything else you might want to have leveled items! http://forum.shrapnelgames.com/images/smilies/cool.gif" src="images/icons/cool.gif" /> Now I know that I'm not easily motivated to work on something past the first night, but I know that this program is something that the SE4 community would greatly appreciate (at least I'd think you would!) so please keep bugging me to finish it! (Or at least release the code so someone else can http://forum.shrapnelgames.com/images/icons/tongue.gif ) edit: changed topic from "Semi-OT: I just negated a number! (Really, this is interesting! ;-)" to "Math parser ready (not the data file generator - yet!)" changed topic to "SE4 Templatizer Ready for Download!" edit: changed topic to "Templatizer 3 is HERE!!!!!" [ July 25, 2004, 05:52: Message edited by: Ed Kolis ] |
Re: SE4 Templatizer Ready for Download!
I just program in basic. I hear binary is easy too, but is owned by Microsoft so that is ruled out.
|
Re: SE4 Templatizer Ready for Download!
Negate a number? As far as I know, a number is an imaginary creation designed to represent Groups or singles of something. ??
|
Re: SE4 Templatizer Ready for Download!
Will it support all sorts of funky math? Exponents, sin, custom user defined functions, etc.?
|
Re: SE4 Templatizer Ready for Download!
I'm hoping to basically put in anything that's in the .NET math library, so exponents and sines should be in. As for user-defined functions, I wasn't planning for them, but if you want to add functions, the program is designed to be extensible so you can code them yourself if you know a .NET language such as C# http://forum.shrapnelgames.com/images/icons/icon10.gif Basically, I have an Expression class with subclasses for all the different types of expressions there can be (unary operations, constants, functions, etc.) and to add a function you'd have to derive a class from one of my base classes and implement its Value property which does the actual computation.
If I ever get this working I'll post it on www.codeproject.com; my main problem is to get the input string parsed out into an expression tree... but I've read about converting to Reverse Polish Notation and that should prove helpful with everything except the functions... and the (non-user-defined) functions shouldn't be too much after that, it's just a matter of getting them to take multiple parameters... |
Re: SE4 Templatizer Ready for Download!
User defined functions are necessary to prevent having to put the same formula code in 700 entries... http://forum.shrapnelgames.com/images/icons/icon12.gif
|
Re: SE4 Templatizer Ready for Download!
Hmm, that might be doable if I just had a separate functions.txt listing all the functions and what they evaluate to; they'd just be evaluated Last in the precedence order, I guess...
|
Re: SE4 Templatizer Ready for Download!
no offense, but that's kinda like my program, i woulda posted it up, but i couldn't, here's the link to the topic:
http://www.shrapnelgames.com/cgi-bin...=011057#000000 btw, only works for non-weap components (i got bored making it, so i stopped) |
Re: SE4 Templatizer Ready for Download!
Quote:
|
Re: SE4 Templatizer Ready for Download!
Negating a number means turning 5 into -5, or -3 into 3, or whatever - basically subtracting it from zero.
|
All times are GMT -4. The time now is 06:00 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.