Talk:Complete Example Scripts

From the CreationKit Wiki
Revision as of 20:43, 15 February 2012 by imported>Cipscis (→‎Standards)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Standards

I'd like to make sure that the example scripts contained on this page are ones that are likely to be useful to readers. In my opinion there are a few things that are particularly likely to make a script useful in this way. For example:

  • Demonstrating a solution to a common problem
  • Demonstrating an advanced technique
  • Demonstrating usage of a difficult function

A lot of the time, though, such scripts would be more useful in other places. For example, if a script demonstrates well how a difficult function could be used, then it would probably be better suited on the documentation page for that function.

I think scripts included in this page should be ones that are:

  • Simple
    Ideally scripts on this page should be kept short and only perform a single function. Perhaps they should be something that could be used as a starting point for a more complex script.
  • Well documented
    • Both on this page and in their comments and variable/custom function names. If people are going to use these scripts, it's important that they're easy to understand and have good self documentation.
    • I think it would be best if the behaviour of a script is documented internally, and any setup required in the Creation Kit is documented on this page.
  • Reusable
    • In Papyrus, we can use properties to define behaviour without referring to any content in the data file itself. For example, the script used for Skyrim's "Transmute" spell is written such that it could be reused on another spell that transmutes a different set of items. Scripts on this page should be set up so that they apply to a generic situation.

When writing a script, there are basically two things that have to be done:

  • Detect an event
  • Do something

Because I'd like to keep scripts on this page as simple as possible, I think it would be best if each example it mainly about one of these things - it should either show how to capture a certain event or how to do something.

If the script is detecting a certain event, then the "do something" bit of the script should be kept separate if possible. Instead of putting some example code in there, I'd recommend a comment, like this:

ScriptName OnPlayerActivateScript extends ObjectReference
{This script detects when the object to which it is
attached is activated by the player, then does something}

Event OnActivate(ObjectReference akActionRef)
	if (akActionRef == Game.GetPlayer())
		; Do something
	endif
EndEvent

Likewise, when a script is mainly about "doing something", if at all possible a very simple event should be used, such as OnActivate, so as not to complicate the script any further.

If it's not possible to separate the event detection from the script's action, then it's probably worth reconsidering whether the script would be useful to have on this page.


In order to prevent this page from containing hundreds or thousands of scripts, only particularly useful scripts should be here. There will be many examples that meet the standards I've defined here, but if we put them all on this page it will become too difficult to find anything. Ideally, the examples here would be simple examples that are commonly sought after.

Currently, I don't think the examples on this page fit the standards I have in mind for it. Before I go about "cleaning it up", does anyone have any objections, criticisms or other comments on the standards that I've laid out here?

-- Cipscis 20:43, 15 February 2012 (EST)