Last active
June 28, 2017 04:26
-
-
Save jwulf/a6e5f930a71d494223404f80c9b11ca9 to your computer and use it in GitHub Desktop.
Magikcraft Spells, by jwulf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function _fb() { | |
// magik.doNTimes(()=> magik.infierno(), 10, 500); | |
magik.dixit('FIREBALLZ!!'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function a() { | |
magik.dixit("Hello"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function clearTimers() { | |
magik.getPlugin().scheduler.cancelAllTasks(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function comet(){ | |
const Fireball = magik.type('entity.Fireball'); | |
const TNT = magik.type("entity.EntityType").PRIMED_TNT; | |
const sender = magik.getSender(); | |
//var arrow = player.getWorld().spawnEntity(sender.location, org.bukkit.entity.EntityType.ZOMBIE); | |
for (var i = 0; i < 50; i++) { | |
const loc = rndBlock(15,15).location; | |
const arrow = sender.getWorld().spawnEntity(loc, TNT); | |
//arrow.setShooter(sender); | |
var v = sender.getEyeLocation().getDirection().multiply(2); | |
v.setX(0); | |
v.setY(0); | |
v.setZ(0); | |
//magik.dixit(loc); | |
arrow.setVelocity(v); | |
//arrow.setMetadata("ArrowType", new MyMetadata(this, "stick")); | |
} | |
} | |
function randn_bm() { | |
const u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
const v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
let ret = 0; | |
for (let i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(radius, height) { | |
return magik.getSender().getLocation().getBlock().getRelative(rnorm(0, radius/5), rnorm(0, radius/5), rnorm(0, radius/5)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
//debug | |
function d(spell){ | |
let thing= magik; //magik.dixit | |
//thing = keys.map(function(k) {return magik[k].toString();}); //obviously going to be too long | |
const keys = getKeys(magik); | |
if (isNumeric(spell)) { | |
thing = magik[keys[parseInt(spell)]]; | |
} else if (typeof(spell) == 'string') { | |
thing = magik[spell]; | |
if (typeof(thing) == 'undefined') { | |
thing = eval(spell); | |
/*if (typeof(thing) == 'object') { | |
magik.dixit("nested"); | |
thing = getKeys(thing); | |
}*/ | |
} | |
} else { | |
thing = keys; | |
} | |
const msg = thing.toString(); | |
magik.dixit(msg); | |
magik.dixit(encodeURI("http://abznak.com/echo?q="+msg)); | |
} | |
function getKeys(obj) { | |
var keys = []; | |
for (var key in obj) { | |
// if (obj.hasOwnProperty(key)) { | |
keys.push(key); | |
// } | |
} | |
return keys; | |
} | |
function isNumeric(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
magik.dixit('Initiating Game Loop'); | |
if (gameloop) { | |
magik.clearInterval(gameloop); | |
} | |
let T1, BossBarAPI; | |
var gameloop = magik.setInterval(doLoop, 1000); | |
function doLoop() { | |
const state = T1.state; | |
let bgl = T1.state.bgl; | |
const insulinOnBoard = T1.state.insulinOnBoard; | |
const carbsOnBoard = T1.state.carbsOnBoard; | |
const insulinAbsorptionRate = insulinOnBoard / 80 + 0.0025; | |
if (insulinAbsorptionRate>0){ | |
// magik.dixit("AbsorptionRate: " + insulinAbsorptionRate); | |
} | |
// do Insulin Absorption | |
if (insulinOnBoard > 0) { | |
const newInsulin = insulinOnBoard - insulinAbsorptionRate; | |
if (newInsulin > 0) { | |
T1.state.insulinOnBoard = newInsulin; | |
} else { | |
T1.state.insulinOnBoard = 0; | |
} | |
// do BGL Absorption | |
if (T1.state.bgl > 0) { | |
const bglAbsorbed = insulinAbsorptionRate * 0.8; | |
const newBGL = T1.state.bgl - bglAbsorbed; | |
if (newBGL > 0) { | |
T1.state.bgl = newBGL; | |
} else { | |
magik.dixit("Aaaaaarggggh!"); | |
T1.state.bgl = 0; | |
} | |
} | |
} | |
// Do BGL increase | |
if (T1.state.insulinOnBoard == 0) { | |
T1.state.bgl += 0.1; | |
} | |
// magik.dixit("Insulin: " + T1.state.insulinOnBoard); | |
const insulin = T1.state.insulinOnBoard; | |
T1.bars.insulin.setProgress(insulin); | |
bgl = T1.state.bgl; | |
T1.bars.bgl.setProgress(bgl); | |
if (bgl > 0.2 && bgl < 0.4) { | |
T1.bars.bgl.setColor(BossBarAPI.Color.GREEN); | |
} else { | |
T1.bars.bgl.setColor(BossBarAPI.Color.RED); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
// explode | |
function e(n=30, repeats=1, delay=200) { | |
const sender = magik.getSender(); | |
sender.getLocation().getWorld().createExplosion(magik.aspecto(),n); | |
repeats--; | |
//magik.dixit(sender.isSneaking() ? "yes" : "no"); | |
if (sender.isSneaking()) { | |
magik.dixit("e done via sneak"); | |
return; | |
} | |
if (repeats > 0) { | |
var task = magik.setTimeout( | |
() => { | |
e(n, repeats, delay); | |
}, | |
delay | |
); | |
} else { | |
magik.dixit("e done"); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function exec(cmd) { | |
const args = [].slice.call(arguments).join(' '); | |
eval(args); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fb(repeats = 200, delay = 400) { | |
magik.dixit('Fireball!'); | |
const sender = magik.getSender(); | |
const fireball = magik.type("entity.Fireball").class; | |
const hurl = (thing) => () => sender.launchProjectile(thing) | |
const volley = () => magik.doNTimes(hurl(fireball), repeats, delay, null); | |
magik.doNTimes(volley, repeats, delay*10, null); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fireball() { | |
magik.infierno(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fireworks(name) { | |
var there = magik.aspecto(); | |
magik.doNTimes(function () { magik.stella(there); | |
magik.iacta(name);}, 1000, 300); | |
magik.iacta(name); | |
magik.stella(there); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fly(){ | |
magik.volare(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fz() { | |
function run(cmd) { | |
var sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
const flyingZombieCmd = 'summon minecraft:zombie ~ ~ ~ {ArmorItems:[{},{},{id:"minecraft:elytra",Count:1b},{}]}'; | |
run(flyingZombieCmd); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
let T1; | |
function getState() { | |
magik.dixit(JSON.stringify(T1)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function h() { | |
magik.dixit(__http__); | |
magik.dixit(__http__.httpGet); | |
const http = { get: __http__.httpGet}; | |
magik.dixit(http); | |
magik.dixit(http.get); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function heal(name) { | |
magik.auxilium(name); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function helloworld() { | |
magik.dixit("¡Hello Tim!"); | |
magik.doNTimes((count) => {magik.dixit(count)}, 5); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function insulin() { | |
const item = 'POTION' | |
const AWKWARD = magik.type('potion.PotionType').AWKWARD; | |
const MATERIAL = magik.type("Material"); | |
const Potion = magik.type("potion.Potion"); | |
const i = new Potion(AWKWARD); | |
const ItemStack = magik.type("inventory.ItemStack"); | |
const thing = new ItemStack(i); | |
magik.getSender().getInventory().addItem(Potion); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function jail(r, typ, force, fire) { | |
if (r == '?') { | |
magik.dixit("/cast jail <r> <typ> <force> <fire>"); | |
magik.dixit("r - radius"); | |
magik.dixit("typ - material type (e.g. FIRE, TNT)"); | |
magik.dixit("force - "); | |
magik.dixit(" 1 - replace even solid blocks"); | |
magik.dixit(" ! - replace only solid blocks"); | |
magik.dixit("fire - "); | |
magik.dixit(" 1 - set the resulting sphere on fire"); | |
magik.dixit(" o - surround the resulting sphere in obsidian"); | |
return; | |
} | |
r = parseInt(r) || 10; | |
typ = typ || 'LEAVES'; | |
var block = magik.aspecto().getBlock(); | |
drawSphere(block, r, typ, force); | |
if (fire) { | |
if (fire == 'o') { | |
drawSphere(block, r+2, 'OBSIDIAN', false); | |
} else if (fire == 'g') { | |
drawSphere(block, r+2, 'GLASS', false); | |
} else { | |
drawSphere(block.getRelative(0, 2, 0), r, 'FIRE', false); | |
} | |
} | |
} | |
function drawSphere(block, r, typ, force) { | |
const Material = magik.type("Material"); | |
sphere(block, r, function(block, x,y,z) { | |
var doit = false; | |
if (force == '1') { | |
doit = true; | |
} else { | |
doit = !block.getType().isSolid(); | |
if (force == '!') { | |
doit = !doit; | |
} | |
} | |
if (doit) { | |
block.setType(Material[typ]); | |
} | |
}); | |
} | |
function sphere(block, r, fn) { | |
var max2 = (r+1) * (r+1); | |
var min2 = (r-1) * (r-1); | |
for (var x = -r; x < r+1; x++) { | |
for (var y = -r; y < r+1; y++) { | |
for (var z = -r; z < r+1; z++) { | |
var dist2 = x*x+y*y+z*z; | |
if (min2 <= dist2 && dist2 <= max2) { | |
fn(block.getRelative(x,y,z), x,y,z); | |
} | |
} | |
} | |
} | |
} | |
function randn_bm() { | |
var u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
var v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
var ret = 0; | |
for (var i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(loc, radius, height) { | |
return loc.getBlock().getRelative(rnorm(0, radius/5), runif(0, height), rnorm(0, radius/5)); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const jwulf = require('jwulf'); | |
let globalVar; | |
function jayz() { | |
jwulf.test(); | |
magik.dixit(`Global var: ${JSON.stringify(globalVar)}`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function jump(power = 100) { | |
magik.exsultus(power); | |
magik.dixit("Yo, wassup!!!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function l() { | |
const Material = magik.type('Material'); | |
const looking = magik.aspecto(); | |
const world = magik.getSender().getWorld(); | |
function p5() { | |
const x0 = looking.getX(); | |
const y0 = looking.getY(); | |
const z0 = looking.getZ(); | |
function blast(X,Z, Y) { | |
const location = looking; | |
location.setX(X); | |
location.setZ(Z); | |
world.strikeLightning(location); | |
let b = world.getBlockAt(location); | |
while(b.getType().equals(Material.AIR)){ | |
Y--; | |
location.setY(Y); | |
b = location.getBlock(); | |
} | |
world.getBlockAt(location).setType(Material.OBSIDIAN); | |
} | |
const r = 8; | |
const items = 40; | |
for(let i = 0; i < items; i++) { | |
const x = x0 + r * Math.cos(2 * Math.PI * i / items); | |
const z = z0 + r * Math.sin(2 * Math.PI * i / items); | |
blast(x,z,y0); | |
} | |
} | |
const x = looking.getX(); | |
const y = looking.getY(); | |
const z = looking.getZ(); | |
function blast(X, Z) { | |
const location = looking; | |
location.setX(X + Math.random() * 10 - 5); | |
location.setZ(Z + Math.random() * 10 - 5); | |
world.strikeLightning(location); | |
} | |
magik.doNTimes(() => { | |
magik.doNTimes(() => { | |
magik.doNTimes(() => {blast(x,z)}, 15)}, | |
15)}, | |
15, p5); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
// lightning | |
// lpc - lightning per circle | |
// cc - circle count | |
function l2(lpc = 10, cc = 3, i = 0, delay = 100) { | |
const m = 30; | |
const sender = magik.getSender(); | |
magik.dixit("l2 - "+ m + " " + i + " " + delay); | |
const oldloc = magik.hic(); | |
const target = magik.hic(); | |
i++; | |
for (var k = 0; k < m; k++) { | |
target.setYaw(360/m*k); | |
target.setPitch(90 - i * 5); | |
magik.ianuae(target); | |
magik.shakti(); | |
} | |
if (sender.isSneaking()) { | |
magik.dixit("l2 done via sneak"); | |
return; | |
} | |
if (i < cc) { | |
var task = magik.setTimeout( | |
() => { | |
l2(lpc, cc, i, delay); | |
}, | |
delay | |
); | |
} else { | |
magik.dixit("l2 done"); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function listen() { | |
const user = magik.getSender().getName(); | |
const EventCallback = Java.type("io.magikcraft.EventCallback"); | |
const PlayerInteractEvent = magik.type("event.player.PlayerInteractEvent"); | |
const EventPriority = magik.type("event.EventPriority"); | |
magik.getPlugin().registerEvent( | |
PlayerInteractEvent.class, | |
EventPriority.MONITOR, | |
true, | |
new EventCallback({ | |
callback: function(event) { | |
const username = event.player.getName(); | |
if (username !== user) { | |
return; | |
} | |
magik.getPlugin().getServer().getPlayer(username).sendMessage(`Interact event: ${username} : ${user}`); | |
} | |
})); | |
magik.dixit(PlayerInteractEvent); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function localise(lang = 'en') { | |
const nextTick = magik.setTimeout; | |
function series(arr, ready = null, safe = true) { | |
var length = arr.length | |
, orig | |
if (!length) return nextTick(ready, 1) | |
let handleItem = (idx) => { | |
arr[idx]((err) => { | |
if (err) return ready(err) | |
if (idx < length - 1) return handleItem(idx + 1) | |
return ready() | |
}) | |
} | |
if (safe) { | |
orig = handleItem | |
handleItem = (idx) => { | |
nextTick(() => { | |
orig(idx) | |
}, 1) | |
} | |
} | |
handleItem(0) | |
} | |
function run(cmd) { | |
var sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
const strings = [ | |
{ | |
name: 'tutorial_welcome', | |
strings: | |
{ | |
no: | |
[ | |
'Velkommen til', | |
'&6The Land of Kigam&r', | |
'i', | |
'&3The World of &4&uMagikcraft' | |
], | |
en: [ | |
'Welcome to', | |
'&6The Land of Kigam&r', | |
'in', | |
'&3The World of&r &4&uMagikcraft' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_magik', | |
strings: | |
{ | |
no: [ | |
'--- &4&uMagi&r ---', | |
'er en kraft som lar folk', | |
'gj[ø]re &6umulige ting&r', | |
'ved [å] si &6spesielle ord&r' | |
], | |
en: [ | |
'--- &4&uMagik&r ---', | |
'Is a power that allows people', | |
'to do &6impossible things&r', | |
'by saying &6special words&r' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_01', | |
strings: { | |
no: [ | |
'Hei, jeg heter M.', | |
'&4&u¡¡¡¡¡¡Hjelp!!!!!!&r', | |
'&dSuperMegaCorp&r', | |
'stjal all &4&magien&r', | |
'i Kigamriket.' | |
], | |
en: [ | |
'Hello, my name is &aM&r.', | |
'&4&u¡¡¡¡¡¡Help!!!!!!&r', | |
'&dSuperMegaCorp&r', | |
'stole all the &4&umagik', | |
'in the realm of Kigam.' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_02', | |
strings: { | |
no: [ | |
'Modige mennesker ble med', | |
'og sammen slo vi', | |
'SuperMegaCorp.', | |
'Men &4&umagien&r ble tapt!!!' | |
], | |
en: [ | |
'Brave people joined me', | |
'and together we beat', | |
'&dSuperMegaCorp&r.', | |
'But &4&umagik&r was lost!!!' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_03', | |
strings: { | |
no: [ | |
'Nå ønsker &dSuperMegaCorp&r', | |
'å få tilbake magien.', | |
'Finn trylleformlene før de finner dem,', | |
'og ta dem med tilbake til', | |
'&a&uAsgard Romstasjon&r!' | |
], | |
en: [ | |
'Now &dSuperMegaCorp&r', | |
'wants to get the &4&umagik&r back.', | |
'Find the magik words before they do', | |
'and bring them to', | |
'the &a&uAsgard Space Station&r!' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_04', | |
strings: { | |
no: [ | |
'--- &dSuperMegaCorp&r ---', | |
'vær advart:', | |
'All &4&umagi&r tilhører', | |
'&dSuperMegaCorp&r.', | |
'Inntrengere vil bli forfulgt.' | |
], | |
en: [ | |
'--- &dSuperMegaCorp&r ---', | |
'Be Warned:', | |
'All &4&umagik&r is the property of', | |
'&dSuperMegaCorp&r.', | |
'Trespassers will be persecuted.' | |
] | |
} | |
}, | |
{ | |
name: 'tutorial_chap_05', | |
strings: { | |
no: [ | |
'Du må bruke &4&umagi&r', | |
'for å komme ut herfra', | |
'&f[|||] &4[|||] &f[|||]', | |
'Finn det magiske ordet.' | |
], | |
en: [ | |
'You need to use &4&umagik&r', | |
'to get out of here', | |
'&f[|||] &4[|||] &f[|||]', | |
'Find the magik word' | |
] | |
} | |
}, | |
{ | |
name: 'tutorialwarp', | |
strings: { | |
no: [ | |
'--- &aM&r ---', | |
'Takk for den du er, og hva du gjør', | |
'for folket i Kigam.', | |
'Skriv inn /warp Lounge', | |
'det vil ta deg til det neste området.', | |
'Fortsett med det, og så ses vi snart!' | |
], | |
en: [ | |
'--- &aM&r ---', | |
'Thank you for who you are', | |
'and what you are doing', | |
'for the people of Kigam.', | |
'Type in &u/warp Lounge', | |
'it will take you to the next area.', | |
'Keep doing you, and see you soon!' | |
] | |
} | |
}, | |
{ | |
name: 'congrats', | |
strings: { | |
no: [ | |
'Gratulerer!!!' | |
], | |
en: [ | |
'&4&uCongratulations!!!&r' | |
] | |
} | |
}, | |
{ | |
name: 'arthur', | |
strings: { | |
no: [ | |
], | |
en: [ | |
"'''Any sufficiently advanced technology", | |
'is indistinguishable from magic', | |
'- Arthur C. Clarke' | |
] | |
} | |
}, | |
{ | |
name: 'jungle-instructions', | |
strings: { | |
no: [ | |
'Finn ingrediensene for trylleformelen', | |
'Det finnes fem stykk...', | |
'Du trenger bare tre stykk til en trylleformel' | |
], | |
en: [ | |
'Find the ingredients to make spell with', | |
'&aThere are five of them...&r', | |
'&aYou only need three for a spell&r' | |
] | |
} | |
}, | |
{ | |
name: 'flight_cast', | |
strings: { | |
no: [ | |
'Bluk "remember"-trylleformelen her' | |
], | |
en: [ | |
'Cast your remember spell here' | |
] | |
} | |
}, | |
{ | |
name: 'flight-goback', | |
strings: { | |
no: [ | |
'Fant du det magiske ordet? Det er tilbake, bak deg...' | |
], | |
en: [ | |
"Did you find the magik word? It's back, behind you..." | |
] | |
} | |
}, | |
{ | |
name: 'flight-end-menu', | |
strings: { | |
no: [ | |
'Fant du den hemmelige passasjen gjennom fossen?', | |
'Gå tilbake for å finne den: &4&u/warp lounge&r', | |
'Gå videre til neste eventyr: &4&u/warp flight2&r' | |
], | |
en: [ | |
'Did you find the secret passage through the waterfall?', | |
'To go back to find it: &4&u/warp lounge&r', | |
'To go on to the next adventure: &4&u/warp flight2&r' | |
] | |
} | |
}, | |
{ | |
name: 'flight2-instructions', | |
strings: { | |
no: [ | |
'Fly hele veien i ett hopp!' | |
], | |
en: [ | |
'Fly all the way in one jump!' | |
] | |
} | |
}, | |
{ | |
name: 'flight2-end', | |
strings: { | |
no: [ | |
'Gratulerer!', | |
'Prøv igjen: &4&u/warp flight2&r', | |
'Gå til neste eventyr: &4&u/warp jungle&r' | |
], | |
en: [ | |
'Congrats!', | |
'To try again: &4&u/warp flight2&r', | |
'To go to the next adventure: &4&u/warp jungle&r' | |
] | |
} | |
}, | |
{ | |
name: 'kigam-volcano-exit', | |
strings: { | |
no: [ | |
'Denne veien tilbake til Kigam Town!', | |
'/ \\ / \\' | |
], | |
en: [ | |
'Stairway' | |
] | |
} | |
}, | |
{ | |
name: 'initial_welcome', | |
strings: { | |
no: [ | |
'Velkommen til &uMagikcraft', | |
'Bruk W, A, S, D til å bevege deg.', | |
'Beveg musen for å kunne se deg rundt.', | |
'Når du er klar, følg stien' | |
], | |
en: [ | |
'Welcome to &uMagikcraft', | |
'Use W,A,S,D to move. Move your mouse to look', | |
'Once you get that, follow the path' | |
] | |
} | |
}, | |
{ | |
name: 'initial_jumping', | |
strings: { | |
no: [ | |
'Trykk på mellomromstasten for å hoppe' | |
], | |
en: [ | |
'Use the Spacebar to jump' | |
] | |
} | |
}, | |
{ | |
name: 'initial_portal', | |
strings: { | |
no: [ | |
'&uMagkicraft&r is connected with &uPortals', | |
'Gå gjennom her for å gå til opplæringsnivået' | |
], | |
en: [ | |
'&uMagkicraft&r is connected with &uPortals', | |
'Walk though, and it will take you to the tutorial level' | |
] | |
} | |
} | |
/*, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
}, | |
{ | |
name: '', | |
strings: { | |
no: [ | |
'' | |
], | |
en: [ | |
'' | |
] | |
} | |
} */ | |
]; | |
strings.forEach(hologram => { | |
hologram.strings[lang].map((text, line) => | |
run(`hd setline ${hologram.name} ${line + 1} ${text}`) | |
); | |
}); | |
} | |
/* | |
Finn de tre ingrediensene - før Zombiene kommer!! | |
Si din huskeformel her | |
Fant du det magiske ordet? Det er tilbake, bak deg... | |
Fant du den hemmelige gangen gjennom fossen? | |
For å gå tilbake for å finne den: /warp lounge | |
For å gå videre til neste eventyr: /warp flight | |
Fly hele vegen i ett hopp! | |
Grattis! | |
For å prøve igjen: /warp flight | |
For å gå videre til neste eventyr: /warp jungle | |
] | |
} | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function look() { | |
const where = magik.aspecto(); | |
magik.dixit(`X: ${where.getX()}`); | |
magik.dixit(`Y: ${where.getY()}`); | |
magik.dixit(`Z: ${where.getZ()}`); | |
magik.dixit(`Pitch: ${where.getPitch()}`); | |
magik.dixit(`Yaw: ${where.getYaw()}`); | |
magik.dixit(`World: ${where.getWorld()}`); | |
magik.dixit(`String: ${where.toString()}`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function magikcarpet() { | |
magik.declaro('elytra'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const say = magik.dixit; | |
const MCT1 = require('mct1'); | |
function mct1(cmd = 'start') { | |
say('Yo, mct1 all up in here'); | |
MCT1().then((mct1) => { | |
say(cmd); | |
const controlr = mct1.controller; | |
if (cmd === 'start') { | |
return controlr.start(); | |
} | |
if (cmd === 'stop') { | |
return controlr.stop(); | |
} | |
if (cmd === 'reset') { | |
controlr.reset(); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function mvtp(worldname) { | |
run("mv tp " + worldname); | |
function run(cmd) { | |
var sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
let global_test_var = 0; | |
function newSpell() { | |
let n = magik.setInterval(()=> { | |
magik.dixit(`global_test_var: ${global_test_var}`); | |
global_test_var ++; | |
}, 1000); | |
magik.setTimeout( | |
()=> { | |
magik.dixit('Timer cancelled'); | |
magik.clearInterval(n); | |
}, | |
5000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function path(typ = 'STONE'){ | |
const Material = magik.type("Material"); | |
const blocks = magik.getSender().getLineOfSight(null,50); | |
blocks.forEach(b => b.getRelative(0, -2, 0).setType(Material[typ])); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const platforms = magik.global('sitapati.platforms'); | |
const layers = []; | |
const say = magik.dixit; | |
function platformz(levels = 5, radius = 15, space = 4) { | |
function run(cmd) { | |
const sender = magik.getSender(); | |
magik.getPlugin().getServer().dispatchCommand(sender, cmd); | |
} | |
function addY(loc, y) { | |
const newLoc = loc.clone(); | |
newLoc.setY(newLoc.getY + y); | |
return newLoc; | |
} | |
if (!platforms.initialised) { | |
magik.dixit("Initialising..."); | |
platforms.initial_position = magik.hic().clone(); | |
layers[0] = platforms.initial_position; | |
layers[1] = addY(layers[0], 1); | |
for (let i = 2; i < levels + 2; i++) { | |
layers[i] = addY(layers[i-1], space); | |
say(layers[i]); | |
} | |
layer('bedrock', layers[0]) | |
layer('lava', layers[1]); | |
platforms.initialised = true; | |
} else { | |
magik.dixit("Already Initialised..."); | |
magik.ianuae(layers[0]); | |
} | |
for (let i = 2; i < levels + 2; i++) { | |
layer('glass', layers[i]) | |
} | |
function layer (material, location) { | |
magik.ianuae(location); | |
const cmd = `/cyl ${material} ${radius} 1` | |
run (cmd); | |
magik.dixit(cmd); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function pubtest() { | |
eventbus.publish('sitapati.msg', 'Hello from the eventbus'); | |
eventbus.publish('sitapati.msg', {ok: true}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function remember(name = 'default') { | |
const memory = ((contents) => { | |
if (!contents) { | |
return {}; | |
} | |
if (!contents.default) { | |
return { | |
default: contents | |
} | |
} | |
return contents; | |
})(magik.exmemento()); | |
const here = magik.hic(); | |
if (!memory.default || name == 'default') { | |
magik.dixit(`Saving ${name}`); | |
memory['default'] = here; | |
} | |
if (name !== 'default') { | |
magik.dixit(`Saving ${name}`); | |
memory[name] = here; | |
magik.dixit(memory[name]); | |
} | |
magik.memento(memory); | |
magik.dixit(here.toString()); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sb(repeats = 200, delay = 100) { | |
magik.dixit('Snowball!'); | |
const sender = magik.getSender(); | |
const snowball = magik.type("entity.Snowball").class; | |
const hurl = (thing) => () => sender.launchProjectile(thing) | |
const volley = () => magik.doNTimes(hurl(snowball), repeats, null, delay); | |
magik.doNTimes(volley, repeats, null, delay*10); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function see() { | |
magik.noxvida(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sendLoreToUser(username, lorename) { | |
const domain = 'http://localhost:8086'; | |
const route = 'api/v1/sendLoreToUser'; | |
const API_key = '6B73F512-5C17-431B-831D-F368BA6CC0D1'; | |
const url = `${domain}/${route}/${API_key}/${username}/${lorename}`; | |
http.dispatchMQ('GET', url, null); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function sname() { | |
magik.dixit(SERVERNAME); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function spawnz(typ='ZOMBIE', n = 50, times = 5, baseloc){ | |
const EntityType = magik.type("entity.EntityType"); | |
const sender = magik.getSender(); | |
if (typ == '.') { | |
typ = undefined; | |
} | |
if (!baseloc) { | |
baseloc = create_spawn_point(magik.aspecto()); | |
} | |
for (let i = 0; i < n; i++) { | |
const loc = rndBlock(baseloc.getBlock().getRelative(0, 0, 0).location, 4,0).location; | |
const typ2 = typ || rnd_monster_type(); | |
const mob = loc.getWorld().spawnEntity(loc, EntityType[typ2]); | |
const v = sender.getEyeLocation().getDirection().multiply(2); | |
const dir = Math.PI*2*Math.random(); | |
const scale = 0.45; | |
v.setX(scale*Math.sin(dir)); | |
v.setY(scale*2); | |
v.setZ(scale*Math.cos(dir)); | |
mob.setVelocity(v); | |
} | |
times -= 1; | |
if (times > 0) { | |
const task = magik.setTimeout( | |
() => { | |
spawnz(typ, n, times, baseloc); | |
}, | |
200 | |
); | |
} | |
} | |
function create_spawn_point(loc) { | |
const block = loc.getBlock(); | |
const r = 1; | |
const depth = 3; | |
const Material = magik.type("Material"); | |
const spawnloc = block.getRelative(0, -depth, 0).getLocation(); | |
//explicitly clear a space | |
for (let y = -depth; y <= 0; y++) { | |
var rr = Math.floor(r); //for changing the shape of the hole. I liked no slope, in the end | |
for (let x = -rr; x <= rr; x++) { | |
for (let z = -rr; z <= rr; z++) { | |
block.getRelative(x,y,z).setType(Material['AIR']); | |
} | |
} | |
} | |
//explode that space, for effect and to mess up the shape a little | |
//spawnloc.getWorld().createExplosion(spawnloc,3); | |
return spawnloc; | |
} | |
function rnd_monster_type() { | |
return 'ZOMBIE' | |
} | |
function rnd_from_array(arry) { | |
return arry[Math.floor(Math.random()*arry.length)]; | |
} | |
function randn_bm() { | |
const u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
const v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
let ret = 0; | |
for (let i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(loc, radius, height) { | |
return loc.getBlock().getRelative(rnorm(0, radius/5), runif(0, height), rnorm(0, radius/5)); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function subtest() { | |
const say = magik.dixit; | |
if (global.sub) { | |
say(global.sub.toString()); | |
say(__eventbus__.topiclist); | |
say('Cancelling existing subscription'); | |
global.sub.unsubscribe(); | |
} | |
say('Subscribing ') | |
global.sub = eventbus.subscribe( | |
'sitapati.msg', | |
data => magik.dixit(data.data.toString()) | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
const Bars = magik.Bars; | |
const TextComponent = magik.TextComponent; | |
let T1; | |
function t1() { | |
T1 = { | |
state: | |
{ | |
insulinOnBoard: 0.2, | |
bgl: 0.4 | |
} | |
} | |
var insulinBar = Bars.addBar(magik.getSender(), | |
new TextComponent("Insulin"), | |
Bars.Color.BLUE, | |
Bars.Style.NOTCHED_20, | |
T1.state.insulinOnBoard, // Progress (0.0 - 1.0) | |
); | |
var bglBar = Bars.addBar(magik.getSender(), | |
new TextComponent("BGL"), | |
Bars.Color.RED, | |
Bars.Style.NOTCHED_20, | |
T1.state.bgl // Progress (0.0 - 1.0) | |
); | |
T1.bars = { | |
insulin: insulinBar, | |
bgl: bglBar | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
magik.dixit(SCRIPTING_ENGINE_PLAYER); | |
magik.dixit(java.lang.System.getenv("MAGIKCRAFT_API_DIR") + '/' + SCRIPTING_ENGINE_PLAYER + '/api/'); | |
const greet = require('myapi/greet'); | |
function test() { | |
magik.dixit("Test"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function unsubscribe() { | |
global.sub.cancel(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function z(n = 50) { | |
function run(cmd) { | |
const sudo = magik.getPlugin().getServer().getConsoleSender(); | |
magik.getPlugin().getServer().dispatchCommand(sudo, cmd); | |
} | |
for (let i = 0; i < n; i++) { | |
run('summon zombie'); | |
magik.dixit(`z ${i}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment