Wow! Scripting in Oblivion is not easy!

Post » Tue Oct 19, 2010 9:16 am

Greetings,

OK, so thanks to a post I made in the MMM thread, I got a fire lit under me and decided, OK, this is it... I'm going to try scripting my own solution. I mean, I have a CS degree (oops, that's Computer Science... sorry for the ambiguity), and I've been a professional Java (and others) programmer for a few years... should be able to handle some video game scripts.

Logically, yes, it's pretty darn straight-forward. Syntactically, not the prettiest thing ever, but manageable I suppose. But then it starts deteriorating... Max script length???? Wow, wasn't expecting that, but OK (starting to understand the challenges modders face a little better). Digging a little deeper I find abstraction to be very difficult to achieve, if not impossible. And then the sea of functions... toss in the many OBSE versions and wow... where do you even start?

So modders, again, I tip my hat. :bowdown: (no hat tip smiley, so praise will have to suffice... it is, after all, appropriate).

Great, but why the post, right? Well, I was wondering... the CS tutorials seem so dated to me (sorry again... this time I mean Construction Set!). It seems like one could spend hours going through them only to find that you still have a ton to learn if you want to write more current, and more efficient, scripts. Is there somewhere a place that has more recent stuff with good examples? I guess that's really what I'm looking for. Any help along those lines would be awesome!

And again... to those of you that work magic with your scripts, Wow! I am even more impressed!
veg

EDIT: wording
User avatar
Anna Krzyzanowska
 
Posts: 3330
Joined: Thu Aug 03, 2006 3:08 am

Post » Tue Oct 19, 2010 5:53 pm

the worst thing is when the CS starts randomly deleting stuff (i swear, it happens)

one addtopic, setstage or getisid fails, 30 mins of testing down the pan. drives me mad
User avatar
john page
 
Posts: 3401
Joined: Thu May 31, 2007 10:52 pm

Post » Tue Oct 19, 2010 6:18 am

the worst thing is when the CS starts randomly deleting stuff (i swear, it happens)

one addtopic, setstage or getisid fails, 30 mins of testing down the pan. drives me mad

I have the exact same thing happen to me dozens of times while working on Kragenir's Death Quest. It's insane. Good to hear that it's not just me. :D
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Tue Oct 19, 2010 11:38 am

Losing the result scripts in dialogue is a frustrating pain in the butt. I ran into it repeatedly in A Brotherhood Renewed before finally realizing it's a CS bug. Adding a new topic while you have an existing one still highlighted = lost result script. Maddening.
User avatar
michael danso
 
Posts: 3492
Joined: Wed Jun 13, 2007 9:21 am

Post » Tue Oct 19, 2010 12:30 pm

Since you know programming you need to learn one thing. How to take what you want to do, write out the script, examine it, then cut it down so it still does what you want but with less scripting. Of course with OBSE things get to be beautiful when you have the extra room and functions to work with. I'm working on my own degree in sciences so I know the pain, then again I'm going for game creation, which is a whole new level of pain.
User avatar
Emmanuel Morales
 
Posts: 3433
Joined: Sat Oct 06, 2007 2:03 pm

Post » Tue Oct 19, 2010 12:33 pm

Interesting feedback so far... thanks! I do appreciate it.

Let me ask a more targeted question if I may: if I wrote an update to a script, and that was all I needed to do for now, would I just add the scripts bash tag and merge it into the bashed patch?

TIA,
veg
User avatar
Saul C
 
Posts: 3405
Joined: Wed Oct 17, 2007 12:41 pm

Post » Tue Oct 19, 2010 7:08 am

If it's strictly a modification of a script from another mod, Bash should allow you to merge the entire thing. It'll show up as green if so. Or import it, which in this case would be the same thing.
User avatar
Latino HeaT
 
Posts: 3402
Joined: Thu Nov 08, 2007 6:21 pm

Post » Tue Oct 19, 2010 4:33 pm

If it's strictly a modification of a script from another mod, Bash should allow you to merge the entire thing. It'll show up as green if so. Or import it, which in this case would be the same thing.



OK, excellent. That's just what I was looking for. I'll give it a go and see what happens. Thanks again!

EDIT: fumbling w/ my Blackberry... Sorry.
User avatar
chinadoll
 
Posts: 3401
Joined: Tue Aug 22, 2006 5:09 am

Post » Tue Oct 19, 2010 7:24 pm

I have the exact same thing happen to me dozens of times while working on Kragenir's Death Quest. It's insane. Good to hear that it's not just me. :D


yeah, i thought i had the northern front finished. i'm currently going back and checking every single quest execution, ai package, dialogue package and line of code added to check for breakages. it's gonna take weeks
User avatar
Daniel Lozano
 
Posts: 3452
Joined: Fri Aug 24, 2007 7:42 am

Post » Tue Oct 19, 2010 7:22 pm

the worst thing is when the CS starts randomly deleting stuff (i swear, it happens)
...

Yep, I've had this happen too.

Edit a script.
Save script.
Save esp.
Close the CS.
Launch Oblivion to playtest...
old bug not squished.
Open esp in the CS, then open my script...
and my previous edits are nowhere to be seen!!!

This is why I do all my scripting in an external editor (I use http://www.editplus.com/, but there are others... personal preference applies). Not only are my scripts safely saved in a folder on my desktop, but when I print them out, all the functions are highlighted, and everything is all indented and easy to walk through.

When I am ready to try out a script I'm working on, I have it open in EditPlus, hit CTRL+A, then CTRL+C, then I switch over to the CS, open my script in it's editor, hit CTRL+A, then CTRL+V, and see if it compiles.

The good code editors also have the nifty ability to save backups of files that you have edited when saving the changes. I have EditPlus set to save backups of the file I'm working on in a sub-directory of my working folder whenever I save any changes to my script. That way, if I FUBAR it, I can easily roll back to a previous state. That has saved my posterior many times.
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Tue Oct 19, 2010 11:45 am

OK, so thanks to a post I made in the MMM thread, I got a fire lit under me and decided, OK, this is it... I'm going to try scripting my own solution. I mean, I have a CS degree (oops, that's Computer Science... sorry for the ambiguity), and I've been a professional Java (and others) programmer for a few years... should be able to handle some video game scripts.

...

Digging a little deeper I find abstraction to be very difficult to achieve, if not impossible. And then the sea of functions... toss in the many OBSE versions and wow... where do you even start?

Your experience with Java and it's ever-expanding libraries should help a bit with the overwhelming number and versions of functions. :)

Seriously, I'm guessing you've gone through a fairly modern Comp. Sci. program with a focus on object-oriented programming and a proper use of abstractions for maintainable code. Game objects really are objects with usable attributes and methods, but other than that you can pretty much throw all of your Java related knowledge away. To write good scripts, focus on ideas from assembly language programming and the event-driven model.

The game itself is very object-oriented in design and implementation, but the scripts aren't really intended for more than minor modifications to existing behaviors. The script "begin" blocks are hooks to a small subset of the existing object methods triggered on specific events and you get to add code at those points. You can try to build more advanced constructs, but you'll have to abuse the generic methods like OnActivate and it's not going to be pretty. Even structured programming is a little advanced for the features available from a scripting engine. Ideas that make a good script are throwbacks to a much earlier era.
User avatar
Stacey Mason
 
Posts: 3350
Joined: Wed Nov 08, 2006 6:18 am

Post » Tue Oct 19, 2010 4:51 pm

Yeah, I've begged my husband to write an Eclipse plugin to replace the CS, no can-do, but we can dream, can't we? I created a Textpad syntax file for script files and that helps, but I've already had the CS trash my latest edits... I've had my problems with Nifskope too...

I wonder if we can ask Beth to do the CS as an Eclipse plugin next time...
User avatar
Dezzeh
 
Posts: 3414
Joined: Sat Jun 16, 2007 2:49 am

Post » Tue Oct 19, 2010 1:16 pm

Heh, I can see one thing very clearly at this juncture - You folks are gonna love CSE ;)
User avatar
lillian luna
 
Posts: 3432
Joined: Thu Aug 31, 2006 9:43 pm

Post » Tue Oct 19, 2010 9:24 pm

Heh, I can see one thing very clearly at this juncture - You folks are gonna love CSE ;)


CSE???
User avatar
Queen
 
Posts: 3480
Joined: Fri Dec 29, 2006 1:00 pm

Post » Tue Oct 19, 2010 7:51 pm

CSE???
Ah, apologies - The CSE :P
User avatar
Jynx Anthropic
 
Posts: 3352
Joined: Fri Sep 08, 2006 9:36 pm

Post » Tue Oct 19, 2010 12:18 pm

shadeMe is nothing but a tease :twirl:

And a master of understatement. CSE is worth more than mere love ;)
User avatar
sally coker
 
Posts: 3349
Joined: Wed Jul 26, 2006 7:51 pm

Post » Tue Oct 19, 2010 10:41 am

Your experience with Java and it's ever-expanding libraries should help a bit with the overwhelming number and versions of functions. :)

Seriously, I'm guessing you've gone through a fairly modern Comp. Sci. program with a focus on object-oriented programming and a proper use of abstractions for maintainable code. Game objects really are objects with usable attributes and methods, but other than that you can pretty much throw all of your Java related knowledge away. To write good scripts, focus on ideas from assembly language programming and the event-driven model.

The game itself is very object-oriented in design and implementation, but the scripts aren't really intended for more than minor modifications to existing behaviors. The script "begin" blocks are hooks to a small subset of the existing object methods triggered on specific events and you get to add code at those points. You can try to build more advanced constructs, but you'll have to abuse the generic methods like OnActivate and it's not going to be pretty. Even structured programming is a little advanced for the features available from a scripting engine. Ideas that make a good script are throwbacks to a much earlier era.

That was by far the deepest anolysis of the TESIV scripting language I've ever seen.

Personally, I've had no formal programming education what-so-ever. I picked up everything I know from running batch programs on a ACS/VTAM system while working at a bank's operations center. One whole floor of the building was a tape silo. That was in the days of punch cards and green mono-chrome monitors. I learned Assembler and some COBOL on a need-to-know basis over a five year time span.

I think the TES scripting language is most closely related to Assembler, like you said, since it is a single pass top down execution. You can perform looping if you toss OBSE into the mix.

My advice to someone diving in to TES scripting is, get the http://www.tesnexus.com/downloads/file.php?id=13176, dissect some other people's mods with it, and spend some time looking at how the logic flows. If you see something you don't understand, email the author. Nine times out of ten, they will be flattered by the fact that you are actually looking at the guts of their work. If that fails, post a message in the CS Forums... there is a lot of pretty sharp crackers there, and they are eager to help anyone who is making an effort to learn.
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Tue Oct 19, 2010 6:39 pm

CSE???

Construction Set Extender.
User avatar
Oceavision
 
Posts: 3414
Joined: Thu May 03, 2007 10:52 am

Post » Tue Oct 19, 2010 2:51 pm

Losing the result scripts in dialogue is a frustrating pain in the butt. I ran into it repeatedly in A Brotherhood Renewed before finally realizing it's a CS bug. Adding a new topic while you have an existing one still highlighted = lost result script. Maddening.

I have seen this happen several times in my mod's quests. I assumed it was caused by adding my result scripts too soon, i.e. whenever the script referred to an object that was not yet defined (some EdId, Topic, AI package, NPC or whatever) the CS would shred a lot of dialog topics in the quest I was working on. It also happened when I tried to feed the CS an info or response that were too long (more than 38 or 150 characters respectively). Since I now double check validity of the script references and text lengths I have not seen it happen anymore. :shrug:
User avatar
Dagan Wilkin
 
Posts: 3352
Joined: Fri Apr 27, 2007 4:20 am

Post » Tue Oct 19, 2010 7:38 pm

I have seen this happen several times in my mod's quests. I assumed it was caused by adding my result scripts too soon, i.e. whenever the script referred to an object that was not yet defined (some EdId, Topic, AI package, NPC or whatever) the CS would shred a lot of dialog topics in the quest I was working on. It also happened when I tried to feed the CS an info or response that were too long (more than 38 or 150 characters respectively). Since I now double check validity of the script references and text lengths I have not seen it happen anymore.

What might help is some canonical examples of good scripts, as I've seen lots of examples of bad scripts (no offence intended, I've written plenty myself in the past), and its hard for newbies to know what is/isn't worth copying. Most of the examples on the CSWiki are outdated, and there are even tutorials that walk through doing things in ways that would now be considered bad.

I'm quite proud of the scripts in my mods http://www.tesnexus.com/downloads/file.php?id=10925, http://www.tesnexus.com/downloads/file.php?id=21424, and http://www.tesnexus.com/downloads/file.php?id=13879, and anyone is free to copy them. However, they pre-date the new OBSE syntax and function extensions so they are not examples of the latest state of the art. I think maybe the latest nGCD and Progress might be better modern examples (check the Author's T&Cs before looking). I think kuertee and tejon mods are probably a good starting point for modern scripting examples.
User avatar
Stephanie Nieves
 
Posts: 3407
Joined: Mon Apr 02, 2007 10:52 pm

Post » Tue Oct 19, 2010 11:37 am

Thanks, everyone, for your input. I really appreciate it. If you can think of anything else helpful, I'm always open to suggestions.

veg
User avatar
Nancy RIP
 
Posts: 3519
Joined: Mon Jan 29, 2007 5:42 am

Post » Tue Oct 19, 2010 11:06 am

Losing the result scripts in dialogue is a frustrating pain in the butt. I ran into it repeatedly in A Brotherhood Renewed before finally realizing it's a CS bug. Adding a new topic while you have an existing one still highlighted = lost result script. Maddening.
I've been talking to my insurance people and they've given me a green light to say this - Not any more, you don't!
User avatar
benjamin corsini
 
Posts: 3411
Joined: Tue Jul 31, 2007 11:32 pm


Return to IV - Oblivion