learngs2:helloworld

Hello World

Whenever you learn a new language, the first step is often to perform what is known as a “Hello World”: it's a simple script that just prints out that statement but it confirms your environment has been set up. We can use this to test that your RC access has been setup and you know what to go.

The code looks like this:

function onCreated() {
  echo("Hello, World!");
}

Don't worry if none if this makes sense right now: we will dive into all aspects as we go. For now, we can under stand that the moment this NPC is created, it will print “Hello, world!” somewhere. Let's make it happen!

First, we will hit the 'Weapons' button in RC:

This will open a list of all the current Weapons in the server. For Testbed, this will be a lot.

From here, we want to press the 'Add' button down the bottom. This will open a prompt where we can enter the name for our weapon. If you are using the Testbed server, you will need to follow the standard naming convention. For me, this would be Personal/Twinny/HelloWorld . You would replace 'Twinny' with your account name. If you are unsure, open your rights and check what rights you have been given [TODO: prob add dedicated section]

When you hit OK, it will open a new window where you can create your weapon but it hasn't done so yet. It will only do so when you hit Apply. For now, enter the code as provided above:

Hit Apply and hopefully you will successfully create your first script and see the output in RC!

You've made your first successful script…hopefully! If you didn't see 'Hello, world!' you may have seen an error instead. Some examples:

Twinny prob: No write rights for WEAPONS/Personal/NotMe/HelloWorld

This is telling me I don't actually have rights to create a weapon with this name. If you see something like this, you will need to check your rights to confirm what weapons you can create (if any). [TODO: elaborate]

If you have been successful, we can move on! Let's go!

  • learngs2/helloworld.txt
  • Last modified: 2023/02/24 12:12
  • by twinny