walterhiggins / ScriptCraft

Write Minecraft Plugins in JavaScript.
MIT License
1.84k stars 379 forks source link

creating a new entity class #121

Closed peterrham closed 10 years ago

peterrham commented 10 years ago

Hi, I started experimenting with scriptcraft a couple of weeks ago. Well done and thanks so much! This is a great idea and I'm trying to write some simple mods for my kids and interest them in programming.

I volunteer a bit at the codedojo kids programming lessons here in Seattle.

I'm just getting my head around the minecraft architecture and have code some beginning modding tutorials and a few examples in scriptcraft.

I noticed that some of the readme files are not up to date yet, but I think that you already know that.

Looks like there's no obvious, non-deprecated way to load .js filed directly. I was searching for that for a while.

Anyway, looks like one cannot create new entity types in scriptcraft. Any suggestions?

Also, if there's a better forum to post on. Google groups? Then let me know. Thanks again! Peter

walterhiggins commented 10 years ago

Hi Peter,

Looks like there's no obvious, non-deprecated way to load .js filed directly. I was searching for that for a while.

you could require('./name-of-file.js'); (replacing name-of-file.js with your own filename). Or you can use scload() (it will work with regular .js files, I just prefer if people used require() instead) https://github.com/walterhiggins/ScriptCraft/blob/master/docs/API-Reference.md#scload-function

Anyway, looks like one cannot create new entity types in scriptcraft. Any suggestions?

You're right. To extend any of the existing Entity Interfaces you'd need to drop down to Java-level. I imagine there's a fair bit of work involved in creating a new Enity from scratch. Maybe look at the source code for an existing entity and subclass that?

https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java

Walter

peterrham commented 10 years ago

Thanks for the quick response!

Previously, I attempted "require()" and "scload()" but I failed. I will try again now with more confidence that it will work if I use them correctly.

I think that I thought that require() can only be used for "modules" and that scload() was deprecated (would fail) for non-json.

scload() function

No longer recommended for use by Plugin/Module developers (deprecated)

scload() should only be used to load .json data.

Thanks for the tip on creating a new entity type. Perhaps there's a way to simulate another entity type in scriptcraft or otherwise. I will keep looking..

Thanks again! Peter