Pages: 1
  Print  
Author Topic: Access instance variables stored in ds_list  (Read 2004 times)
Offline (Unknown gender) intygamer
Posted on: March 25, 2014, 08:01:23 PM

Member
Joined: Mar 2013
Posts: 77

View Profile Email
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
Logged
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: March 26, 2014, 09:31:28 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Possibly a segfault—does it happen in debug mode? I'll test this out later to see what happens on my copy.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #2 Posted on: March 26, 2014, 11:37:03 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
I'll bet it was that damn Sasquatch again.

Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) intygamer
Reply #3 Posted on: March 27, 2014, 08:37:32 PM

Member
Joined: Mar 2013
Posts: 77

View Profile Email
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.



I,ll keep and eye out for Bigfoot.

Thanks
Joe
Logged
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: March 28, 2014, 10:18:48 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
I just noticed; you're calling ds_list_create(t0_list);, and I have no idea how. That shouldn't build. It should say t0_list = ds_list_create();.

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.
« Last Edit: March 28, 2014, 10:21:06 AM by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) intygamer
Reply #5 Posted on: March 28, 2014, 11:33:16 AM

Member
Joined: Mar 2013
Posts: 77

View Profile Email
I just noticed; you're calling ds_list_create(t0_list);, and I have no idea how. That shouldn't build. It should say t0_list = ds_list_create();.

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.

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
Logged
Offline (Male) Josh @ Dreamland
Reply #6 Posted on: March 28, 2014, 12:14:01 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: 1
  Print