Jump to content

namegame

Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Female
  • Interests
    Trying to learn coding! I miss the early internet days when all I had to do was make Geocities pages.

namegame's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Yes! And it works now - Thank you so much! I really appreciate your patience and willingness to walk me through this. Thanks again!
  2. For comparison, here's the completely random generator code that does work:
  3. Thank you so much for your help, davej. I finally have something I can work with! I'm going to take advantage of your kindness, but I hope maybe you (or anyone else! I need all the help I can get!) can find where I'm going wrong now. I've been playing around with that chunk of javascript for nearly 2 hours and haven't gotten my generator to work yet. Here are those three paths inserted into the code that I'd been working on: So it's not working and I've been developing a migraine trying to figure out why. I've been comparing it to the totally random generator that I *did* get to work, but I really don't know why the totally random one is junctional why this one isn't. Thanks to davej, this is so, so close to being done. And then I can give this up and go back to safety of simple HTML coding.
  4. Yes! That looks like exactly what I need! Thank you so much for your help!
  5. Thanks for your reply! I'm sorry - I didn't explain myself well. I'm pretty new to coding and this is a messy quesiton. The name's supposed to have three parts - so "Abhorrence of Mythic Adornment" or "Abhorrence of Mythic Amber," not four as in "Abhorrence of Mythic Adornment Amber." It's a quirk of the names in my friend's fantasy world, and that's what makes the generator more complicated than your average bear. So that fourth variable set - var randomNumber4 = parseInt(Math.random() * wordlist4.length); - I was hoping to swap in for one of the other three variable sets. Essentially, I wanted to tell the generator: If you use a nature word for the first part of the name, then use any word for the second part and any word for the third part; if you use any word for the first part, you need to use a nature word for the second part or a nature word for the third part. Another way to state this: If you use a word from variable set one for the first part of the name, then you need to use a word from variable set four for the second part or for the third part. So, like (and this isn't real code)... But I just can't figure out how to convery those instructions in javascript. Argh so annoying. Regarding that div element, I probably should have just cut that out. I think that's part of the instructions for displaying the result... could be wrong, though.
  6. Let me know if any of this is confusing and I’ll try to clarfiy!I’d like to make a semi-random name generator. The names are made from three parts: [first] of the [second] [third], like [Flash] of the [sapphire] [sky]. What makes the names complicated is that they need to have at least one nature-related word in them in any of the three parts, like Beach of Summer’s Joy (“Beach” is the nature word, in the first part), Dedication of the Maple’s Colors (“Maple,” in the second), or Anger of the Rolling Ocean (“Ocean” here, in the third part). Thanks to online-generator.com, I was able to make a completely random generator without a problem; that generator pulled words from three sets and pieced them together. But, being random, it created names that didn’t follow the rule of having a nature term in there. Duh.After playing around with a few generators, I think I’ve figured out a way to accomplish this. I have four variable sets: one for each part of the name, and then a fourth set that will include the nature terms. And then here’s where I get stuck. I can’t come up with and/or borrow code that will instruct the generator to swap in the fourth variable set for one of the three other sets.So my question is, how do I do that? Which is linked to other questions: Is this possible? Am I coding it correctly or do I need a different approach? I’m hoping that someone can at least point me in the right direction! Again, please let me know if this question or post doesn’t make sense.Here’s my current and incomplete code, minus the vast majority of terms in the variable sets (and the style sheets and whatnot, to save space): <html><head> <script type="text/javascript"> function generator(){ var wordlist1 = ["Abhorrence","Acclamation","Adoration","Adornment",,"Artist","Ash","Ashes","Attacker","Aurora","Yearning","Zenith","Zephyr"]; var wordlist2 = ["of Mythic","of the Abhorrent","of the Accursed","of the Adorned","of the Amber","of the Amber","of the Amethyst","of the Ancient","of the Approaching","of the Aquatic","of the Wretched","of the Xanthic","of the Yellow"];var wordlist3 = ["Adornment","Air","Alignment","Amber","Asylum","Attacker","Aurora","Autumn","Awe","Bands","Basilisk","Battle","Beach","Bedrock","Blaze","Blood","Blossom","Wound","Wraith","Wreath","Zenith","Zephyr"]var wordlist4 = ["Amber","Aurora","Autumn","Beach","Bedrock","Blossom","Blossoms","Bough","Branch","Breeze","Breezes","Briar","Brine","Charcoal"] // Random numbers are made var randomNumber1 = parseInt(Math.random() * wordlist1.length); var randomNumber2 = parseInt(Math.random() * wordlist2.length); var randomNumber3 = parseInt(Math.random() * wordlist3.length); var randomNumber4 = parseInt(Math.random() * wordlist4.length); var name = wordlist1[randomNumber1] + " " + wordlist2[randomNumber2] + " " + wordlist3[randomNumber3]; //alert(name); //Remove first to slashes to alert the name //If there's already a name it is removed if(document.getElementById("result")){ document.getElementById("placeholder").removeChild(document.getElementById("result")); } // A div element is created to show the generated name. The Name is added as a textnode. Textnode is added to the placeholder. var element = document.createElement("div"); element.setAttribute("id", "result"); element.appendChild(document.createTextNode(name)); document.getElementById("placeholder").appendChild(element); } </script> Thank you! I’m new to coding, so please excuse my ignorance. This was supposed to be a fun test for myself and a little gift for a friend, but I had no idea how complicated it’d be for me.
×
×
  • Create New...