Brand MU Day
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Learning to Code - A Sprite Break

    Scheduled Pinned Locked Moved Helping Hands
    85 Posts 28 Posters 6.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SpaceKhomeiniS
      SpaceKhomeini @Jennkryst
      last edited by

      This post is deleted!
      O 1 Reply Last reply Reply Quote 1
      • TezT Tez referenced this topic on
      • TezT Tez referenced this topic on
      • TezT Tez referenced this topic on
      • TezT Tez moved this topic from Rough and Rowdy on
      • FaradayF
        Faraday @Jennkryst
        last edited by Faraday

        @Jennkryst said in Learning to Code - A Sprite Break:

        I am attacked, halp

        To echo what @Tat said - it’s not true. I have a mountain of tutorials on Ares to teach people how to code, and am more than happy to answer even basic questions on the discord.

        Unfortunately, Ares is not really well-suited for the type of game/code you’re looking for 😞 But I just wanted to provide a counterpoint that people willing to teach others how to code (within reason - I can’t do it FOR you) do, in fact, exist.

        That said - online resources are better than ever and then you don’t have to rely on anyone’s good graces.

        1 Reply Last reply Reply Quote 5
        • IoleRaeI
          IoleRae
          last edited by

          Python:

          https://codecombat.com/

          That’s where I send interested teens, and it seems to do the trick.

          the entity previously known as Sunny

          PolkP JennkrystJ 2 Replies Last reply Reply Quote 0
          • PolkP
            Polk @IoleRae
            last edited by

            @IoleRae Python has great learning resources available, and a good base from which to build a MUSH: Evennia.

            Plus folks like @Darren have things you can surely use so you’re not starting from scratch.

            IoleRaeI 1 Reply Last reply Reply Quote 0
            • IoleRaeI
              IoleRae @Polk
              last edited by

              @Polk

              Yes, thank you. Evennia is why I linked a helper to Python.

              the entity previously known as Sunny

              1 Reply Last reply Reply Quote 3
              • C
                catzilla
                last edited by

                Does this include web hosting and wiki stuff? I just bought a domain for a Hunter game I’m starting. I’m sure I could figure out wiki skinning if I just knew WHERE TO GO. I have hostgator and installed MediaWiki, I just don’t know the next step. 😞

                JennkrystJ RozR PolkP 3 Replies Last reply Reply Quote 0
                • JennkrystJ
                  Jennkryst @catzilla
                  last edited by

                  @catzilla The extent of my wiki code knowledge is ‘that page looks pretty, let me copy the code and fiddle with it until it looks right for my character vibe’

                  Mummy Pun? MUMMY PUN!
                  She/her

                  1 Reply Last reply Reply Quote 0
                  • RozR
                    Roz @catzilla
                    last edited by

                    @catzilla It depends what you mean by wiki skinning? This has links to various MediaWiki skins and how to install them (which is generally just downloading a bundle of files to the /skins/ directory in your MW directory and then copy-pasting a line of code into your LocalSettings.php). If you mean how to customize a skin, then you’ll generally want to either edit MediaWiki:Common.css or your skin’s CSS file on your wiki itself (so it’ll be like https://yourwikiurl.com/blahblah/MediaWiki:Common.css, or https://yourwikiurl.com/blahblah/MediaWiki:SkinNameHere.css). Common.css overrides the CSS on any skin a viewer may use (since there are usually a few installed by default and users can technically switch around), while the individual Skin.css files will override just that skin. Most game wikis are basically designed around a single skin so you can probably just use either. You can even comment out the lines where any other skins are activated in LocalSettings.php. Using these on-wiki CSS sheet is preferred over trying to edit the raw skin files themselves, since changes there would be potentially overwritten if there were any updates made to MW or the skin.

                    she/her | playlist

                    C 1 Reply Last reply Reply Quote 1
                    • JennkrystJ
                      Jennkryst @IoleRae
                      last edited by

                      @IoleRae said in Learning to Code - A Sprite Break:

                      Python:

                      https://codecombat.com/

                      That’s where I send interested teens, and it seems to do the trick.

                      Never going to get past the second level, because it won’t let me pet the dog. RIP all my planz.

                      Mummy Pun? MUMMY PUN!
                      She/her

                      1 Reply Last reply Reply Quote 0
                      • PolkP
                        Polk @catzilla
                        last edited by

                        @catzilla To do hosting and system administration stuff properly you need a minor course in unix

                        Gotta be one on freecodecamp

                        https://www.freecodecamp.org

                        https://www.freecodecamp.org/news/the-linux-commands-handbook/

                        1 Reply Last reply Reply Quote 0
                        • JumpscareJ
                          Jumpscare
                          last edited by Jumpscare

                          Evennia has a lot of tutorials, but they’re geared at the basics, not what you’d actually want in your game.

                          So here’s one where I write the code for you and tell you want to do.

                          Lesson 1: Make skills and roll modifiers for your characters.

                          Disclaimer: I typed this all up from memory. It’s probably got a few typos, so I trust you to be able to figure out what’s wrong, by looking at adjacent code and making yours look just like the code that’s next to it. One of the most valuable skills you can learn is figuring out what to do when your code spits out an error. Make errors early on! The site Stack overflow is your friend, too.

                          So you have Evennia running. You can log in as your admin account. You have access to the command line.

                          First, pull up characters.py in your game directory.

                          Now, set up your skills as a dict, in characters.py, in the at_object_creation method, which should be near the top.

                          self.db.skills = {
                              "Medicine": 1,
                              "Underwater Basket Weaving": 1
                          }
                          

                          Your skills won’t automatically get added to existing characters, so you’ll have to create a method to add them manually, or reload your character object. Reloading your character object resets ALL attributes to what’s in at_character_creation, so make sure you only use it when you’re fine with resetting your character back to nothing. Check the Evennia documentation for how to do this. I don’t remember offhand, since it’s been over a year since I’ve reloaded an object.

                          Once you get your skills on your object, you can reference them easily. Here’s an example line. Don’t add it anywhere yet.

                          self.db.skills.get("Medicine", 0)
                          

                          The zero at the end says that if the Medicine skill isn’t found, default to zero.

                          You can run python lines as your admin account while being logged in.

                          Try typing:

                          py self.msg(self.db.skills.get("Medicine", 0))
                          

                          This should message (msg) your character the value of its Medicine skill.

                          Now, let’s add buffs / debuffs or other roll modifiers. Once again, add a dict of modifiers to your at_character_creation method:

                          self.db.modifiers = {}
                          

                          It can go just below your skills dict.

                          Now we need a method in your character class to add modifiers.

                          First, add this to the top of your characters.py file.

                          import time
                          

                          We do this because we need to know the time for this part. It’ll make sense eventually.

                          Next, add this to the bottom of your characters.py file.

                          def add_mod(self, name, value, effect, duration):
                              # adds a value to a modifier, value can be negative for a debuff
                              # name is the name of the mod, e.g. "Squeamish"
                              # value is how strong this mod is, e.g. 2 or -4
                              # effect is the skill or other roll it targets, e.g. "Medicine"
                              # duration is how long it should last, in minutes
                          
                              # get the strength of the current_mod
                              current_mod = self.db.modifiers.get(name, 0)
                              # update or set the value of the modifier
                              self.db.modifier[name] = (current _mod + value, effect, time.time() + duration * 60)
                              # What does the above mean?
                              # We're adding a list of 3 entries to self.db.modifier, using the name of the mod as the key
                              # current_mod + value is our new value
                              # effect is set without change
                              # time.time() means to get the current numeric time, and we add to it the duration we set, but we multiply the duration by 60 because the duration is in minutes, but time.time() is in seconds, so we need to convert it
                          

                          A line that begins with a # is a comment. Read the comment lines above to learn what this method is doing. There are only two real lines of code in that method. The rest are comments explaining what’s going on.

                          If you want buffs & debuffs that don’t stack, you can alter the above code by removing the current_mod code. This will set static values so that your +2 Holy Weaver buff doesn’t stack to a +4 the second time it’s used in succession. If you want both cumulative and static buffs, make two methods. Alternatively, add a “stacking” flag to the method and set stacking = True or stacking = False, then add a little check for whether or not it should stack, setting current_mod to 0 if it doesn’t stack.

                          Now, modifiers don’t expire on their own. We need a method to expire old modifiers. This method has only 3 lines of code, but again, I’ve commented it to explain it all.

                          def expire_mods(self):
                              # check all mods and remove any that have expired
                              # first, iterate through all keys in the modifier dict
                              for mod_name in self.db.modifiers:
                                  # check if its expiration time (entry 2 in the mod's list) is before the current time
                                  # We're iterating on the keys of self.db.modifiers, not the lists, so we need to use .get to get the list, and pull out entry [2], the expiration time, then compare that to the current time.
                                  if self.db.modifiers.get(mod_name)[2] < time.time():
                                      # if we're here, then we've confirmed that a mod is old and should be removed, so let's .pop it out of there
                                      self.db.modifiers.pop(mod_name)
                          

                          There’s only one last thing you need: a way to check skills with their mods. Again, this method is only 2 lines, but commented a bunch:

                          def get_skill(self, name):
                              # First, expire old mods. We don't need to check for expiration and removal at any point up until now.
                              self.expire_mods()
                              # There are no arguments with this, even though the expire_mods method has "self" as an argument. This is because "self" is automatically sent for any method call, regardless of whether or not you want it to be sent.
                          
                              # Next, pull the value of the skill out of the skills dict, and add the value of the corresponding mod from the modifier dict
                              # If the mod is negative, you'll be adding a negative, which is just subtraction, so this accounts for buffs and debuffs.
                              return self.db.skills.get(name, 0) + self.db.modifiers.get(name, 0)
                          

                          In your commands.py, add a command to test your code.

                          class ListSkills(command):
                              # Type "skills" to use this command
                              key = ["skills"]
                              def func:
                                  # Set our message to be a blank string.
                                  message = ""
                                  # The "self" from characters.py is now "self.caller" since we're "calling" this command.
                                  for skill in self.caller.db.skills:
                                      # We're creating a string that will eventually be sent to the player. We can add additional text to that string with +=. The code \n means to go down one line, as if you pressed enter.
                                      message += "Your " + skill + " skill is at level " + self.caller.get_skill(skill) + "\n"
                                  # We now have a string that lists the names and values of each skill, one per line. Let's send this message to the player.
                                  self.caller.msg(message)
                          

                          Whenever you add a command, you need to import and add it to the default_cmdset.py file.

                          from command.commands import ListSkills
                          

                          And then further down the file near the “super,” add something like this:

                          ListSkills.add()
                          

                          Now at your command prompt, type:

                          Evennia restart
                          

                          If you get no errors in the command line of your logged in character, type “skills” and press enter, and look at your beautiful skills.

                          Congrats, you now know about 80% of what it takes to code in Evennia.

                          If you do this lesson and you’re still confused about any errors or lines of code, feel free to ask me and I’ll be happy to help.

                          Game-runner of Silent Heaven, a small-town horror MU.
                          https://silentheaven.org

                          JennkrystJ tsarT 3 Replies Last reply Reply Quote 8
                          • JennkrystJ
                            Jennkryst @Jumpscare
                            last edited by

                            @Jumpscare None of this tells me how to pet the doggy in code combat, the new limbo I am stuck in.

                            (actually trying to figure out Virtual Box, since I do not have Hyper-V)

                            Mummy Pun? MUMMY PUN!
                            She/her

                            JumpscareJ 1 Reply Last reply Reply Quote 0
                            • JumpscareJ
                              Jumpscare @Jennkryst
                              last edited by

                              @Jennkryst I don’t know what any of that means, sorry.

                              I installed WSL2 on my desktop, which is Linux on Windows.

                              Some combination of these commands should work. Change “mygame” to whatever you want your game to be called internally.

                              source evenv/bin/activate
                              pip install python3.9
                              python3.9 -m venv evenv
                              pip install evennia
                              evennia --init mygame
                              cd mygame
                              evennia start

                              To start Evennia after rebooting, I type the following.

                              source evenv/bin/activate
                              python3.9 -m venv evenv
                              cd heaven
                              evennia start

                              Game-runner of Silent Heaven, a small-town horror MU.
                              https://silentheaven.org

                              JennkrystJ 1 Reply Last reply Reply Quote 5
                              • JennkrystJ
                                Jennkryst @Jumpscare
                                last edited by

                                @Jumpscare I got linked to this here thingy:

                                @IoleRae said in Learning to Code - A Sprite Break:

                                https://codecombat.com/

                                And there is a section where you tell your hero sprite to hero.moveTo(2), and there is a dog sprite standing there, but no instruction on how to give the dog head pats.

                                This is criminal.

                                Mummy Pun? MUMMY PUN!
                                She/her

                                JumpscareJ RozR 2 Replies Last reply Reply Quote 0
                                • JumpscareJ
                                  Jumpscare @Jennkryst
                                  last edited by

                                  @Jennkryst

                                  Sorry, I don’t know how to code anything besides Evennia.

                                  Game-runner of Silent Heaven, a small-town horror MU.
                                  https://silentheaven.org

                                  1 Reply Last reply Reply Quote 3
                                  • RozR
                                    Roz @Jennkryst
                                    last edited by

                                    @Jennkryst This is a really weird response to someone typing out a bunch of stuff to try and help you after you asked for help.

                                    she/her | playlist

                                    JennkrystJ 1 Reply Last reply Reply Quote 10
                                    • tsarT
                                      tsar @Jumpscare
                                      last edited by

                                      @Jumpscare said in Learning to Code - A Sprite Break:

                                      Disclaimer: I typed this all up from memory.

                                      I can’t type up a damn thing from memory without looking at it 4,000,000 times, this is very impressive to me lol

                                      1 Reply Last reply Reply Quote 2
                                      • JennkrystJ
                                        Jennkryst @Roz
                                        last edited by

                                        @Roz @Jumpscare said she didn’t know what any of what I was talking about meant, so I explained.

                                        I should have clarified the code combat people are the criminals, for not letting me pet the dog.

                                        ahem

                                        Right now, I’m stuck at trying to even install evennia onto the Linux virtual machine (which finally worked on the 4th try, horray!) So progress is happening, just slow. Efforts to resume after work.

                                        Mummy Pun? MUMMY PUN!
                                        She/her

                                        1 Reply Last reply Reply Quote 0
                                        • JennkrystJ
                                          Jennkryst
                                          last edited by

                                          This took a dumb amount of time, but fear me.

                                          Glorious.PNG

                                          Mummy Pun? MUMMY PUN!
                                          She/her

                                          1 Reply Last reply Reply Quote 2
                                          • RucketR
                                            Rucket
                                            last edited by

                                            this is a very random comment but

                                            every game should have a command to pet the doggo. doggos good.

                                            dog

                                            that said, this is an interesting thread to follow!

                                            1 Reply Last reply Reply Quote 3
                                            • First post
                                              Last post