Spellscript Tutorial

From Hack/Mine Wiki
Revision as of 20:52, 23 February 2013 by 69.246.185.35 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a guide on how to get started creating Spellscript scripts in Minecraft. See Spellscript for a general language reference-- otherwise, read on...

Using Spellscript-Blocks

To get started, go ahead and place a Spellscript-Block as an Op on a server (you can find them in the Creative inventory.) By default, it's name will be "Untitled Spellscript-Block", and it's content will be "pass" (a statement which equates to "Do nothing"). For your first program, we're going to print "Hello world!" to your chat screen! Simply replace "pass" with the following:

if activator is None:
    return

if not (activator instanceof Player):
    return

Player player = activator as Player
player.tell("Hello world!")

We'll break this down and explain what's happening, but first, go ahead and left-click the block to make sure everything's working. Was "Hello world!" printed on your chat console? Good! You've written your first Spellscript script! Pretty simple, sure, but it's a good starting point.

activator is a variable referring to the entity that activated the block (in this case, you!) None is a special value indicating a value of "nothing". If activator is None, the block wasn't activated directly by an entity, so we don't do anything-- thus, we return, which means we cease execution, basically.

<to be continued...>

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox