Scripting

From Kemoverse
Jump to navigation Jump to search

Scripting is a way for characters to behave in-game. You can even script yourself!

Introduction

An example of a script with three options.

Scripting. What is it, anyways? Well, think of a movie script - you read it from top to bottom to check what you have to do or say next. In this case, the character script (which I call Action Script) directs what characters do and behave, including you. So if you script yourself, your character can start doing stuff by themselves without your control. A script is actually quite simple, it's just a text file that you write in the in-game script editor.

Every character has two scripts - a "life script" and an "interaction script".

  • A life script runs automatically at random, so basically, it makes your character have a life on its own. It's used to make them automatically do stuff, like walking around, sitting down, think for themselves and generally act like an NPC.
  • An interaction script is the script that does stuff in response to interaction, so when you (or someone else) walk up to an NPC (or you) and click, the interaction script will be shown.

Script files are divided in to options, basically sub-sections of both life and interaction scripts. Options are important - neither life script or interaction script will execute if you don't have options. You specify options by beginning a line with "=" and typing the title after. In interaction scripts, writing "= Hello" makes others see a button "Hello" when interacting with you, and executes the script under that option when they click it. In life scripts, writing "= random 10" tells the automated life script to execute that part of the script 10% of the time, so essentially a random choice.

SPC Mode

By default, the interaction/life scripts won't bother you as you play (you have to explicitly run the options through the "Run" button in the script editor). If someone wants to interact with you, you can approve that one interaction request by clicking on them and clicking "Answer".

However, there is a way to auto-accept any request and run your loaded scripts automatically - I name this SPC mode (SPC being Scripted Playable Character). You can enable it by pressing Alt+X or Shift+X. By enabling SPC mode, your interaction script auto-accepts any interaction, and your life script starts living out by itself, letting the game pick options based on the "= random" title.

While you typically have to load an interaction and/or life script to be used by your SPC manually, there is a way to automatically load these depending on the time of day. Scheduling is used to automate the what script is used based on the time of day.

Examples

Interaction Scripts

= Say Hello
tn t
+ Hello there.
lk left
lk right
lk l
- I'll tell you a secret.
+ What?
- I have a snail in my pocket.

Here's a short interaction script example. It presents and option to interact ("say hello"). Let's say that you wrote this script and put it on your character. If a player clicks on this option when interacting with you, it starts this script. Both players turn to each others, exchange dialog, and the script player (you) look to the left, right, then continues the dialog. As you can see, it's very easy to make a simple conversation. But there's way more than that! You can make your character walk around, animate, do facial expression... and such.

See the first word/symbol that starts on each line? It's the command - this determines what you want the character to do. After that command, you type in parameters to specify what exactly you want it to do.

Life Scripts

Let's talk quickly about life scripts. Life scripts are scripts that you can trigger to just happen randomly. They make good idle scripts for your SPC as well as allow you to automatically do somewhat complex tasks without any interaction.

= random 50
mv forward
mv back
= random 40
tn left
tn right
tn right
tn left

With this script the SPC has a 50 percent chance to move forwards and backwards and if that fails... your SPC has a 40% chance to look around. Random allows you to trigger those sections of the life script with a certain percentage chance. You can also do = random 100 to ensure the code always runs. In the next example, lets look at a script that always runs.

= random 100
eq 
eq fishingpole
eq fishingpole use
. 60
eq fishingpole use

This fishing script will always run and repeat itself. There is a 100% chance you'll cast your fishingpole, wait 60 seconds, and unreel hoping to catch a fish. This is a great simple script for automatically catching fish. Be sure to hit alt + v and run your character in Scripted Player Character mode, as this will automatically repeat your life scripts.

Script commands

Communication

There is some ways to have your SPC talk, those interacting with you talk, display grey chat messages, and display big title messages.

Tip: It could be a great idea to take advantage of chat formatting codes in the Chatting page to format chat text.

SPC Talking

- followed by something you want your scripted character to say will make it talk.

- Hello there! will make your SPC say "Hello There!" in chat.

Interactor Talking

+ followed by something you want someone interacting with you to say.

+ Hi there! will make someone interacting with your SPC say "Hi there!"

Grey Text

_ followed by something you want in chat to appear in grey color.(People see this if they are interacting with you)

_ Something spooky happens. will make "Something spooky happens." appear and be grey in chat.

Big Title Text

^ followed by something you want to see in big title letters.(People see this if they are interacting with you)

^ Super Epic Title will make "Super Epic Title" appear in giant title text in the center of the screen.

Warning: The big title text does not disappear on it's own! Please remember to add ^ with nothing else after to remove the big title letters. It can be very annoying to have it stay on your screen.

Movement

mv or move is one of the most important movement commands. There is various ways to get a character to move.

Move a direction
mv forward
mv left
mv back
mv right

You can also specify how many steps you want a character to take. mv forward 5 will move 5 steps forward.

Move to an object

mv to sera_hammock

Tip: To get the name of an object you wish to move to middle click it twice while having the script text cursor at the place you want the name to be pasted into your code.

Move to an object with a specific distance

mv to sera_hammock 3

Move up to 3 units next to sera's hammock.

It also accepts decimals such a 0.5 units.

Tip: To get the name of an object you wish to move to middle click it twice while having the script text cursor at the place you want the name to be pasted into your code.

Warning: It's important to remember that distance between something like worms, players, plants, and other objects will be entirely different depending on the size of their collision boxes. 50 units for a worm is way smaller than 50 units away from a lot of larger objects. In other words, it 5 units feels different with different objects, it probably is different. Experiment and find out exactly what distance you want per object.
Move to an exact spot

You can move to an exact spot in the world using coordinates.

mv to -38.35 1.77 41.12

Tip: To get the coordinates you can right click the life script as you are working on it and hit paste coordinates. It'll paste the current coordinates you are standing on. This is very helpful.

Stop moving

mv to stop moving.

Turning

turn or tn is a command used to turn your character.

Turn to a compass direction
tn north
tn west
tn east
tn south
Turn to face an object
tn to sera_hammock

Tip: To get the name of an object you wish to turn to middle click it twice while having the script text cursor at the place you want the name to be pasted into your code.

Turn to an exact spot

You can turn to an exact spot in the world using coordinates.

tn to -38.35 1.77 41.12

Tip: To get the coordinates you can right click the life script as you are working on it and hit paste coordinates. It'll paste the current coordinates you are standing on. This is very helpful.

Turn around a specified number of degrees
Warning: This command is likely bugged as of ALPHA 12(0.11.1). Specifying the number of degrees doesn't actually seem to properly turn you the number of degrees specified. Sometimes this command leads to randomized results as well with turning to random directions.

You can turn a certain number of degrees with tn around.

tn around 50 will make you turn around 50 degrees.

Stop turning

tn to stop turning.

Looking

lk or look is a command used to turn your head to look at something.

Look to a compass direction
lk north
lk west
lk east
lk south
Look at an object
lk to sera_hammock

Tip: To get the name of an object you wish to look at middle click it twice while having the script text cursor at the place you want the name to be pasted into your code.

Look at an exact spot

You can look at an exact spot in the world using coordinates.

lk to -38.35 1.77 41.12

Tip: To get the coordinates you can right click the life script as you are working on it and hit paste coordinates. It'll paste the current coordinates you are standing on. This is very helpful.

Stop looking

lk to stop looking.

Interaction

in or interact is a command used to interact with objects.

Interact with an object

Interacting with objects is fairly reasonable.

in sera_hammock

You can also interact with an object that has multiple interaction options.

in kitchen_chair 2

Tip: To get the correct interaction of an object you wish to interact with middle click the interaction you wish to choose twice while having the script text cursor at the place you want the interaction to be pasted into your code.

Equipment

eq or equip lets you equip, unequip, and use equipment.

Equip item

eq fishingpole equips an item in to its respective slot.

Use item

eq fishingpole use uses an item, similar to pressing the left mouse button/using "V". The item has to have been equipped already.

Unequip item

eq unequips your primary item (typically, the one you're actively holding in your hand).

eq all unequips any of your equipped items (which includes accessories and other gear attached to parts of your body).


Equipment list

A list of a few valid items to equip or use:

watergun, fishingpole, waterbucket, glowstick, stickynote, spraycan, slingshot, shovelknife, catchnet, foodbowl, phone, planner

Most items are required to be in your pack before you can use them. Exceptions are phone and planner as they kind of just always exist.

Facial Expression

fc or face lets you make a facial expression.

Expressions

fc happy for a happy expression.

fc sad for a sad expression.

fc close to close your eyes.

fc tongue to put your tongue out.

fc angry for an angry expression.

fc fear for a fearful expression.

Make expressions for a length of time

fc happy 3 will be happy for 3 seconds.

Stop expressions

fc to stop facial expressions.

Play emote

em or emote to play a specific emote.

Play emote

em yes will play the "yes" emote, the same one that plays with the chat command "/em yes" or when pressing "yes" in the emoter window.

Cancel emote

em will cancel any currently playing emote.

Wait/Delay

Wait for a certain amount of time

wait 5 waits for 5 seconds before running more of the code. Mind the space! (".5" without space doesn't mean anything)

Wait until action is finished

wait simply waits until an action like walking, fading, or other things are completed. This is a great way to ensure finishing moving to a location.

wait:Target can be used to target an action wait for a specific character.

Repeat/For Loop

For loops allow you to repeat sections multiple times. [ <number> begins a for loop and ] ends it with all code between being repeated multiple times.

As an example [ 5 followed by some code and ] afterwards would run code 5 times. See the below example.

[ 5
mv forward
. 2
]

This allows the script runner to move forward and pause for 2 seconds for a total of 5 times.

Camera control

cm or camera lets you control cutscenes, cameras, and have a few cinematic controls.

Cutscene mode

cm cs will enable cutscene mode. Cutscene mode adds black borders and the top and bottom of your screen and hides the interface.

cm will disable cutscene mode and resets the camera (ie. places it back at the player character)

Focus

cm focus returns camera focus on the player.

cm focus sera_hammock for example will allow you to focus on an object with the camera. The camera will rotate to look at the object.

Set position

cm set (coordinates) (for example, cm set 60 21.51 2.90 -13.37 -0.29 2.43 0.00) sets the camera position and aim.

This detaches from the focused item and serves as a "static" camera placement. You can get the camera coordinates by right clicking the scripting window and clicking "Paste camera".

Fading

cm fade creates a short black fade.

cm fade 0 will make the screen black instantly.

cm fade 2.5 will fade the screen from screen to black, over the course of 2.5 seconds.

cm fade -1.5 will fade the screen from black to screen, over the course of 1.5 seconds.

Remember to put wait to wait for the fade. (eg. wait 1.0 to wait one second after doing cm fade 1.0)

Fading to player

cm fadeplayer is a shorthand to fade to black, reset camera to player, then fade out (with automatic waiting).

Dissolving

cm dissolve creates a short dissolve effect (a snapshot of the screen is faded out to a new shot).

Blurring

cm blur 2.0 toggles a blurry effect on the screen with 2.0x power.

cm blur toggles the blurry effect off.