如何使程序恢复到原始文本,而无需重新键入它
How to make the program revert back to original text without retyping it
if (playerChoseWeapon === true) {
var roomGenerator = Math.Random();
if (roomGenerator > 0.75) {
var roomGeneratorRoomOne = Math.Random();
if (roomGeneratorRoomOne > 0.75) {
var rGenR1One = prompt("You see a dusty room with a door on the other side, what do you want to do? REST, DOOR, or STOP");
if (rGenR1One === REST && playerHealthPoints < 5) {
playerHealthPoints++;
//Make so it goes back to original thing!
} else if (rGenR1One === STOP) {
alert("Script stopped, you can restart now.");
//Maybe add some way to ask if they want to restart and it will let them?!
} else if (rGenR1One === DOOR) {
}
代码在上面看起来真的很丑,但是在我的编辑器中看起来好多了。
基本上有代码在"你看到一个尘土飞扬的房间…"当你做REST时,它会恢复到相同的"你看到一个尘土飞扬的房间…"。
这样我就不用重复输入上千次了
你可以使用do while循环:
if (playerChoseWeapon === true) {
var roomGenerator = Math.Random();
if (roomGenerator > 0.75) {
var roomGeneratorRoomOne = Math.Random();
if (roomGeneratorRoomOne > 0.75) {
do{
var rGenR1One = prompt("You see a dusty room with a door on the other side, what do you want to do? REST, DOOR, or STOP");
if (rGenR1One === REST && playerHealthPoints < 5) {
playerHealthPoints++;
//Make so it goes back to original thing!
} else if (rGenR1One === STOP) {
alert("Script stopped, you can restart now.");
//Maybe add some way to ask if they want to restart and it will let them?!
} else if (rGenR1One === DOOR) {
}
}while(rGenR1One === REST)
或者像这样:
if (roomGeneratorRoomOne > 0.75) {
var rGenR1One = prompt("You see a dusty room with a door on the other side, what do you want to do? REST, DOOR, or STOP");
if (rGenR1One === REST && playerHealthPoints < 5) {
playerHealthPoints++;
do{
var rGenR1One = prompt("You see a dusty room with a door on the other side, what do you want to do? REST, DOOR, or STOP");
if (rGenR1One === REST && playerHealthPoints < 5) {
playerHealthPoints++;
}
}while(rGenR1One === REST)
} else if (rGenR1One === STOP) {
alert("Script stopped, you can restart now.");
//Maybe add some way to ask if they want to restart and it will let them?!
} else if (rGenR1One === DOOR) {
}
}
相关文章:
- 一个按钮,点击后会生成一个新的文本框?-Javascript
- 使用javascript创建新的文本文件(),但存储[objectFile]而不是文本
- 如果键入文本,请更改输入边框颜色
- Photoshop Javascript-试图创建新的文本层时出现语法错误
- innerHTML文本框在键入文本后不起作用
- 为什么可以't键入文本输入时,单选按钮保持选中状态
- 是否可以控制typed.js插件何时启动和停止键入文本
- 无法在ModalPopupExtender中键入文本框
- 在图像 html 旁边键入文本
- 无法在 Knockoutjs 中调用键下方法的 texbox 中键入文本
- 在填写另一个文本框时动态创建新的文本框
- 在文本框中键入文本时,替换文本框中的一部分文本
- 用ng重复或ng模型填充一个文本区域,这样它就不会用迭代的数据一个接一个地创建新的文本区域
- 如何添加一行新的文本框并下拉
- 阻止用户在文本框中键入文本,但允许粘贴键盘快捷键
- e.preventdefault()等效于替换java(Android)中的键入文本
- 如何自动重复键入文本
- 显示消息时,开始键入文本框内使用javascript
- 在文本字段中键入文本时格式化文本
- jQuery:当最后一个文本框被填充时创建新的文本框