HOW TO USE MINI WORLD API, CODE, BASIC FUNCTION
Tutorial: Recent, the Mini World has a lot of good maps. It usually uses script. Now I will tutorial about how to use basic function in the Mini World API
1. What is variable
variable has the form of letter. It does not have value. If you set your variable equal to value(number). example:
local Mini_World_Game --- It does not have value.
but if you set it is:
local Mini_World_Game = 1 --- It has value equal to 1
2. What is function
Function is the main programs. You can called and reused many times. This is function's format:
function game() --- The value: game (does not have value). You should change it to other variable name ---------action end --- If you called function, you must write "end" of the last line. It's function format. ScriptSupportEvent:registerEvent([=[GameEvent]=], Value) * GameEvent is event to activated action
Example:. When the player enters the game activated action. GameEvent is: Game.AnyPlayer.EnterGame
* Variable = Variable in function. Example:
function MWC () -----action end ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=], MWC)
Game Event
Game Event ScriptSupportEvent:registerEvent([=[Game.Start]=], Game_StartGame) ScriptSupportEvent:registerEvent([=[Game.Run]=], Game_Update) ScriptSupportEvent:registerEvent([=[Game.End]=], Game_GameOver) *Player Event ScriptSupportEvent:registerEvent([=[Player.Die]=], Player_Dead) ScriptSupportEvent:registerEvent([=[Player.Revive]=], Player_Revive) ScriptSupportEvent:registerEvent([=[Player.AddItem]=], BackPack_AddItem) *BlockEvent ScriptSupportEvent:registerEvent([=[Block.Add]=], Block_Add) ScriptSupportEvent:registerEvent([=[Block.DestroyBy]=], Block_Destroy) ScriptSupportEvent:registerEvent([=[Block.Trigger]=], Block_Trigger)
Detail: LUA EVENT Script Wiki: I have an example to practice it.
function event_chat () Chat:sendSystemMsg("THE MINI WORLD GAME") end ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=], event_chat)
Example 2:
local A = "I am" --- A is variable local B = "a boy" --- B is variable local Number = 0 function String () Chat:sendSystemMsg(B + A) --- B = "a boy", A = "I am" => B + A = A boy I am Number = Number + 1 if (Number == 1) then Chat:sendSystemMsg(A + B) --- A = "I am", B = "a boy" => A + B = I am a boy end end ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=], String)
Practice
Exercise 1: Chat string “I love Mini World” when game runs
Exercise 2: Chat string “I love Mini World” when players get power-ups