Optimizing mill script, and tracking uses

Post » Tue May 07, 2013 2:22 pm

Hey again everyone,

I'm trying to track how many times the player helps out at the lumber mill. Two simple things count as helping: Loading a log onto the sawmill, and pulling the lever to send them through the blade.

However, as the sawmill object is a heavily scripted 'resource' object, I had my work cut out for me. So, I combined the ResourceObjectScript and ResourceObjectSawmillScript into one custom script, and then cut out all the extra garble about sabotage, repairing, etc. So, I have two questions:

1. Can this script be simplified any more? It was around 350 lines when I combined the two, but I've managed to cut out the excess stuff and I'm down to a mere 106 lines, but I'm not an expert on a lot of the stuff used here (Like states) so I was wondering if I could remove/combine/optimize anything else here. Sorry for the lack of indentation, pasting into the browser doesn't seem to carry that over. I'll edit this post and add it in to the best of my abilities so you guys can read it more easily. Also, I just tested in game and this script seems to work just fine with my modifications thus far.

Spoiler

2. How can I add my own script fragments into this to increase a global variable by 1 every time the player does one of the two aforementioned actions? I'm using a global to track their 'help' so they can collect pay from the lumberjack (Thus resetting the global to 0). There doesn't seem to be any event for loading the log in originally, and activation is done from a lever to put the saw through the mill. Do I need to put a script on the lever that checks the mill's state, then adjusts the global accordingly? And what about tracking when the player loads a log in?

I appreciate any help!

Thanks,

Alexander J. Velicky

User avatar
barbara belmonte
 
Posts: 3528
Joined: Fri Apr 06, 2007 6:12 pm

Return to V - Skyrim