In one of my event, one NPC alway lie about how hold she is.
So she alway give random number between 18 and 104.
But I dont want to use variable for that.
So i guess my only solution was to create messagebox by script right?
I sean this command:
$gameMessage.setFaceImage('Actor1',0)
$gameMessage.setBackground(1)
$gameMessage.setPositionType(1)
$gameMessage.add("Show Text Script Call")
So I guess I will be able to use that, but for random number inside this, im not sure.
Thanks for your help.
If that does not work, use this for the number part
Math.floor(Math.random()*(104-18+1))+18
Then you're using variables in the wrong way - you don't need to store the number if it is different every time.
So what you should do in any larger project is to reserve about ten "temporariy" variables for cases where you only need the numbers for calculations inside the specific event or sequence.
You use one of those temp variables to get a random number for the age and use that in the show text, forgetting about it afterwards.
And in another event, the temp variable can be used for something else.
But it should be named for temporary or something like that to remind you that you cannot store anything there, because you will be overriding the old values any time you need a temporary random number.
Thanks andar, I use that some time. But it's also for learn javascript in same time and for a personnal chalenge heheheh.
But curently with variabl or without, that did'T work anyway.
This line:
$gameMessage.add(Math.floor(Math.random()*(104-18+1))+18);
Give me undefined is not a function. I guess Math did't exist in rpg maker lol
Math exists for MV, I've seen people use it in threads here... I've also used it for some things.
can you try this
$gameMessage.add(104-18+1)
and see if it errors or displays the message correctly?
That give 96 on first line and undefined on next line
Why are you so worried about running out of variables? You don't have to KEEP a variable for a single purpose unless you need to.
Have a few "rubbish" variables specifically for short-term use. Use the same ones over and over again.
In this case, your variable is going to be set, then used, within the same event, and you don't care what happens to it after that. It can be used for an entirely different purpose by a hundred other events, if all they want to do is set it, then use it.
Your girl who lies about her age - set the variable to a random number, then use that variable in the dialogue.
A merchant who wants to sell you something - set the variable to the amount of gold, then use it in a conditional branch to see if you can afford the item.
A man who's given you a quest to collect 10 of some item - set the variable to the number of that item in inventory, then use it in a conditional branch to see if you've got the number he requested.
A door that uses a numeric password - use a variable with Number Input, then use it in a conditional branch to see if they've entered the right number.
A puzzle that wants you to select a key item to solve it - use a variable with Select Item, then use it in a conditional branch to see if they chose the right item.
Every one of these events can use the exact same variable. You don't need to allocate a separate variable for each one, when it's going to be set and used in the same page of the same event, and then forgotten about for the rest of the game.
Put more thought into the way you design things and make use of your database, and you won't have any problems like that anymore.
That's weird... a search of Math.random() here in the forums yields so many threads where Math.random() is suggested so that function itself should actually be fine..