Strange Issue Concerning the textNumber Function

Game Editor comments and discussion.

Strange Issue Concerning the textNumber Function

Postby bamby1983 » Wed Aug 01, 2012 6:29 pm

I ran into a strange issue while using the textNumber function and an even stranger workaround that I accidentally discovered and do not understand.

I have the following function defined in my Global code:

Code: Select all
void displayRowsMarket () {

    Market_Row_1_Qty.textNumber=10;
    ChangeAnimation("Market_Row_2", "Market_R_Power_Grey", FORWARD);
                          }


The following is my mouse down event (on another actor) that calls the above function.

Code: Select all
displayRowsMarket();



On mouse down, the animation changes as expected, but the value of the number does not. It remains at 0 (the default value).


However, the number changes as expected if I add a comment above the function call in the mouse down event. The complete code within the mouse down event with which the number value changes properly is as follows:

Code: Select all
//Market_Row_1_Qty.textNumber=30;
displayRowsMarket(costHandgun);



I had inserted the comment to check whether the code worked without the function call (and it did). I commented it out thereafter and noticed the code worked after I re-added the textNumber line of code the function call. Upon removing the comment, the code ceased to function as expected once again.


I have no idea why the above occurs and why a comment affects the way the code functions, but I'd sure like to find out.
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Strange Issue Concerning the textNumber Function

Postby skydereign » Mon Aug 06, 2012 3:57 am

This is a problem with global code and actor variables. It is a bug, and has a relatively poor workaround for now. The problem occurs from your event code (the mouse button down) not referencing the actor that you change the textNumber for. gE parses the event script for actor names, which it uses to update the variables of those actors. Since Market_Row_1_Qty does not appear in the text of the mouse button down event, it doesn't know to update the textNumber variable (again a very sad predicament).

If you want your mouse button code to work, you should add a comment with the actor's name in it.
Code: Select all
// Market_Row_1_Qty
displayRowsMarket();
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest