Skip to content

Style command #32

Answered by okaybenji
Bharat0112 asked this question in Q&A
Oct 2, 2023 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Yeah, that's no problem. Change your function to accept newName as an argument like this:

let stylex = (newName) => {
  const selectStylesheet = filename => document.getElementById('styles').setAttribute('href', filename);
  println(`You changed the stylesheet to ${newName.toUpperCase()}.css.`);
  selectStylesheet(`styles/${newName}.css`);
};

Now you can call the function, passing the filename as a string:

stylex('modern');

Finally, you'll need to update your game's commands. Since this function accepts a single argument, you'll need to override commands[1] like this:

commands[1] = Object.assign(commands[1], {stylex});

Check out the Commands section of the documentation for more info.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@Bharat0112
Comment options

Answer selected by okaybenji
Comment options

You must be logged in to vote
2 replies
@Bharat0112
Comment options

@okaybenji
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #31 on October 27, 2023 18:33.