Morrowind Script Checker

Post » Sun Jul 17, 2011 8:20 pm

Morrowind Script Checker

This is an early version of my script checker for MW.

Features

1. Syntax Highlighting.
2. Intellisense (WIP: 45%)
3. Basic error checking. (WIP: Constantly being improved.)
4. Wiki lookup feature.

Syntax Highlighting

1. Supports: Morrowind, Tribunal, and Bloodmoon commands. (MWSE: Coming soon.)
2. Highlights: Keywords, commands, special globals, and custom variable names.

Note: Variables will be highlighted after pressing the "Check Script" button.

Intellisense

1. Supports a number of "->" commands(WIP), and shows a brief description of each function it currently supports.

Note: Intellisense can be accessed at anytime by pressing "F1".

Formatting\Error Checking

The script checker tries to find, and fix many formatting issues for you, it also has basic error checking, simply press the "Check Script" button to anolyze the script at any time.

Wiki Lookup

You can now double left click any valid script command, which will highlight the text, then double right click the highlighted text, this will open up the corresponding Wiki page in your default browser. (Firefox, etc,.)

Note: You can also manually select the text, then double right click it. (I may change the method for doing this, perhaps a right click context menu with a "View Wiki" button, or similar.)

Note: For now it let's you look up stuff that probably doesn't exist on the Wiki, but only real commands, ie, "To", etc,. I'll try to filter out things you shouldn't be able to lookup in a future update.

Other Features

1. Tab Indent. (ie, highlight a block of text, then press tab to indent the selected text.)

Known Issues

1. Scripts containing comments like this ;************* cause the editor to malfunction(it just screws up the text, nothing too bad.). (I'll see what I can do about it. For now, don't use that style of commenting, and remove them from scripts that do before using "Check Script".)

Requirements

1. .Net Framework v4.0

http://www.microsoft.com/download/en/details.aspx?id=17851

Installation

1. Just run the included "Setup.exe".

Note: The file is installed under Microsoft on your start menu. (Don't know why it's doing that, probably need to fix a setting somewhere.)

Removal

1. Go to your control panel, and remove the program via "Add\Remove Programs" or "Programs & Features", etc,.

-------------------------

Updates:

1. Wiki lookup feature added. (Double left click any valid command in the editor, this will highlight the text, then double right click it, this will open up the Wiki page containing information on using the selected command.)

2. More script formatting features. (ie, "if DoOnce", get's replaced with "if ( DoOnce )", etc,. I fixed a few small formatting bugs, and removed some console only commands from the editors database, etc,.)

There were lot's of internal updates, and probably features I'm forgetting to mention..

Download
http://www.mediafire.com/?7pw7gcy3eb0tlwx

Image
http://imageshack.us/photo/my-images/835/59673242.png/
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Mon Jul 18, 2011 12:00 am

Wow, that far after just two days....can't wait to see what becomes of this! I will definately use this for the mods I make patches for and fix up!
User avatar
Leonie Connor
 
Posts: 3434
Joined: Mon Mar 12, 2007 4:18 pm

Post » Sun Jul 17, 2011 5:39 pm

Wow, that far after just two days....can't wait to see what becomes of this! I will definately use this for the mods I make patches for and fix up!


Yeah, syntax highlighting, and intellisense will be really helpful, but the script parser is what I really hope I can pull off.

Basic parsing isn't bad, but some stuff is pretty hard to do.

For example, I can detect mismatched if\endif blocks, however, actually parsing out where it's happening is another story. :)

I have some pretty useful features implemented, aside from what I mentioned already.

1. Script name errors. (ie, _MyScript, or missing script names, etc,.)
2. Begin\End mismatch errors. (Or missing.)
3. Brace errors. (ie, it will replace "(DoOnce)" with "( DoOnce )".)
4. Keyword formatting. (ie, "Set" becomes "set", "Float" becomes "float", etc,.)
5. Comment formatting. (ie, ";Comment" would become "'; Comment".)

Here is what a formatted script looks like.

Spoiler

Begin aaaNaturalHealing; First Runshort DoOnce; Timerfloat Timerfloat UpdateInterval; Healthfloat HealthPercentagefloat CurrentHealthfloat MaxHealth; Willpowerfloat WillPercentagefloat CurrentWill; Fatiguefloat Strengthfloat Agilityfloat Endurancefloat FatiguePercentagefloat CurrentFatiguefloat MaxFatigue; Modifiersfloat BottomLimitfloat HealthModifierfloat UpdateModifier; Combat Detection ( Workaround: Combat Detection )float LastHealth; Heal Valuefloat HealValue; First Runif ( DoOnce == 0 )	set BottomLimit to 0	set HealthModifier to 0.025	set UpdateModifier to 5	set DoOnce to -1endif; MenuMode Check ( Stop Processing )if ( MenuMode == 1 )	returnendif; Weapon Drawn ( Stop Processing )if ( Player->GetWeaponDrawn == 1 )	returnendif; Spell Readied ( Stop Processing )if ( Player->GetSpellReadied == 1 )	returnendif; Fully Fatigued ( Stop Processing )if ( Player->GetFatigue == 0 )	returnendif; Get Current Health Percentageset HealthPercentage to ( Player->GetHealthGetRatio ); Fully Healed ( Stop Processing )if ( HealthPercentage >= 1.0 )	returnendif; Bottom Limitif ( HealthPercentage < BottomLimit )	returnendif; Increment Timerset Timer to ( Timer + GetSecondsPassed ); Calculate Update Intervalset UpdateInterval to ( UpdateModifier / HealthPercentage ); Updateif ( Timer >= UpdateInterval )	; Get Current Health	set CurrentHealth to ( Player->GetHealth )	; Taking Damage ( Workaround: Combat Detection )	if ( CurrentHealth < LastHealth )		set Timer to 0		set LastHealth to ( CurrentHealth )		return	else		set LastHealth to ( CurrentHealth )	endif	; Get Max Health	if ( HealthPercentage > 0 )		set MaxHealth to ( CurrentHealth / HealthPercentage )	else		set MaxHealth to 0	endif	; Get Current Willpower	set CurrentWill to ( Player->GetWillpower )	; Calculate Willpower Percentage	set WillPercentage to ( CurrentWill / 100 )	; Get Current Fatigue	set CurrentFatigue to ( Player->GetFatigue )	; Get Max Fatigue [ Sum of: Strength, Willpower, Agility, and Endurance. }	set Strength to ( Player->GetStrength )	set Agility to ( Player->GetAgility )	set Endurance to ( Player->GetEndurance )	set MaxFatigue to ( Strength + Agility + Endurance + CurrentWill )	; Calculate Fatigue Percentage	set FatiguePercentage to ( CurrentFatigue / MaxFatigue )	; Calculate Heal Value	set HealValue to ( MaxHealth * HealthModifier * WillPercentage * FatiguePercentage )	; Add HealValue	Player->ModCurrentHealth HealValue	; Reset Timer	set Timer to 0.00endifEnd




Any script you run through it will follow the same general rules. (ie, "Begin", instead of "begin", lowercase variable declarations, etc,.)

Note: I did most of that script myself, the tool did a bit, but it does represent what the tool generates,. (It's been ran through a number of times, I've been using that script to test out new features, etc,.)
User avatar
Charlotte X
 
Posts: 3318
Joined: Thu Dec 07, 2006 2:53 am

Post » Mon Jul 18, 2011 5:15 am

Are you using a parser generator (like antlr)?

If not, i really advise it, since doing a parser by hand is kinda... complex.

Very complex.
(btw a parser generated by a generator tells you for free where most - syntactic - errors happen)
User avatar
neen
 
Posts: 3517
Joined: Sun Nov 26, 2006 1:19 pm

Post » Sun Jul 17, 2011 6:47 pm

Are you using a parser generator (like antlr)?

If not, i really advise it, since doing a parser by hand is kinda... complex.

Very complex.
(btw a parser generated by a generator tells you for free where most - syntactic - errors happen)


Actually, I was doing it by hand. :)

Mainly for the challenge. (My other programming project is learning to RE stuff, so I can create tools like MWSE\OBSE\etc..)

But yeah, that tool looks like it might be something I should consider using, at least for now, it's looking like it's going to take a lot of complex data manipulation to really parse scripts like the CS does, and even more to surpass it.

Thanks for pointing me towards that tool\lib, I'll check it out, see how well it works with my existing setup, etc,. :)
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Mon Jul 18, 2011 7:33 am

Hmmm perhaps not to get off topic. Does anyone have a list of the compiled op-codes that the MW script uses? I may be adding that in as part of SM, but that would be in a while...
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Mon Jul 18, 2011 8:17 am

Hmmm perhaps not to get off topic. Does anyone have a list of the compiled op-codes that the MW script uses? I may be adding that in as part of SM, but that would be in a while...


I'm assuming you refer to things like "AddItem", correct? If so the UESP wiki has a list of all the commands.

Otherwise, I can't help ya. (Referring to the games internal op-codes, etc,. MWSE's source might be able to help.)
User avatar
Lilit Ager
 
Posts: 3444
Joined: Thu Nov 23, 2006 9:06 pm

Post » Sun Jul 17, 2011 7:56 pm

There is a new version up, the details are in the top post.

Short version.

1. Lot's of general improvements, more auto-formatting stuff implemented, etc,.
2. Wiki lookup function.

I'm going to try to get the rest of the intellisense stuff done in the next update, which will have this mostly done in terms of being a script editor. (Still a ways to go on becoming a script parser..)

Anyways, give it a try, it should be better than any of the alternatives at this point.

-------------

If someone wants to compile a list of MWSE commands that would be great, something like..

"FunctionName", "[MWSE] Description of the function." - (Uses: ->)"FunctionName", "[MWSE] Description of the function." // Leave this last part blank if it doesn't use ->

User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm

Post » Mon Jul 18, 2011 4:31 am

If someone wants to compile a list of MWSE commands that would be great
They should be listed in http://sourceforge.net/projects/mwedit/ Functions.dat.
User avatar
Davorah Katz
 
Posts: 3468
Joined: Fri Dec 22, 2006 12:57 pm

Post » Sun Jul 17, 2011 9:46 pm

They should be listed in http://sourceforge.net/projects/mwedit/ Functions.dat.


I see, thanks. :)

Though, my request still stands, it would really speed up the process, that format is custom to their software, and I still have to figure out how the functions work to understand which intellisense list they belong in.. (ie, uses ->, or doesn't.. Which means I have to compile the list twice, or invent a system to split a single list into the appropriate list on a per command basis.)

I still have to copy\paste half the Wiki for intellisense for the vanilla stuff, so with MWSE that's another huge chunk of work, and then I believe MWE\MGE, etc, have commands that need compiled, and added into my own tools format, etc,. These also need added into the syntax highlighting database. (This isn't getting into the complexity of writing the script parser, even using a lib as suggested above, it's not easy. In fact, it may be easier to write my own, than learning how to use that lib..)

So feel free to chip in, someone, anyone, the project will be better for it, or at least done quicker. ;)
User avatar
Unstoppable Judge
 
Posts: 3337
Joined: Sat Jul 29, 2006 11:22 pm

Post » Sun Jul 17, 2011 6:14 pm

I can't help with the MWSE stuff, but I can say that this will certainly come in handy. It's a shame that the CS's script compiler doesn't give much in the way of feedback when things go wrong. I especially hate not having a search & replace function. :brokencomputer:
User avatar
Jessie Rae Brouillette
 
Posts: 3469
Joined: Mon Dec 11, 2006 9:50 am


Return to III - Morrowind