# How to edit scripts

  • Tips: copay and paste script marked black in game - trigger - script. Hit Play Mode to operate the scripts!


How to type out: Hello! Mini World, in chat box

Chat:sendSystemMsg("Hello! Mini World!")

Code Dissected:

  • Easy isn't it? Try it now in game!
  • You can replace the text in () to send out other chats.
  • If you wish to send out multiple chats, paste down more.


Spawn a Jockey in coordinate:5,7,5

World:spawnCreature(5, 7, 5, 3102)

Code Dissected:

  • Jockey is a very common mob in game, but it spawns randomly. By putting down this script, you can spawn Jockey in assigned location.
  • Paste down the code in game and give it a try! If you are a daredevil, spawn more! Of course you can change the coordinate freely.

Script Basic Syntax:

There are some common syntax that must be followed or the script will not work.

  • Words should be separated by Spaces
  • When declaring more than one variable, or more than one parameter on the same line, you need to separate them with a ","
    • How to declare variables:
      • Declear 1 variable named a, assign value to 1: local a = 1
      • Multiple variables named a, b, and c: local a, b , c = 1 , 2 , 3
  • Conditional Script:
    • Format: if() then end
    • Explanation: if ( judgement conditions ) then So if condition is true, the action written here will happen end
  • judgement conditionsHere are some examples:
    • (1 > 2) Explanation: 1 greater than 2, false
    • (1 < 2) Explanation: 1 small than 2, true
    • (1 ~= 2) Explanation: 1 not equals to 2, true
    • (1 == 2) Explanation: 1 equals to 2, false
    • (a == b) Explanation: no value assign to a and b,so it is nil(empty), which is also true. If you assigned value, it depends on whether it equals to the assigned value.

Click to learn more about lua scriptting


Place down 1 stone block in front of character

local ret1, playerId = Player:getMainPlayerUin()
local ret2, x, y, z = Player:getPosition(playerId)
local ret3, curdir = Player:getCurPlaceDir(playerId)
if curdir == FACE_DIRECTION.DIR_NEG_X then x = x+1 end
if curdir == FACE_DIRECTION.DIR_POS_X then x = x-1 end
if curdir == FACE_DIRECTION.DIR_NEG_Z then z = z+1 end
if curdir == FACE_DIRECTION.DIR_POS_Z then z = z-1 end

Block:replaceBlock(104, x, y, z, FACE_DIRECTION.DIR_POS_Y)
--Place down block ID 104, 104 is the id of stone block
-- “--”Symbols are used for comments, The script will not execute content inside “--”.

Last Update: 4/15/2020, 6:29:50 PM