Choosing global variables with a calculation.
I'm attempting to set up a procedure that will retrieve a value from an ini file, then get the global variable with that value and set it to a given number.
I'm certain that the procedure is being activated, because if I simply set it to change, say "global variable 4" to 1, it'll work just fine. However, when I tell it to set "global variable (value of ini)" to 1, it doesn't work.
Am I going about this the wrong way, or can it not be done at all?
Re: Choosing global variables with a calculation.
The easiest way would be to use an array and set the Y position to the value you want to change. That's what i'd do.
Re: Choosing global variables with a calculation.
The "Set global variable (result of calculation)" action chooses the index of the global variable to set based on the result of the calculation - it doesn't look for a global variable that already has the result of that calculation. I think that's where you're going wrong, reading your description, at least.
What is it you're trying to do, on a more general level? Perhaps there's an easier approach.
Re: Choosing global variables with a calculation.
Quote:
Originally Posted by DavidN
The "Set global variable (result of calculation)" action chooses the index of the global variable to set based on the result of the calculation - it doesn't look for a global variable that already has the result of that calculation. I think that's where you're going wrong, reading your description, at least.
No no.
Let's say that the value I've set in the ini file is 5. When I run the procedure, I want it to get, as you say, the global variable with the index of 5, not the global variable that has a value of 5. Sorry that wasn't clear enough.
What I'm basically doing here is setting up a dialogue system, and certain variables may need to be set when a conversation is finished. For example, if someone gives you a key, it should set the variable "playerHasKey" to 1 when the conversation's over.
The conversations are stored in an ini file, and I'm attempting to set it up so that if there's a "set variable" line in the current conversation group, it'll set the variable with the index of (value) to a number, usually 1.
Re: Choosing global variables with a calculation.
Upon further investigation, the feature doesn't seem to be working at all.
I can literally declare an "Always" event at the very start of the editor telling the program to set a global value and simply put "4" (or any number, minus the quotes of course) into the expression window for calculating which value to set...and yet it doesn't work. Global value 4 remains unchanged.
However, if I select the name of the global value from the drop-down list, it works perfectly.
Am I missing something here? The index of a global value is the number that comes before its name, right?
Re: Choosing global variables with a calculation.
I've never used the feature you're using, but i know as a fast my suggestion workds perfectly, as i used it regularly.
Re: Choosing global variables with a calculation.
I'll give your solution a try if the way I'm doing it now isn't possible, but in all honesty I'd prefer to simply use global values. They're easier to keep track of given that you can name them, and if you change frames you don't need to worry about them transitioning properly.
Re: Choosing global variables with a calculation.
Quote:
Originally Posted by Meanderer
I'd prefer to simply use global values. They're easier to keep track of given that you can name them, and if you change frames you don't need to worry about them transitioning properly.
If you can't get your original way to work, you could use the named variable object. That will allow you to name your values and you can make it global to your app
Re: Choosing global variables with a calculation.
Fair enough.
Isn't this basically a bug, though? I mean, unless I'm completely barking up the wrong tree here, the function allowing you to choose a global value based on an expression just...isn't working. At all. Even with the simplest expression possible, that being a single integer.
EDIT: OK. This has actually been my error from the beginning.
When you look at the list of global values, they've all been numbered, starting from 0. I naturally assumed that these were the indexes of the values, but apparently they aren't, and in actual fact the numbering starts at 1. So basically the reason it wasn't working is that I was altering the values that were 1 index lower than the ones I actually wanted to alter.
Sorry, folks. Thanks for the help anyway, though.
Re: Choosing global variables with a calculation.
Just did a check look and it seems the index for global values using the expression is 1-based rather than the 0-based that they are shown as in the app properties.
Seems to be for both setting the global value and also retrieving it's value
Edit: Opps, you've already found it :D
Re: Choosing global variables with a calculation.
Thanks for saying - MMF's indexing is all over the place sometimes, with some things starting from 0 and others from 1. The real trouble is that standardizing them at this point would break a lot of existing MFAs...
Re: Choosing global variables with a calculation.
Quote:
Originally Posted by DavidN
Thanks for saying - MMF's indexing is all over the place sometimes, with some things starting from 0 and others from 1. The real trouble is that standardizing them at this point would break a lot of existing MFAs...
I also struggle a lot with the whole 0 and 1 thing. I personally would prefer things all starting from 0 as it seems the majority do. But i guess it is too late to implement that now.
Re: Choosing global variables with a calculation.
I think it is worth breaking some things for MMF3.
I'm not sure people who have large projects would agree with that though...
Re: Choosing global variables with a calculation.
Unless there was a single 'override' sort of file that you could install that simply updates the objects.