variablefilevariablechangefunction
This commit is contained in:
parent
7846f80f11
commit
6714250079
2 changed files with 13 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// Program is started from here, runs functions from other files.
|
// Program is started from here, runs functions from other files.
|
||||||
import { userInput, calcLocation, radPointsCalc, healthCapCalc, checkLose, sleep } from './functions.js';
|
import { userInput, calcLocation, radPointsCalc, healthCapCalc, checkLose, sleep } from './functions.js';
|
||||||
import { pois, poiCounter } from './poiscreens.js';
|
import { pois, poiCounter } from './poiscreens.js';
|
||||||
import { name, prewarmoney } from './variables.js';
|
import { name, prewarmoney, variableChange } from './variables.js';
|
||||||
|
|
||||||
|
|
||||||
console.clear();
|
console.clear();
|
||||||
|
|
@ -34,13 +34,14 @@ switch(mainMenuInput) {
|
||||||
console.log("Quitting Game...");
|
console.log("Quitting Game...");
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "4":
|
||||||
sleep(5);
|
variableChange("name","=","finn");
|
||||||
|
console.log(name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startGame() { // So far what I have is filler and testing, feel free to change.
|
function startGame() { // So far what I have is filler and testing, feel free to change.
|
||||||
console.clear();
|
console.clear();
|
||||||
name = userInput("What is your name? ");
|
variableChange("name","=",userInput("What is your name? "));
|
||||||
console.log(name+" Is now your name...")
|
console.log(name+" Is now your name...")
|
||||||
console.clear();
|
console.clear();
|
||||||
console.log("Intro:");
|
console.log("Intro:");
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,12 @@ export var daysSinceScav = 0; // Days since player last scavenged. Must be >= 15
|
||||||
|
|
||||||
export var name = "placeholder"; // Player name, changed when the game starts
|
export var name = "placeholder"; // Player name, changed when the game starts
|
||||||
|
|
||||||
|
export function variableChange(variable, operation, value) {
|
||||||
|
switch(operation) {
|
||||||
|
case "%": global[variable] = global[variable] % value
|
||||||
|
case "+": global[variable] = global[variable] + value
|
||||||
|
case "-": global[variable] = global[variable] - value
|
||||||
|
case "/": global[variable] = global[variable] / value
|
||||||
|
case "=": global[variable] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue