• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows 4 objects 1 parent

B

Brian Deckman

Guest
This is driving me nuts for the past week!
Parent child relationship no longer - 5 separate objects in room.

Edited this from original post - took out all the debug, and simplified.

Event: Create

// First FIND all Player villages (old parent) global.temp_list[xxx,yyy ] seeds properly.
var xxx = 0;
var yyy = 100;
var zzz = 0;

for (zzz = global.Village_Count; zzz > 0 ; zzz -= 1)
{
if (global.Village_Array[yyy,8] = global.Player_Name)
{
global.temp_list[xxx,0] = global.Village_Array[yyy,1] // village number
global.temp_list[xxx,1] = global.Village_Array[yyy,2] // village name

xxx += 1
yyy -= 1

}
}

global.yyyy = yyy + 1

return global.temp_list
- - - - - - - - - - - - - - - - -
obj-Next

Event: Left Button

global.xxxx += 1
if global.xxxx >100
{
global.xxxx = 99
}
- - - - - - - - - - - - - - -
obj_Prev

Event: Left Button

global.xxxx -= 1
if global.xxxx < 0
{
global.xxxx = 1
}

Push :: Execution Error - Variable Index [46,1] out of range [500,0] - -5.temp_list(100017,1472001)
at gml_Object_obj_Village_Name_DrawEvent_1 (line 3) - draw_text(x + 10,y,global.temp_list[global.xxxx,1]);

Now the push error tells me global.temp_list [global.xxxx,1] fails.

I am getting a global.xxxx value of 37,32,37,41,36,39,32,57,91,100,,,,, after depressing the left mouse button (yes I have ran it that many times this morning!)

after I rerun after failure, to test what the value of global.xxxx

There is no rhyme or reason for this!
global.xxxx should only increment or decrement by 1 after each depression of left mouse button.

What am I missing? HELP!

Just changed global.xxxx to lives. There is something amiss! With lives draw shows massive "jumps" in increment/decrement!

tested this code 7/15/2016
//
obj_Next

if (mouse_check_button_pressed(mb_left))
{
lives += 1
}

This is the only code for these objects. no change in outcome. (obj_prev subtracts 1 by code - not working)

Moved to Create Event - activates with any mouse depression within room - but yes by only 1. There is a hint here - now I must figure it out! frustration overload!
 
Last edited by a moderator:
H

heyimdandan

Guest
I don't think you can add or subtract in a Create Event from the way you appear to have placed the code above.
 
G

guadalcanal

Guest
With lives draw shows massive "jumps" in increment/decrement!
So your problem is that when you press the mouse button it increments by large amounts? It also looks like you are using the "Left Button" event. This even will trigger every step while the mouse button is held down. If you want to increment by 1 every click, you need to use either "Mouse Pressed" or "Moused Released" events. Hope this helps!
 
B

Brian Deckman

Guest
I don't think you can add or subtract in a Create Event from the way you appear to have placed the code above.
Thank you for the reply. That part of the code works fine. That is seeding the global.temp_list [ ] and works - as per draw - and when obj_Name or obj_Num access it.

The lives add/sub is taking place in event mouse for obj_Next/Obj_Prev - and that is the only code in them.

The is issue is the huge increase/decrease in lives - not incrementing/decrementing by 1 with a depression - which pushes it outside of the array boundaries. (as per draw - for verification).
 
B

Brian Deckman

Guest
Thank you for the reply.
Nope. Changed event to both results are: 2 restarts
obj_Next
Left Pressed: 1st: 0,47,85,180 2nd: 0,88,208,344
Left Released: 1st: 0,94,206,330 2nd: 0,45,126,224

did not try obj_Prev after these. frustration level extremely high.

and actually, would like it to keep incrementing/decrementing with left button held down. faster scroll thru player villages - which could eventually number in the 100's. (for debug - limit 18 - for the whole game presently)

I need to get this working to move on to other parts of the game. It has me in limbo presently. I really don't have an alternative plan presently.
 
Last edited by a moderator:
E

Electrino

Guest
Im not sure where the error is but I just made a simplified version of what you wrote and it runs perfectly for me.

I created 3 objects (obj_up, obj_down, obj_ValueCount)

In obj_ValueCounts create I put:
Code:
global.value = 0;
and in its draw event I put:
Code:
draw_text(x + 10,y,global.value);
then in obj_up, in the mouse/left pressed event:
Code:
global.value += 1;
if global.value > 100
{
global.value = 99;
}
This results in the value incrementing

and similarly, in obj_down mouse/left pressed event:
Code:
global.value -= 1;
if global.value < 0
{
global.value = 1
}
This results in the value incrementing/decrementing by 1 depending on which object the mouse is hovering over (while the left mouse button is pressed down)
I know this doesn't really help...but at least it shows you're on the right track!
 
B

Brian Deckman

Guest
Im not sure where the error is but I just made a simplified version of what you wrote and it runs perfectly for me.

I created 3 objects (obj_up, obj_down, obj_ValueCount)

In obj_ValueCounts create I put:
Code:
global.value = 0;
and in its draw event I put:
Code:
draw_text(x + 10,y,global.value);
then in obj_up, in the mouse/left pressed event:
Code:
global.value += 1;
if global.value > 100
{
global.value = 99;
}
This results in the value incrementing

and similarly, in obj_down mouse/left pressed event:
Code:
global.value -= 1;
if global.value < 0
{
global.value = 1
}
This results in the value incrementing/decrementing by 1 depending on which object the mouse is hovering over (while the left mouse button is pressed down)
I know this doesn't really help...but at least it shows you're on the right track!
Thank you for your reply.
I checked my other global variables to see if they were misfiring in other parts of the game, they are working fine. I have changed Events, code with no luck. This is happening in a different room - could that be an issue? My Create Game is in one room (0), this is in room(3). ???????????????? My other globals are being used in room(1)?????????????? room(2) doesn't use globals. ??????
 
Last edited by a moderator:
B

Brian Deckman

Guest
I want to extract about 20 pieces of information from global.Village_Array[] per village to draw for player - linked (pointed) to one of the selected villages in global.temp_list[] (these are only the players villages, can not see other players village intel. This is why this is important to get working - and why it is driving my nuts! pure frustration. The player will be gaining or losing villages as he progresses with his military or taken by other live or computer players. So as he requests this intel "screen" it must select only his and display.

After writing the above, I am rethinking this approach. I was attempting to increase game speed by not having to go thru 10,000's of village just for 10-100 villages (in live game) for each next/prev press. But maybe in processor speed doing the sort on all - with a coded if var = player then display, might be the better approach, with just increment/decrement on the full global.Village_Array[]. My quick think here is that global.temp_list with still be accessing global.Village_Array[] for display - and then incorporate a change option, to affect global.Village_Array[]. I am thinking that will add a lot to the processor overhead???????? and/or maybe a couple of nested loops?????? - this all if I don't get this working.
 

TheouAegis

Member
Are obj_Next and obj_Prev being created via code or placed in the room manually?

Check instance_number(obj_Next) and instance_number(obj_Prev)
Click on an instance of obj_Next
Compare the increase in global.xxxx to the number of instances of obj_Next

If the values are the same, there is your issue. Other than that, since you changed over to using Mouse Pressed event, I don't notice anything else that could be causing said issue.
 
B

Brian Deckman

Guest
Are obj_Next and obj_Prev being created via code or placed in the room manually?

Check instance_number(obj_Next) and instance_number(obj_Prev)
Click on an instance of obj_Next
Compare the increase in global.xxxx to the number of instances of obj_Next

If the values are the same, there is your issue. Other than that, since you changed over to using Mouse Pressed event, I don't notice anything else that could be causing said issue.
Thank you for your reply.
WOW! WTF! The instance_create is in Event Draw for obj_Room_Controller - all 5 objects. Draws the borders, headers, art, and main intel (etc.)

For obj_Parent, instance_number - draw_text(x,y,obj_Next_Button - displays 1,
the other 4 are being created constantly! stopped watching after 200+ (LOL).

copy of chunk of code:

//
instance_create(364,18,obj_PARENT_Village_Numb_Name_Next_Prev)
instance_create(364,18,obj_Village_Number);
instance_create(404,40,obj_Village_Name);
instance_create(216,33,obj_Previous_Button);
instance_create(604,33,obj_Next_Button);
// End Village Information Box

Will cut/paste these into a separate Create Event and see what happens! (then make another response/edit).
WOW!

Very interesting - the Parent object is only being created once - correctly - then the others are continuous????????? but that might because, Parent is doing the instance_number and draw_text!

and THANK YOU!

but this now brings up yet another issue of concern. I was under the impression that Draw is a one time event - while Draw GUI was continual.

The issue is one of constraints - when drawing "borders, headers, art, etc." The processor overhead must be huge! and memory required. I'll have to look into this a bit more. When I complete this game will be using 100,000+ obj in the main room (persistent), and then all the subsequent rooms just keep adding. Definitely a learning experience going on here! WOW!

I discovered my error in thinking! of what was going on. THANK YOU! Back to the drawing board, as they say.
 
Last edited by a moderator:
Top