kvier Wrote:So, I took your code from this post, threw it into a file ("Q.html"), opened firefox (28)'s debugger and opened the page in the browser. It shows me this: See over there on the right? Where it says "<exception>: Error" and "message: "Player is not defined"" ? That's all I'm doing. The green ■▶ cursor in the middle shows the line that contains the error, too.
If you hit the ▶ button in the upper left, it'll go on and tell you the next error (if one exists). After you have it running correctly, click on the "> Console" tab in the upper left, and the messages that your javascript is producing with "console.log()" will show up there.
Unfortunately, the debugger isn't also an editor, so you'll need to go back and forth between firefox's debugger and whatever your preferred editor is.
kvier Wrote:So, I took your code from threw it into a file ("Q.html"), opened firefox (28)'s debugger and opened the page in the browser. It shows me this:<exception>: Error" and "message: "Player is not defined"" ? That's all I'm doing. The green ■▶ cursor in the middle shows the line that contains the error, too.See over there on the right? Where it says "
If you hit the ▶ button in the upper left, it'll go on and tell you the next error (if one exists). After you have it running correctly, click on the "> Console" tab in the upper left, and the messages that your javascript is producing with "console.log()" will show up there.
Unfortunately, the debugger isn't also an editor, so you'll need to go back and forth between firefox's debugger and whatever your preferred editor is.
Void Director Wrote:kvier Wrote:So, I took your code from threw it into a file ("Q.html"), opened firefox (28)'s debugger and opened the page in the browser. It shows me this:<exception>: Error" and "message: "Player is not defined"" ? That's all I'm doing. The green ■▶ cursor in the middle shows the line that contains the error, too.See over there on the right? Where it says "
If you hit the ▶ button in the upper left, it'll go on and tell you the next error (if one exists). After you have it running correctly, click on the "> Console" tab in the upper left, and the messages that your javascript is producing with "console.log()" will show up there.
Unfortunately, the debugger isn't also an editor, so you'll need to go back and forth between firefox's debugger and whatever your preferred editor is.
You can do this in chrome as well. You can also set up a work-space with chrome so that it is able to edit files and persist them to the disk. I would recommend putting the script in a separate file and including it. This will allow a good text editor to give you much more help
Here is a very simple example structure
In index.htmlSpoiler (click to show/hide):
in game.jsSpoiler (click to show/hide):
The files game.js and index.html should be two files in the same folder. If you want to edit them in chrome simply open index.html in chrome then open the dev tools (f12). Switch to the sources tab and open the sidebar on the left side called sources. Right click and select Add Folder to Workspace. Navigate to the folder with Index.html and game.js and click ok. When chrome asks permission to edit the files say yes. From then on you can use chrome as a live editor while also saving the files to the disk.
var Entity = function (attack, health, attraction, lust) {
this.health = health;
this.attack = attack;
this.attraction = attraction;
this.lust = lust;
};
var player = Entity(25, 500, 25, 100);
var monster = Entity(25, 250, 25, 100);
var selectedentity;
if (randomnumber >= 0 && randomnumber < 3){
selectedmonster = lesser_witch;
names = "Lesser Witch";
}
else if (randomnumber > 3 && randomnumber < 6){
selectedmonster = goblin;
names = "Goblin";
}
else if (randomnumber > 6){
selectedmonster = lilith;
names = "Lilith";
}
that man Wrote:Ok, I'm just saying this so that I can try and get it. If I wanted to have the player fight a monster, then all I would have to do is to assign something like "var selectedmonster", and then have it randomly select one of the monsters available?
[12:25:29.182] TypeError: selectedmonster is not a function @ file:///H:/debug.html:11
[12:25:29.184] The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. @ file:///H:/debug.html
Users browsing this forum: No registered users