ENIGMA Forums

Outsourcing saves money => Programming Help => Topic started by: intygamer on March 25, 2014, 08:01:23 pm

Title: Access instance variables stored in ds_list
Post by: intygamer on March 25, 2014, 08:01:23 pm
I am working on a Civilization type of game turn based where the game switches keyboard control to each unit for each players turn.  Each player will have multiple units being added as the city earns enough money.

The ds_list is working, I tested rotating threw instances with draw_text.  I can't seem to get image_index to switch or control movement with keyboard without the game closing down on me.

Here is the code I used.
Code: [Select]
// script
Unit = instance_create(argument0, argument1, obj_Unit);  // The script is ran from ob_spawner 
ds_list_add(t0_list,Unit);

Obj_Unit Create:
ds_list_create(t0_list);

// obj_Unit Page Up
up +=1;
if(up > (ds_list_size(t0_list) - 1)) {up = 0;}
sc = true;

// obj_Unit Page Down
up -=1;
if(up < 0) {up = (ds_list_size(t0_list) -1);}
sc = true;

// obj_Unit Step
if(sc = true)
{
inst = ds_list_find_value(t0_list,up);  // I put instance id into temp variable inst.
inst.image_index = 1;  // I try to change the variable image_index for that instance. 
sc = false;
}

My problem is when I run step event code.  I must not be the instances correctly.  Please help

Thanks
Joe
Title: Re: Access instance variables stored in ds_list
Post by: Josh @ Dreamland on March 26, 2014, 09:31:28 am
Possibly a segfault—does it happen in debug mode? I'll test this out later to see what happens on my copy.
Title: Re: Access instance variables stored in ds_list
Post by: Goombert on March 26, 2014, 11:37:03 am
I'll bet it was that damn Sasquatch again.

(http://d1w7nqlfxfj094.cloudfront.net/wp-content/uploads/2012/10/pee-pants-miles-davis.jpg)
Title: Re: Access instance variables stored in ds_list
Post by: intygamer on March 27, 2014, 08:37:32 pm
Possibly a segfault—does it happen in debug mode? I'll test this out later to see what happens on my copy.
It does the same thing in debug mode.
Code: [Select]

*********** EXECUTE
  `/usr/bin/make`
  `Game`
  `WORKDIR=/home/joey/.enigma/`
  `GMODE=Debug`
  `GRAPHICS=OpenGL1`
  `AUDIO=OpenAL`
  `COLLISION=Precise`
  `WIDGETS=None`
  `NETWORKING=None`
  `PLATFORM=xlib`
  `CXX=g++`
  `CC=gcc`
  `COMPILEPATH=Linux/Linux`
  `EXTENSIONS= Universal_System/Extensions/Alarms Universal_System/Extensions/Timelines Universal_System/Extensions/Paths Universal_System/Extensions/MotionPlanning Universal_System/Extensions/DateTime Universal_System/Extensions/ParticleSystems Universal_System/Extensions/DataStructures`
  `OUTPUTNAME=/tmp/egm6124076566347273319.tmp`
  `eTCpath=`



******** Make Completed Successfully ********
`$exe` == '$exe': true
8 Adding Sprites to Game Module:
Done writing sprites.
Finalized sprites.
0 Sounds:
Done writing sounds.
0 Adding Backgrounds to Game Module:
Done writing backgrounds.
2 Adding Fonts to Game Module:
Iterating included fonts...
Allocated some font stuff
Copied metrics
Sorted out some font stuff
Expanded to 128 by 64
Finished packing font stuff.
Allocated a big texture. Moving font into it...
Wrote all data for font 0
Iterating included fonts...
Allocated some font stuff
Copied metrics
Sorted out some font stuff
Expanded to 128 by 64
Expanded to 128 by 128
Finished packing font stuff.
Allocated a big texture. Moving font into it...
Wrote all data for font 1
Done writing fonts.
0 Adding Paths to Game Module:
Done writing paths.
Closing game module and running if requested.
Running "/tmp/egm6124076566347273319.tmp"


*********** EXECUTE
  `/tmp/egm6124076566347273319.tmp`



Initializing audio system...
Opening ALURE devices.
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 2, instance id 100002: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100004: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100005: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100006: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100007: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100008: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100009: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100010: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100011: Accessing uninitialized variable
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480


Game returned 0
0


I see I have unintalized variable errors.  I have added var Unit to script and var inst to obj_Unit.  I got same errors after doing that.

The game starts up and then closes when I hit an active key.

I'll bet it was that damn Sasquatch again.

(http://d1w7nqlfxfj094.cloudfront.net/wp-content/uploads/2012/10/pee-pants-miles-davis.jpg)

I,ll keep and eye out for Bigfoot.

Thanks
Joe
Title: Re: Access instance variables stored in ds_list
Post by: Josh @ Dreamland on March 28, 2014, 10:18:48 am
I just noticed; you're calling [snip=edl]ds_list_create(t0_list);[/snip], and I have no idea how. That shouldn't build. It should say [snip=edl]t0_list = ds_list_create();[/snip].

Was that just some copy-paste error, or did someone change how lists work? Possibly, it's accepting an initial size, but it seems to not be documented (http://enigma-dev.org/docs/Wiki/Ds_list_create).
Title: Re: Access instance variables stored in ds_list
Post by: intygamer on March 28, 2014, 11:33:16 am
I just noticed; you're calling [snip=edl]ds_list_create(t0_list);[/snip], and I have no idea how. That shouldn't build. It should say [snip=edl]t0_list = ds_list_create();[/snip].

Was that just some copy-paste error, or did someone change how lists work? Possibly, it's accepting an initial size, but it seems to not be documented (http://enigma-dev.org/docs/Wiki/Ds_list_create).

I think I miss type in 1st post only t0_list = ds_list_create(0); worked.

I did fix the problem.  I moved the t0_list = ds_list_create() from obj_Unit create event to obj_spawner create event that calls the script that creates the instances.   :)

I still get errors in showing in termial in debug mode, but the game works now.  Not sure if it's a big deal or not?
Code: [Select]
*********** EXECUTE
  `/tmp/egm1613180763639922822.tmp`



Initializing audio system...
Opening ALURE devices.
ERROR in some action of some event for object 6, instance id 100003: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100004: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100005: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100006: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100007: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100008: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100009: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100010: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100011: Accessing uninitialized variable
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
ERROR in some action of some event for object 6, instance id 100003: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100004: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100005: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100006: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100007: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100008: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100009: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100010: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100011: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100003: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100004: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100005: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100006: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100007: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100008: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100009: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100010: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100011: Accessing uninitialized variable
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
ERROR in some action of some event for object 6, instance id 100003: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100004: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100005: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100006: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100007: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100008: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100009: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100010: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100011: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100003: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100004: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100005: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100006: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100007: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100008: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100009: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100010: Accessing uninitialized variable
ERROR in some action of some event for object 6, instance id 100011: Accessing uninitialized variable
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480
0 0 640 480


Game returned 0
0


Thanks for all your help!
Joe
Title: Re: Access instance variables stored in ds_list
Post by: Josh @ Dreamland on March 28, 2014, 12:14:01 pm
For now, don't worry about it. We'll have better error reporting at some point in the discrete future, so you'll know which variable you're using undeclared. The 0, 0, 640, 480 thing is probably my fault, from when I was editing the view code. Don't worry about it, either.