Members | Sign In
All Forums > Mission Scripting
avatar

Advice on best way to develop a script (yes a n00b)

posted Dec 07, 2011 00:29:08 by DrTwitch
i know that mission scripting is not for everyone and everyone has their own approach, but I want to ask how some of you "develop" and hope you will be kind.

I am sort of trying to find a good set of practices for writing a script, haivng basically not scripted a game before.

It seems that basically everything in the script happens all at once - totally event driven, and not proceedural - is this right?

I have taken apart and studied some of them (and thanks to those that put in comments so that we can view them and copy what is done.)

How do you sort an outline and organize the XML (and the document gets LOOONG).

thanks in advance for any information and advice you wish to provide.
---- ---- ----
here come the drums
page   1
7 replies
avatar
!Ed said Dec 07, 2011 09:05:31
Find yourself a decent editing program; for example, Notepad++
avatar
5th_Wall_Gaming said Dec 07, 2011 14:33:45
How do you sort an outline and organize the XML (and the document gets LOOONG).


Hey Thom. Any chance of the include idea I had ever happening or is that not feasible?
http://www.5thWallGaming.com
We make dreams reality
avatar
Vorus said Dec 07, 2011 15:05:07
It seems that basically everything in the script happens all at once - totally event driven, and not proceedural - is this right?

Basically, the entire script gets read each time the game looks at it. And if something in the script doesn't tell the game "Hey, you already ran that event!", then the game is going to try to run every event in the script.

So, one of the big things you have to do is make sure that each event has some way of preventing that from happening. What I do is for each event, I have a separate variable, like this:

<event>
<if_variable name="event1_started" comparator="!=" value="1"/>
DO WHATEVER HERE
<set_variable name="event1_started" value="1"/>
</event>

That way, that event can only happen one time, because it sets its own variable to 1 when it's done, so the next time the game reads the script, it doesn't get past the first line in that event. (Obviously, if you need that event again, you can have another even reset that "event1_started" variable to something other than 1, and that event will get activated again.)


That's one of the biggest things that I can think of, that someone just starting out might not grasp right away.



As far as outlining a script, my missions so far have been fairly linear, so I just write the script in chronological order. If I had a lot of branching things, I would try to put all the branches at the end, but I don't really have any better advice than that. I would say, keep the mission's end at the very end of the script, and just put good comments around confusing parts of the script.

It's generally considered bad programmer's practice, but I like to have a good amount of "whitespace" around confusing parts of anything I code. So, if I have to put something like a branching event in, I want there to be extra space between it and whatever was before it, so that when I'm scrolling through days or weeks later, I'll notice that, and read the comments, and know what I was doing the first time.

I can't really think of anything else, I've never been that good at teaching people things, but I hope I haven't confused you, at least. :P
[Last edited Dec 07, 2011 15:06:10]
-----------
Khomerex nal Khesterex

The unofficial Artemis Wiki, your best source for Artemis Information
avatar
DrTwitch said Dec 07, 2011 21:56:59
thanks for the advice! i will see what i can do to make up a simple mission or two.

so how often is the file checked? i noticed timers, etc. in the system.


i agree about the possibility of the include file, that could be a big help, i have found that to be the case in scripting other programs.
---- ---- ----
here come the drums
avatar
Vorus said Dec 08, 2011 00:58:40
I don't actually know how often it is checked, I've wondered that myself. It must definitely be more often than once per second, I'm guessing its considerably more frequent than that.
-----------
Khomerex nal Khesterex

The unofficial Artemis Wiki, your best source for Artemis Information
avatar
Mike_Substelny said Dec 08, 2011 23:50:15
The file is read once at the moment the mission is launched.

My experiments show that the mission file is read every time you launch the mission, but some associated files (e.g. WAV sound files) are not re-read if you launch the mission again. So you can play your mission, change the script, save the XML file, and play again to see the changes. But if you change a WAV file, save it, and play again you won't hear the new sound.

I use xmlpad pro.

I haven't found a best practice for organizing mission scripts yet, though I do like to put long missions in chapters (or sectors for "Truce or Consequences").

I'm trying to write "The Pegasus Passage" backwards, starting at the end and working my way back to the beginning. The idea is the part I'm working on will always be near the top, but it isn't working out as well as I'd hoped. Of course Pegasus has a huge START block, so it might not be a good example and I will try that strategy again with my next mission script.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
DrTwitch said Dec 09, 2011 15:26:02
Thanks for this advice Mike.

The file is read once at the moment the mission is launched


i sort of misspoke.
i was wondering once the mission file is in memory how often is it "processed" by the program.

basically if i raise a condition, do things just happen? (i am still stuck in the mind set of loops, branching, etc.)

so if i just set a timer i can just refer to it?

I was looking at the Verse.xml mission and there are random number generators in there that go off every second(?).

sorry to be dense on this. this is just such a new way of thinking.
---- ---- ----
here come the drums
Login below to reply: