[Open Source] SkyBlock Minecraft Addon - Challenges added [New feature #10]

in #utopian-io5 years ago (edited)
New blocks, items and entities which are now available for players through the challenges.

Hello everyone,

In the last days, I focused on creating a challenge system, which players have to solve to get some rewards for the Minecraft game add-on SKYBLOCK.SK. SKYBLOCK.SK is licenced under the MIT licence, feel free to use it as you want. =)

1. Repository

https://github.com/Abwasserrohr/SKYBLOCK.SK

2. Index

  1. Repository
  2. Index
  3. New Features
    3.1. Added openchallenges function
    3.2. Added solvechallenge function
    3.3. Added default configuration for challenges
  4. Pull requests
  5. GitHub Account
  6. How to contribute

3. New Features

3.1. Added openchallenges function

Thanks to inventory menus, it is possible to create menus, like I already done at other places in the past with SKYBLOCK.SK. The challenges are another new menu, which players can open by either typing in /island challenges or by the main menu, which is not fully done, yet.

The challenges I added are fully customizable by the server operator. To make this possible, I created a dynamic menu, which understands the settings for every challenge.

Here are all the possible settings:

  • Name of the challenge for every language code
  • Toggle between repeatable and not repeatable
  • If repeatable, how many times per day it should be repeatable
  • Custom rewards and required items
  • Execute an optional defined function once the challenge is done
  • Add a custom reward text
  • Unlockable challenge levels to keep the players on the game

While keeping the settings above in mind, this is a part of how I created the new challenges menu.

function openchallenges(p:player):
  set {_slot} to 9
  set {_challengelvl} to 1
  set {_uuid} to uuid of {_p}
  set {_lang} to {SK::lang::%{_uuid}%}

First, I set some local variables, which are needed quite often. The slot is the place in the inventory where the menu starts. I keep one slot row free to make the challenges menu look not full. The {challengelvl} variable is used later to count the levels.

  if {SB::config::usechallenges} is not true:
    message "%{SB::lang::prefix::%{_lang}%}% %{SB::lang::challenge::disabled::%{_lang}%}%" to {_p}
    stop

If the server operator doesn't want challenges, there is the {SB::config::usechallenges} variable, which disables the challenges if it is set to false.
Above, I simply print a message to the player ({_p}) and then stop the function if the variable is not true.

  set {_date} to new Date()
  set {_d} to new SimpleDateFormat("yyyy-MM-dd").format({_date})
  if {SB::today} is not {_d}:
    set {SB::today} to {_d}
    delete {SB::crepeats::*}

Some server operators may want to limit some repeatable challenges to a specific amount per day. Once, a new day occurs, the {SB::crepeats::*} list gets deleted, which contains data about all repeats of the last day. There is also a variable which contains statistics for all challenges to keep track of them, which doesn't get deleted.

  opengui({_p},54,"%{SB::lang::challenge::menutitle::%{_lang}%}%")

Then, the menu is opened. It is a big menu with 54 slots, the same size as a double chest.

  set {_bedrock} to {SB::player::%{_uuid}%::island::bedrock}
  set {_x} to x-coord of {_bedrock}
  set {_y} to y-coord of {_bedrock}
  set {_z} to z-coord of {_bedrock}
  set {_xp} to {SB::island::%{_x}%_%{_y}%_%{_z}%::challengexp}
  if {_xp} is not set:
    set {_xp} to 0

Team play is a big part of SkyBlock, if players are playing together on an island. For this reason do share all members of an island their challenge experience. The challenge experience is increased by solving challenges. The more experience the player/island has, the more challenges are going to be unlocked later.

Then, the "real menu" part starts. I don't want to show more, since there would be much stuff to explain. If you're interested, you can look into the pull request or into the challenges.sk#L60, I added many comments to make it easier to understand.

Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/93


3.2. Added solvechallenge function

Now, there is a menu for the challenges, but without a function, which allows to solve them, they are pretty useless. For that reason, the solvechallenge function has been added.

The solvechallenge function has two parameters, it needs the player and the challenge id.

We have 5 challenge levels with 7 challenges in each challenge level. A challenge id contains the challenge level and the challenge level part number.

Example: The 5th challenge of the challenge level 1 has a challenge id of 5::1. The "::" is the spacer, it is used here for list variables, which has been created for the configuration of the challenges, I go into further detail later below at 3.3, how the configuration works.

function solvechallenge(p:player,challenge:text):

As you can see here, the solvechallenge function only needs the two parameters. The parameters can be used as {_p} and {_challennge}. Parameters are handled like local variables, in functions.

  set {_needed} to {SB::config::challenges::c::%{_challenge}%::needed}
  set {_reward} to {SB::config::challenges::c::%{_challenge}%::reward}
  set {_repeatreward} to {SB::config::challenges::c::%{_challenge}%::repeatreward}
  set {_repeat} to {SB::config::challenges::c::%{_challenge}%::repeat}
  set {_repeatsperday} to {SB::config::challenges::c::%{_challenge}%::repeatsperday}
  set {_cid} to {_challenge}
  replace all "::" with "" in {_cid}
  set {_uuid} to uuid of {_p}
  set {_lang} to {SK::lang::%{_uuid}%}
  set {_prefix} to {SB::lang::prefix::%{_lang}%}
  set {_bedrock} to {SB::player::%{_uuid}%::island::bedrock}
  set {_x} to x-coord of {_bedrock}
  set {_y} to y-coord of {_bedrock}
  set {_z} to z-coord of {_bedrock}

There many variables, which we may need in the process of solving a challenge. I also tend to use short local variables to make it easier to read and understand what is actually happening.

  • {_needed} is a string with all items, which are needed to solve the challenge, the format looks like this: <amount>-<item name>, if there are more items needed, they can be split using a comma.
  • {_reward} works the same as {_needed}, this is the reward, if the player has never solved the challenge before.
  • {_repeatreward} works the same as {_needed}, this is the reward, if the challenge already has been done.
  • {_repeat} is a Boolean. True means that the challenge is repeatable, false is not repeatable.
  • {_repeatsperday} is a integer, which defines, how many times the challenge can be solved within one day.
  • {_cid} is the short version of {_challenge}, which is a parameter. The "::" part of the {_challenge} gets replaced by nothing.
  • {_uuid} is the uuid of the player.
  • {_lang} is the language code defined for the player.
  • {_prefix} is the prefix for the language code, this is needed, since we print some messages later.
  • {_bedrock} is the bedrock (island centre) of an island. There are many variables set, which are named after the x, y and z coordinates.
  • {_x}, {_y} and {_z}are needed to get the challenge data of the island.

Quite a lot of stuff we need to solve a single challenge. But I hope this list helped to make it easier. =)

Like the openchallenges function, it is quite challenging to make a post appealing to read if there is everything full of code examples. If you want to look into challenges.sk#L224, here is a direct link how it goes on. With the local variables in mind, it is easier to know what I've done there. =)

But one thing I wanted to show here is how I made items with valid amounts out of the string.

To make it easier to understand, here is an example, what the {_reward} variable could contain: 1-apple,5-cookie,1-milk bucket

  set {_reward::*} to {_reward} split at ","

Since every item in the string is separated by a comma, we can split the string at every comma to a list. That way, we can loop through it.

  loop {_reward::*}:
    set {_tmp::*} to loop-value split at "-"

Within the loop, there is a new variable list created, named {_tmp::*}, which is used to store temporary the rewards. The loop-value should contain 1-apple at this point.

We need to separate this once more. By splitting this temporary value at "-", the integer and the item can be parsed to the right format.

    set {_tmp::1} to {_tmp::1} parsed as number
    if {_tmp::2} is "xp":
      set {_xp} to {_tmp::1}
    else:
      set {_tmp::2} to {_tmp::2} parsed as item
      if {_p} has enough space for {_tmp::1} of {_tmp::2}:
        give {_p} {_tmp::1} of {_tmp::2}
      else:
        spawn {_tmp::1} of {_tmp::2} at {_p}'s location

If we have "xp" set as reward, it doesn't try to give it to the player. This {_xp} variable is used later in the solvechallenge function. But if it is an item, it is checked if the player has enough space in the inventory, if there is enough space, the player gets the item, if not, it is spawned at the location of the player.

Pull request: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/93


3.3. Added default configuration for challenges

Now, the functions are ready. To make it easy for server operators, I added the default configuration for the challenges to the config.sk file. The configuration for the challenges is quite massive but necessary to make it easy customizable.

Players now can build aquariums and fill them with coral blocks, soul sand, magma blocks and also with the conduit. Animals like dolphins, fishes and turtles can now be obtained on islands with the default configuration.

To make it harder for new players, the default configuration has a high experience threshold. The server operator can change these integers as needed. Apologies for the misspelled “threshold” in the variables, this is going to be fixed in the next pull request.

  set {SB::config::challenges::thereshold::1} to 0
  set {SB::config::challenges::thereshold::2} to 2000
  set {SB::config::challenges::thereshold::3} to 5000
  set {SB::config::challenges::thereshold::4} to 9000
  set {SB::config::challenges::thereshold::5} to 25000

Then, there is the configuration of all the challenges. This is the example for the challenge 1::1

  set {SB::config::challenges::c::1::1::needed} to "64-cactus"
  set {SB::config::challenges::c::1::1::reward} to "15-xp,2-sand"
  set {SB::config::challenges::c::1::1::repeatreward} to "1-xp,1-sand"
  set {SB::config::challenges::c::1::1::item} to sand block
  set {SB::config::challenges::c::1::1::repeat} to true
  set {SB::config::challenges::c::1::1::repeatsperday} to 20
  set {SB::config::challenges::c::1::1::customfunction} to ""
  set {SB::config::challenges::c::1::1::customreward} to ""
  • The {SB::config::challenges::c::1::1::item} variable is set to an item, which should be displayed in the challenges gui.
  • {SB::config::challenges::c::1::1::customfunction} is a string, which is later executed as skript code. The server operator could put a function in it, which should be called, if someone solves the challenge.
  • {SB::config::challenges::c::1::1::customreward}is displayed in the challenge menu and is also a string.
  • The other variables are explained at 3.2. Added solvechallenge function and also in the config.sk file itself, of course. =)

Commit: https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/93/commits/e7635718cdfbc29dffb434f137e917905a5ac2aa


4. Pull requests

https://github.com/Abwasserrohr/SKYBLOCK.SK/pull/93


5. GitHub Account

https://github.com/Abwasserrohr


6. How to contribute

Interested in contributing to SKYBLOCK.SK? Feel free to contact abwasserrohr on the Discord linked below. You already know how Skript works? I'm looking forward to see you on GitHub. =)

Discord: https://discord.gg/FRuK5BC


Thank you for reading this contribution post. The people seem to like the new challenges they now have. It was much work to get all the default configuration challenges ready and the functions work like they should. Some also can’t get enough, they want multiple challenge sites. Let’s see how long the new feature keeps the players busy. =D

This change allows now players to get stuff they would normally never get on a flying island. This makes the challenges very valuable for the players. I keep in contact with players to adjust the default settings to make SKYBLOCK.SK a good experience right out of the box.

If you got some feedback, let me know, I appreciate your effort. =)

Keep on steeming and have a nice weekend

@immanuel94

Sort:  

Thanks for the contribution, @immanuel94! I really like the way you have laid out your post, it's a great way to showcase all the information! Also the way you explain everything makes for a great read, great work.

As for the code; I don't have any experience with using Skript, so I honestly can't give any proper feedback about it. From what I can tell everything looks consistent and clean, so there's not much to say about it. Is the language used much, and do you have syntax highlighting when using it?

Anyway, thanks once again for the great contribution! I'm looking forward to seeing more.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Hey @amosbastian! =)
Thank you for reviewing my contribution post. Unfortunately, Skript isn't used enough to have syntax highlighting on GitHub, but here is a syntax IDE/UDL for atom: https://forums.skunity.com/resources/skriptdark-atom-ide-udl.31/

I use this custom language syntax highlighting for Notepad++: https://forums.skunity.com/resources/dark-vs-light-notepad-udl.156/

Skript has a pretty active community at skunity.com, I've also seen many people use it. They also have a online parser tool: https://parser.skunity.com/

Have a great weekend.^^

Thank you for your review, @amosbastian! Keep up the good work!

Hello @amosbastian. =)

I think there gone something wrong with the utopian upvote. But I'm not sure about that, of course. ^^

Have a great weekend. :3

Hi, when each voting round is started it prioritises contributions with the highest score. Because of this it can happen that a contribution won't get upvoted (they have always said an upvote is never guaranteed), and with the increase of the rewards recently this is more likely to happen. You can read more about the bot's behaviour here if you want.

Thank you, yeah, that makes sense.^^

Sehr cool gemacht. Die ersten sind schon erledigt ^^

Freut mich, dass dir die Herausforderungen gefallen. =)

Die Challenges sind gut, aber mit manuellen Farmen nehmen sie viel Platz ein.

Hallo @levant! =) Freut mich, dass dir die Challenges soweit gefallen. Ja man ist durchaus gut beschäftigt, wenn man alle Herausforderungen schaffen will... ^^

Sehr spannende Challenges. Sehr gut umgesetzt

Alles klar! =) Vielen Dank für deinen Kommentar und Willkommen bei Steem! ^^

ich finde die neuen challenges cool, man kann bestimmt noch viel daraus machen =)

Aber sicher. =) Gerade die Konfigurationseinstellungen lassen viele Optionen für Serverbetreiber offen.

Hi @immanuel94!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Coin Marketplace

STEEM 0.35
TRX 0.12
JST 0.040
BTC 70638.80
ETH 3565.34
USDT 1.00
SBD 4.73