Skip to main content

Detect events for ALL player on a world

Comments

6 comments

  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    A wise friend advised me to stop trying to think like a programmer =D and think like Minecraft. There are things I wish I could do in code alone which require me to use code plus command blocks plus NPCs. I wish it was all code, but I am in an interactive world, and I have to think like Minecraft. It turns out, it works better for me. =D

    So to help you, I wish I knew more specifically what it is you are trying to do. For example, is there a particular event occuring you are trying to detect in a kind of scenario you can describe? Maybe we can put our heads together and think like Minecraft and figure out how to make it happen. :)

    0
  • Thing is, we're using Minecraft as a support to teach programmation logic to the kids. We encourage them to prioritise use of the code, to make them think like a programmer. So having to find workarounds because the interface is lacking is a bummer.

    We're not even trying to do any really difficult things, but here a couple exemples:

    - If a player is walking above specific blocks, it means that player has entered a zone that's lined in those blocks. And then you can give that player an item, or an effect

    - If a player break a block of a certain type, he's reached some limit, or item that he was supposed to, so we can apply an effect, teleport him, give him an item

    All the uses of the "Player" category, that apply only to the code-user, which could make some incredibly cool things, and are out of reach because of how the "Player" category is limited.
    And yes, I know those could be made with workarounds, but like I said, workaround that aren't code-based (NPC, command blocks) don't fit in our teachings.

    I remember asking this same question a long time ago on this forum, and a MCE person telling me it was to avoid kids using that to bother other kids in the classroom with the code. I never understood that reasoning because (as our kids proved many times) they can already do that with the code builder as it is now. If that's the reason, a lot of the other code blocks should also be removed.

    And if that's not the reason, then what would it be? I'm also frustrated because I just don't get why that choice was made I think.

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Yeah, believe me, I get it. ;)

    Okay, let's brainstorm the block breaking one, since thats familiar to me. We did the same exercise in my CS1 class. Students created a game environment with a challenge that culminated in breaking four particular blocks. I had hoped we could do a multiplayer game in which anyone who broke the 4 blocks would be the "winner." But all the code each student wrote only worked if each player ran the same code, which was cumbersome. 

    After talking to Andrew Mulholland - and trying his suggestion, we had the agent jump around and check for the presence of the 4 blocks. Is the block that needs to be broken in the position, or not? This is code the game-running player can run without every player running the code. So if the block is broken (or missing,) then we need to know if player x has a certain inventory status. I'm pretty sure I can check all of the players' inventories in a loop. So you should be able to mimic the desired result with this approach. Would it be easier with an on_that_player_broke_block_event? Yep. =] But it's a fix.

    The hard thing about the "zone" idea is knowing if they are in or out. Is it only on the perimeter? You'd have to maintain flags for in and out for every player, for every zone. And if they walk along the line, how do you know if they turn left or right, as it were? If I were implementing something like that, honestly, I'd make that with a "pinch point." That's from my old RPG making days, where you create a small area that the player goes to so they walk over the teleport blocks to get to the next map. If you use a pinch point, again, you run into thinking like a Minecrafter. Just use a pressure plate. Instead, though, you could have a "gate:" they could have to talk to an NPC or something, which could create a chat comment which could initiate code (a bit messy, but its codable.) (now I'm wondering if the pressure plate can just run a chat command or not...)

    I think an important lesson here for me has been the same one I was always telling my RPG Maker students. You have to work within the capabilities of the engine. Minecraft is certainly an incredibly capable engine, but I can still think of things it cannot do. You can, too. We can ask for improvements, and really really beg for the best ones. (lol I do!) I find it genuinely frustrating, so don't get me wrong. But in the end, I know that teaching Python in Minecraft is twenty times more engaging, and I will trade the difficulty for the engagement.

    In the meantime, we should collaborate! Which language are you using? Are you on the Facebook group, The Teachers' Lounge? Stronger Together is my motto. 

    Hope I didn't completely miss the point, and maybe helped a wee bit.

     

    1
  • Laylah Bulman

    Great ideas, Debbie!

    0
  • The agent one would actually work quite well!

    Indeed, it's no real solution, which would be the all-player events blocks, but it would still be a working solution within the code builder! so thanks a lot for that one!

    The zone one, one of my colleague found a work-around, fully in the codebuilder, which is to use a Creature block that can check for entities within a distance of a specific position. Combined with a teleport, this can allow player to teleport others outside of a zone, or inside it, if they step within distance of a specific coordinate.
    Again, not as versatile or universal as I wish, but it works and remain fully code-builder.

    I'm not part of the group, I'm from a french extra-curricular activity company, and we use mainly the MakeCode language because we're offering this class for younger children who have no previous coding knowledge, so it's a good way to make them discover coding logic with a "skin" they like

     

    I also made a post for the cursor position, if you got any idea for this one as well?

    1
  • Moderator Beacon of Knowledge Super Star

    I'm happy that you persevered, collaborated and found a work around! i know your students are benefiting from having such a fantastic instructor!

    I will seek out your other post!

    0

Please sign in to leave a comment.