Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
with(selectableobject){
if other.clickableID = id selectable = true
if !other.clickableID = id selectable = false
}
clickableID is the storeage variable on your clicker of what item "should" be selectable and should be the exact ID of the clickable object. variable selectable is the local seletableobject variable for if I'm currently selected.
Thanks for the quick reply.
I don't have a mastery of GML, but I can kinda of tell what this is trying to do (correct me if I am wrong please):
With the object that is not selected
if the local variable of the other object that is not selected is true...
and
if the local variable of the other object that is not selected is false...
DO NOT USE "=" for comparison. Use "==". It's a big headache saver.
Furthermore, learn the practice of ALWAYS putting the condition of "if" statement into brackets:
if (condition) { statement; statement; ... statement; }
Why?
Because if you later add additional content to the curly brackets {...}, then it will work; if you do not use the curly brackets, the second statement will not be conditional (only if the "if" is true), which is a nightmare to troubleshoot.
Use the same object and duplicate it in the room, then try something like this:
(Sorry for any typos)
Also, I've never had to use == in Gamemaker
Trust me, learn it / switch to it.
The PROBLEM is that "=" can mean "assignment" (evaluate the stuff on the right and assign it to the variable on the left), but it can also mean "comparison".
And one of the coolest programming technique is to shorten code:
instead of:
if (a equals b) then varEqual = true else varEqual = false;
you would write:
varEqual = (a equals b).
But if "=" means both, you would get:
varEqual = a = b
And suddenly, you have a problem. Does this mean:
take the value of b and assign it to variable a, then take the new value of a and assign it to varEqual?
or does it mean "assign the logical value of the comparison between a and b and assign it to varEqual?
imagine:
a = 5;
b = 6;
varEqual = a = b
in the first style, varEqual will become 6. In the second, it will become "false".
You really do not want this kind of ambiguity in your code!
varEqual = (a == b) will always mean exactly one thing: compare the two, and store the result in varEqual.
Not two comparisons -- two assignments. That's actually quite common in C programming, in which an assignment is automatically an expression that can be further used.
Okay I see what you're trying to do. This is sort of what I had in mind, but I didn't know you could put events inside of events (having the mouse button press in the if statement). This is all cool knowing that it's inside the step event too, so I can remove my separate code dealing with mouse enter and exit assigning sprites.