Hello, and welcome to a tutorial for all those noobs who want to learn ModPe! I'll be covering the basics here, and make a more advanced tutorial for more advanced people (that's self-explanatory).
Here's The Start!
First, you'll need to understand hooks. These are what call in events to happen. Here's a list :
function useItem (x, y, z, itemId, blockId)
function attackHook (attacker, victim)
function procCmd (cmd)
function modTick ()
function newLevel ()
function leaveGame ()
See those? Those are hooks. These are incredibly vital to learning JavaScript and ModPE. I'll go over them in detail below.
function useItem (x, y, z, itemId, blockId)
This makes an event happen when you use a certain item on/or a certain block. x,y,z marks the point you use it.
function attackHook (attacker, victim)
This makes an event happen upon hitting an enemy. YOU are the attacker and the foe is the victim. This is important!
function procCmd (cmd)
This helps you create Commands! This is quite useful!
function modTick ()
This causes an event to happen every game tick. Not a second mind you, but a tick. This is ridiculously fast!
function newLevel ()
This causes an event to happen upon entering a world!
function leaveGame ()
This causes something to happen when you leave a world. Not too sure how this will be helpful though.
Got it? I hope so. Time to go on!
Setting Up Your Script
The way you should set-up your Script is muy importante (very importante) .
Here's how I do it.
function useItem (x,y,z,itemId,blockId)
{
}
This is a good start.
I'll keep working on this, I need to go for now. I'll work heavily on making this a great tutorial for everyone. Be back some other time! PEACE!
Rollback Post to RevisionRollBack
Zu'u los drog!
I am secretly a modder, who works only for himself, seldom publishes.
function deathHook(murderer, victim) //when a mob dies
function entityAddedHook(entity) //when an entity enters the world. E.g. Arrow, snowball, etc.
function entityRemovedHook(entity) //when an entity is removed from the game. E.g. Arrow, snowball, etc.
There might be more but not that I know of
Rollback Post to RevisionRollBack
Willing to work on Android apps or multi-platform games, see profile bio for information.
function deathHook(murderer, victim) //when a mob dies
function entityAddedHook(entity) //when an entity enters the world. E.g. Arrow, snowball, etc.
function entityRemovedHook(entity) //when an entity is removed from the game. E.g. Arrow, snowball, etc.
There might be more but not that I know of
THANKS! I needed that.
Rollback Post to RevisionRollBack
Zu'u los drog!
I am secretly a modder, who works only for himself, seldom publishes.
Wiki-ize it or move it to https://github.com/connor4898/modpe-scripts/wiki so that we can help improve itAlso you should explain javascript syntax firstSomeone pins this thread to avoid duplication.
Rollback Post to RevisionRollBack
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
Javascript (ModScript) tutorial
A must-read for noobs to modding
If you know modding please help me find the mistakes.
Post not finished.
I am not making an independent thread for this because there should be as little duplication as possible for things like this.
Normally, I would advise people to read w3schools, but it is in fact for html. So I decided to include syntax of javascript.
First, let's go into the basic script syntax:
A script is made up of functions. A function is something the reader (i.e. BlockLauncher) would operate its contents.
Basically you can delete all line breaks (i.e. what is inserted when you press 'enter'. A few exceptions are explained below.
The format of a function:
function functionName(parameterOne, parameterTwo){
//contents of the function
/*comment*/
}
The code in each line after the symbol // will be ignored until there is a next line. The ones surrounded by /* and */ are also ignored. These are called comments.
The function name can be anything, but to let BlockLauncher run it, you must use a particular name.
These functions are called hook functions, whose contents are modder-defined.
What are functions that are not hooks? I will explain later.
These are a list of hook function names, as of BlockLauncher version 1.5.2:
function useItem(x,y,z,item,block,side){
}
function destroyBlock(x,y,z,side){
}
function attackHook(attacker,victim){
}
function procCmd(cmd){
}
function deathHook(murderer,victim){
}
function newLevel(){
//BlockLauncher calls this when a world is loaded.
}
function leaveGame(){
//Self-explaining
}
function modTick(){
// called every 1/20 seconds.
}
/
This three functions have no parameters. What are parameters?
For example, when the player taps a bedrock block (bedrock's id: 7) holding an iron sword (iron sword's id: 267), how can you be informed what is the coordinates and type of the block, and which side of it is tapped, and that the player is holding an iron sword?
The answer is parameters. Parameters are a kind of local variables.
What are variables?
A variable is a value, that can be an integer, a decimal number, a piece of text (in computer language called a string), a player, a mob, an entity... basically everything can be saved through a variable. A variable can be accessed through a variable name, acceptable characters are CAPITAL or lowercase letters, numbers 1-10 and _ (only acceptable at the middle). They are called just like algebra, except that you cannot do 3a but a*3.
Variables can be classified into local and global. A local variable is deleted when the function has ended, and a global variable is deleted when the script is unloaded (i.e. leave game).
To define a non-parameter local variable, the code is:
var varName = /*value*/;
The value can be the following:
85365.3477 (any numbers)
A function with a
'Shbdjkfu48$*(-&9)-oy'
"%+%Yfhiugkue"
' and " have no difference, bu
I'm trying my best to make it easy to understand.
Rollback Post to RevisionRollBack
Zu'u los drog!
I am secretly a modder, who works only for himself, seldom publishes.
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
Please help editing it. You see, I deleted the mess in the second half.200 posts
Rollback Post to RevisionRollBack
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
How would I do it for like if I type "test" I'd get a block, or place a block! Thanks!
Put it in ur signature like I do for modPE.enjin.com...
I know, but my signature is quite full, and I am not in the mood to do signature trial-and-see-if-it-is-in-4-lines things.
Rollback Post to RevisionRollBack
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
To post a comment, please login or register a new account.
Here's The Start!
First, you'll need to understand hooks. These are what call in events to happen. Here's a list :
function useItem (x, y, z, itemId, blockId)
function attackHook (attacker, victim)
function procCmd (cmd)
function modTick ()
function newLevel ()
function leaveGame ()
See those? Those are hooks. These are incredibly vital to learning JavaScript and ModPE. I'll go over them in detail below.
function useItem (x, y, z, itemId, blockId)
This makes an event happen when you use a certain item on/or a certain block. x,y,z marks the point you use it.
function attackHook (attacker, victim)
This makes an event happen upon hitting an enemy. YOU are the attacker and the foe is the victim. This is important!
function procCmd (cmd)
This helps you create Commands! This is quite useful!
function modTick ()
This causes an event to happen every game tick. Not a second mind you, but a tick. This is ridiculously fast!
function newLevel ()
This causes an event to happen upon entering a world!
function leaveGame ()
This causes something to happen when you leave a world. Not too sure how this will be helpful though.
Got it? I hope so. Time to go on!
Setting Up Your Script
The way you should set-up your Script is muy importante (very importante) .
Here's how I do it.
function useItem (x,y,z,itemId,blockId) { }This is a good start.
I'll keep working on this, I need to go for now. I'll work heavily on making this a great tutorial for everyone. Be back some other time! PEACE!
I am secretly a modder, who works only for himself, seldom publishes.
There might be more but not that I know of
Willing to work on Android apps or multi-platform games, see profile bio for information.
Founder and CEO of Temena Development
Twitter: @TemenaPE
Instagram: @ItsLiterallyMath
THANKS! I needed that.
I am secretly a modder, who works only for himself, seldom publishes.
No problem. I could also help with the tutorial, and you should make a website for it.
Maybe even a Github
Willing to work on Android apps or multi-platform games, see profile bio for information.
Founder and CEO of Temena Development
Twitter: @TemenaPE
Instagram: @ItsLiterallyMath
Thanks! I'm planning on expanding today.
I do have a website! Not too developed though : here
By the way, could you help explaining how to use those functions you told me? I don't know how yet. xD
I am secretly a modder, who works only for himself, seldom publishes.
would something like this work?
function procCmd (cmd) { if cmd=='test' { print 'test worked!' } }or...???
Thanks!
MattdaveMatt
Actually, the set-up of a command is very complicated. Here's what it should be :
function procCmd(cmd) { var Data = cmd.split(" "); if(Data[0]=="test") { print("Test worked!"); } }I am secretly a modder, who works only for himself, seldom publishes.
PM me with whatever you need help with.
Willing to work on Android apps or multi-platform games, see profile bio for information.
Founder and CEO of Temena Development
Twitter: @TemenaPE
Instagram: @ItsLiterallyMath
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumCalled when a door is opened or closed
and:
Which is called every three seconds for chests to announce to open their closed/open state.
Did I help?
Would be awesome if I recieved a +1 if i did
Check out my game! It's an open-world, sandbox text adventure.
Follow @hexdro_
Hexdro © 2012-2015
A must-read for noobs to modding
If you know modding please help me find the mistakes.
Post not finished.
I am not making an independent thread for this because there should be as little duplication as possible for things like this.
Moved to here: https://github.com/Connor4898/ModPE-Scripts/wiki/ModPE-and-Javascript-Tutorials-(Basics-for-everyone)
I'm trying my best to make it easy to understand.
I am secretly a modder, who works only for himself, seldom publishes.
I never knew that wiki existed..
I am secretly a modder, who works only for himself, seldom publishes.
Please help editing it. You see, I deleted the mess in the second half.200 posts
'Grats. Sure, you can move it, but don't delete this post please. I need something to do.
I am secretly a modder, who works only for himself, seldom publishes.
Thanks!
How would I do it for like if I type "test" I'd get a block, or place a block! Thanks!
Put it in ur signature like I do for modPE.enjin.com...