Talk:Complete Example Scripts

From the CreationKit Wiki
Revision as of 13:44, 12 May 2012 by imported>Scrivener07 (→‎Container Script: new section)
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)

Thinking a bit more about this, it seems to me that these standards would work quite well for another page, but "Complete Example Scripts" implies something else that is also useful.
-- Cipscis 17:57, 27 February 2012 (EST)
Perhaps if this were split into a series of helpful catagory subpages, like "Scripts for Activators", "Scripts for Sounds", "Scripts for Moving Things", and so on, it would help a user narrow down his search to the exact sort of script he or she is looking for. Otherwise it will most likely eventually be a horde of random scripts in no particular order. RedwoodElf 23:06, 8 March 2012 (EST)
That certainly sounds like a good idea to me. There's a Skyrim Script Repository on TESAlliance that's organised like this, perhaps those categories would be good starting points?
-- Cipscis 23:08, 8 March 2012 (EST)
I think having categories would be a good idea. Maybe also adding a full list at the bottom for those that could be in one place or another... I am still confused about what to put in here though. What about examples that people uses to ask about like for example having a spell place an item and getting its coordinates? That would need 3 scripts at least. Would that fit in here?
Shana 02:31, 9 March 2012 (EST)
Yes that fits here. If you want to write a complete tutorial for than it would go in Tutorials instead, otherwise here's fine. But make a new page for it. I think it's a good idea to put each example on its own page and make this a category.
--Qazaaq 06:20, 9 March 2012 (EST)

Container Script

Thanks fg for streamlining my container script. Though there may be a problem with it now. I havent tested it but it looks like the script will destroy and item not on the formlist. I think the item must be removed from the container and returned to the player. Thoughts?