PDA

View Full Version : If you want to use scripts, but hesitate to edit them...



Saffith
03-06-2007, 09:57 PM
I know making even minor changes to scripts can be intimidating to non-scripters, so I threw together a program to alleviate that problem. This will let you modify constants that control a script's behavior within limits set by its author. It doesn't require you to edit the file directly, so you don't have to worry about screwing anything up.
This is a prototype of something I'd like to integrate into ZQuest eventually—even for those who are comfortable editing scripts, it would be more convenient. I doubt it'll make it into 2.5; if not, I'll continue developing this separately until at least the next version.
Scripts have to be specifically made to work with the program, so you can't use it with any that are already out there. I've provided a demo script, but, as written, it doesn't work in ZC quite yet.
Also, this only works with ZScript at the moment, but I do intend to add support for ZASM.
Suggestions for interface improvements and better names would be welcome.

ZScript Modifier (http://users.wpi.edu/~absutman/zscript/zscriptmodifier/zsm.exe)
Demo script (Vacuum.z) (http://users.wpi.edu/~absutman/zscript/zscriptmodifier/Vacuum.z)

The source code's in Ruby. I used RubyScript2Exe (http://www.erikveen.dds.nl/rubyscript2exe/index.html) to compile a Windows executable. The code should work on Mac and Linux as it is.

zsm.rb (http://users.wpi.edu/~absutman/zscript/zscriptmodifier/zsm.rb)



Now, for those of you who actually write scripts, here's a file that illustrates the current format.

zsmtest.z (http://users.wpi.edu/~absutman/zscript/zscriptmodifier/zsmtest.z)

I'm open to suggestions on how it might be done differently. I like how this style blends in with regular comments, so you can easily insert extra notes for people editing the file manually without them looking out of place. However, the symbols are pretty arbitrary, and will only become more so with added functionality. Javadoc style might be preferable for its meaningful tags. Maybe something between the two, like ignoring lines that don't start with /// and determining their meaning from Javadoc-like tags.
Of course, nothing like those will work with ZASM. That's going to need a whole different format.

Obviously, there are a lot more features that could be added to this. Here's what I've thought of so far:
- When a script is loaded, show a description of the script itself and what each argument does
- Hexadecimal numbers
- Allow int values to be selected from a list rather than simply setting a minimum and maximum
- Let actual values be offset from given values (e.g. user enters 1-4, actual value is 0-3)
- Determine one value from multiple inputs (e.g. if a number is 0-127 and 0 has a special meaning, ask about that separately)
- Skip or change the meaning of some constants depending on values given earlier
If anyone has more ideas, let me know.

Plissken
03-07-2007, 12:08 AM
Thank you so much! I am about to take some classes that will help me with scripting but before that this is extremely useful.

Nimono
03-07-2007, 12:15 AM
Does this thing only work on constants? If so, that's very limiting. And I mean LIMITING. I've never once used a constant in my scripts that isn't in std.zh...

Saffith
03-07-2007, 12:32 AM
I've never once used a constant in my scripts that isn't in std.zh...Yes, but I've noticed you frequently use variables where constants would work as well.
And, really, it's not so limiting. If you want to change the initial value of a variable, you can just make a new constant for that. That's generally a better design, anyway, as it's easier to change.

Nimono
03-07-2007, 12:33 AM
Yes, but I've noticed you frequently use variables where constants would work as well.
And, really, it's not so limiting. If you want to change the initial value of a variable, you can just make a new constant for that. That's generally a better design, anyway, as it's easier to change.

Well, actually, when I made those scripts, I never truly knew about constants... XD I'll remember that in the future. ;)