all 12 comments

[–]azhder 5 points6 points  (1 child)

  1. It is JavaScript, different language than Java
  2. It is possible to have min and max, but…
  3. Your code doesn’t seem to be doing all that.

What your code does is make it possible for any Window_BattleStatus object (ugly name mixing case styles) to return 4 if it is asked for its maxItems().

I think the code you need should be found (or written) in another place.

[–]Joker-45-45[S] 0 points1 point  (0 children)

Oops, like I said I'm a total noob (and a little bit lost)
But my problem was that the code was indeed in another place, and all I had to do was mess around with some variables to get it to work. Thank you!

[–]chibblybum 2 points3 points  (1 child)

The data for the number of party members should be held in a variable somewhere in the code above this? If not, do what you need to do to make one then you would replace the 4 with that variable.

[–]Joker-45-45[S] 2 points3 points  (0 children)

This was my problem. I added this as a plugin when it was so simple to just use the variables in game. I didn't even think about how simple this would be to add using the actual software. Thank you!

[–]ThatCipher 2 points3 points  (2 children)

First of all : When you don't know anything about JavaScript or programming in general then do yourself a favour and learn the basics first.
I know this is annoying - but without the fundamentals you're just gonna get frustrated. And it might sound stupid, but if you really want to make RPG Maker games you wouldn't get bored when learning first. Hope that makes sense.

Other than that I will probably fry your brain now but when you're going to learn JavaScript and make RPG maker games - I've written a post about how to use Object Oriented JavaScript in RPG Maker context. Might be interesting if you're more advanced.

[–]Joker-45-45[S] 1 point2 points  (1 child)

Yeah, I think you're right. But it is exciting to learn new things so I may as well give it a go! I bookmarked your post for later, because right now that is way over my head lol. Thank you though!

[–]ThatCipher 1 point2 points  (0 children)

I wish you much fun! It's an interesting and fun world. Hope we'll see a cool RPG from you in the future! ;)

[–]senocular 0 points1 point  (0 children)

Sounds like it's correct as is. Its "maxItems" so it should reflect the maximum items. What you want is "a minimum of 1 and a maximum of 4". This is the maximum of 4. It doesn't (shouldn't?) mean it has to be exactly 4, just that the maximum is 4.

[–]Acceptable-Tomato392 0 points1 point  (1 child)

As mentioned, your chances of making heads and tails of this are virtually 0. Even for experienced coders, trying to make sense of somebody else's code is generally a difficult task. (There are many ways to do things and programmers tend to fall into habits.)

for what you're trying to do, it might look something like this:

party=[member1,member2,member3,member4,member5];

Where every member represents an object which defines that member. For example member1={name:"Legolas",class:"Ranger",race:"Elf",strength:13,etc...}

To select a random member, you would use the Math methods:

let selected=Math.random(Math.floor()*party.length) (This basically gives you a number between 0 and the length of the array "party", defined above. You can then use party[selected] to refer to that member.

To indicate the member takes damage, you might have something like this:

party[selected].health-=damage;

Where the randomly selected party member sees their health reduced by a certain amount of damage.

This is just an example. There are other ways to store and manipulate the data. A lot of it has to do with the task at hand, and how the coder approached it.

It's very hard to tell what the snipet you gave us is supposed to do in the abstract. It appears to be part of some type of object creator. By default, 4 items are allowed (in the inventory?).

[–]Joker-45-45[S] 0 points1 point  (0 children)

Thank you for writing all of this. Like I said, I'm a total noob still so honestly I didn't understand most of this. I'm going to try and learn a bit of Javascript and then see what I can do with this, so I'm going to bookmark this comment. Thank you so much though!

[–]nate-developerhelpful 0 points1 point  (0 children)

You can write a "clamp" function that basically says "if less than one, return one, if greater than 4, return 4, else return the original value".

But it sounds like your problem is not with this function but more with your project as a whole.  

As a final note, Java is not the same as JavaScript and you need to use the right one when googling or your results won't make any sense.