trouble following 'beginners guide to writing plugins...'
johndgreene opened this issue · 6 comments
i'm following the book beginners guide to writing minecraft plugins in javascript with my 11 year old son. we're making pretty good progress and it's mostly working. we are not getting the expected results when we try to follow the instructions on page 104, with the 'guessTheNumber' script.
we start the server and in the server console we typed the following and got these results:
js guessTheNumber( self )
[13:41:19] [CanaryMod] [INFO] [MESSAGE]: Pick a number between 0 and 5 inclusive
3
[13:41:23] [net.minecraft.server.MinecraftServer] [INFO]: Unknown command. Try /help for a list of commands
the first part seems right - the script asks the player (self in this case) to pick a number. but then when we type a number at the console prompt, we get an error. it seems like the input function is not working somehow and the console just went back to normal, not expecting an answer from 'self'.
for reference, here is a paste of the code from the numberGuess.js script we saved in the scriptcraft/plugins folder:
(this version is from a bit further in the book - we went ahead and added the if clause from page 109. we have the same problem with this version).
var input=require('input');
var dice=require('dice');
var randomNumber;
function checkAnswer(guess, guesser){
if(guess==randomNumber){
echo (guesser,'You guessed correctly!');
} else{
echo(guesser,'better luck next time');
}
echo(guesser, 'Thanks for playing');
}
function guessTheNumber(player){
randomNumber=dice.roll(6);
input(player,'Pick a number between 0 and 5 inclusive',checkAnswer);
}
exports.guessTheNumber=guessTheNumber;
we have a similar problem getting the Minecraft client to say 'Night!' as on page 113, but other than that we are following the book ok. we have moved on in the book - we finished chapter 9 and will start chapter 10. we got the dropped cookies to work at end of chapter 9
we are on a macbook air. our mcserver folder is in the users/johngreene folder
any suggestions to fix the console input and echo functions would be much appreciated!
thanks
john g
Hi John,
I'm seeing the same problem you've seen with the input() function in the
very latest version of CanaryMod (this has changed since the book was
written).
I'll look into this and get back to you with a solution soon hopefully.
Walter
On Sat, Aug 8, 2015 at 9:58 PM, johndgreene [email protected]
wrote:
i'm following the book beginners guide to writing minecraft plugins in
javascript with my 11 year old son. we're making pretty good progress and
it's mostly working. we are not getting the expected results when we try to
follow the instructions on page 104, with the 'guessTheNumber' script.we start the server and in the server console we typed the following and
got these results:
js guessTheNumber( self )
[13:41:19] [CanaryMod] [INFO] [MESSAGE]: Pick a number between 0 and 5
inclusive3
[13:41:23] [net.minecraft.server.MinecraftServer] [INFO]: Unknown command.
Try /help for a list of commandsthe first part seems right - the script asks the player (self in this
case) to pick a number. but then when we type a number at the console
prompt, we get an error. it seems like the input function is not working
somehow and the console just went back to normal, not expecting an answer
from 'self'.for reference, here is a paste of the code from the numberGuess.js script
we saved in the scriptcraft/plugins folder:
(this version is from a bit further in the book - we went ahead and added
the if clause from page 109. we have the same problem with this version).var input=require('input');
var dice=require('dice');
var randomNumber;function checkAnswer(guess, guesser){
if(guess==randomNumber){
echo (guesser,'You guessed correctly!');
} else{
echo(guesser,'better luck next time');
}
echo(guesser, 'Thanks for playing');
}function guessTheNumber(player){
randomNumber=dice.roll(6);
input(player,'Pick a number between 0 and 5 inclusive',checkAnswer);
}exports.guessTheNumber=guessTheNumber;
we have a similar problem getting the Minecraft client to say 'Night!' as
on page 113, but other than that we are following the book ok. we have
moved on in the book - we finished chapter 9 and will start chapter 10. we
got the dropped cookies to work at end of chapter 9we are on a macbook air. our mcserver folder is in the users/johngreene
folderany suggestions to fix the console input and echo functions would be much
appreciated!thanks
john g—
Reply to this email directly or view it on GitHub
#262.
Walter Higgins
Mobile: (+353) 086 8511600
Website: http://walterhiggins.net/
Hi @johndgreene ,
If you issue the command at the in-game prompt (not the server prompt) then it should work fine.
The server prompt always expects a command of some sort whereas the in-game prompt can take commands or conversations.
thanks very much. i'll try issuing the command from the in-game prompt today
j
now that we know you have the same problem, it is not very important to solve it (in server console). we thought perhaps we were doing something wrong, or mac had a different config. but given you see same thing, we can just move on. i guess it might matter if we want input at the console prompt, but we don't necessarily have to do that
just tried it at the in-game prompt. i typed /js guessTheNumber(self). it behaved similarly to in the console - it asked me to guess a number between 0 and 5. but then when i typed a number it said unknown command. i tried just a number, / followed by a number, js followed by a number and /js followed by a number. none of these seemed to work. again, not hurting us right now, but would like to know if we have configured something incorrectly
thanks for the help
j
we moved on to chapter 10. on page 120, it has instrux to respond to the new script animal sounds. in those instrux it says to type a T (inside minecraft client) to enter text. i went back to guessTheNumber and tried using T and it worked. so now we have input working correctly inside minecraft client. the instrux to enter a T were the thing we did not have. - would be good to include walking the reader through the text entering (via T) in chapter 9 when first trying to use the input function.
thanks for the help
j