Khaikaa Posted February 15, 2019 Share Posted February 15, 2019 Hi everybody, Â Today I'm teaching you how to break another limitation of intersect engine: how to know the empty inventory slots of a player's inventory. Let's start with an example of usage: Â Imagine that you created a very nice minigame that gives a nice reward to your players. But... what happens if a player starts the minigame with a full inventory by mistake? This player will lose this nice reward and there is nothing you can do to solve that... right? Â WRONG! Â You can check that player's inventory and send a warning message to him/her, so the player will notice he has not enough empty space on his/her inventory and go to the bank/shop to make more space. But how? Â We will make this with an event that fills the player's inventory with a special item. For each item we add to his/her inventory we will add +1 to a player variable and repeat. After his/her inventory gets full, we will take all these special items so the player gets back his/her inventory empty spaces. That simple! Â This is as so easy to do: Â Â Before getting started, make sure you have an available player variable and a useless item. If not, create them. Â First of all, we set the player variable to 0 and add a label(I called this first label "contar"). After that, add a "change player items" command which will be adding the useless item. If it successfully adds the item, we add +1 to the player variable and go back to the "contar" label. Â At some point there won't be any empty spaces in the player's inventory, so this loop will break. After that happens, add a new label(I called it "vaciar") and add another "change player items" command. This time, it will be taking the useless item. If we successfully take 1 of the useless items, we go back to the "vaciar" label. At some point we won't be able to take more useless items from that player's inventory and the loop will break. After that happens, add some show text command(i did this with a show chatbox text command) and tell the player that he has "(value of that player variable here)" empty spaces. You can optionally tell the player that he needs at least "x" empty spaces so he/she can earn these great rewards. or you can even forbid his/her entrance until he/she has enough empty space. Â I hope this helps someone! Xeno, AccurateNoodle and jcsnider 2 1 Link to comment Share on other sites More sharing options...
Zetasis Posted February 15, 2019 Share Posted February 15, 2019 This is a pretty clever way of checking inventory space. Can’t say I would’ve thought about doing this myself.  One question though, shouldn’t there be an event that sets the temporary variable back to 0 after calculating how much inventory space is available? Link to comment Share on other sites More sharing options...
jcsnider Posted February 15, 2019 Share Posted February 15, 2019 It gets set back to 0 on the first line, so right before it is ran. At the beginning or at the end doesn't matter too much. Zetasis 1 Link to comment Share on other sites More sharing options...
Zetasis Posted February 15, 2019 Share Posted February 15, 2019 Oh I see! I somehow overlooked that I guess. Well, good tutorial and clever idea. I might use this at some point. Link to comment Share on other sites More sharing options...
Khaikaa Posted February 15, 2019 Author Share Posted February 15, 2019 Yes, you can notice for its name that I use some multipurpose switches and variables (variableMultiproposito_1 would be multipurposeVariable_1 in english), so every time I need any of them I set them to 0/false as a good programming practice. I don't know which value may have that variable at the momment of running that event(which in this tutorial is triggered by commands just because it's comfortable to test with but I NEVER let the players manipulate these variables through commands for obvious reasons), so I reset them. Working this way saves a lot of switches/variables space and lets you have a clear workspace. Link to comment Share on other sites More sharing options...
AccurateNoodle Posted February 18, 2019 Share Posted February 18, 2019 You're very clever, thanks a lot for this. Link to comment Share on other sites More sharing options...
Guest Posted April 21, 2019 Share Posted April 21, 2019 I wouldn't call this "beating intersects limitations" and I think I know a MUCH simpler way but still nice tutorial and well done :p  Edit: Not sure what I was talking about when I wrote this, but reading the tutorial again it's great! Ty :p Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now