FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Custom resources

5 posters

Go down

Custom resources Empty Custom resources

Post  Don Jaffa Mon May 25, 2009 12:11 pm

Hey, I was just wondering if anyone knows the code to add an object to a specific resource rather than the standard 'everything' resource.

I.e. if I am running a section of code that duplicates an existing object, what do i write to add the duplicated object to the 'level' SIO2resource?

Thanks for any help, this problem has been my nemesis since I started using SIO2 (well, part of the despawning problem I had ages ago and still havent managed to fix Crying or Very sad )

Don Jaffa

Posts : 49
Join date : 2009-02-19

Back to top Go down

Custom resources Empty Re: Custom resources

Post  Don Jaffa Tue May 26, 2009 3:47 am

No-one knows?

Don Jaffa

Posts : 49
Join date : 2009-02-19

Back to top Go down

Custom resources Empty Re: Custom resources

Post  sio2interactive Tue May 26, 2009 3:56 am

just bind the sio2->_SIO2resource handle to another SIO2resource then add whatever you want to it...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Custom resources Empty Re: Custom resources

Post  Don Jaffa Tue May 26, 2009 4:49 am

Now what your saying seems really simple but its refusing to work.

This is what i do:

Code:

SIO2resource *level = NULL;
SIO2resource *playerentity = NULL;
...
...
sio2->_SIO2resource = playerentity;
...
//add player entity objects here
...

sio2->_SIO2resource = level;
...
run the script that duplicates the object here
...

{
   static unsigned int i = 0;
   
   if (i != level->n_object)
   {
      ++TEST_VAL1;
   }
   ++i;



But when I run it I get a 'EXC_BAD_ACCESS' error here:

Code:

case SIO2_OBJECT:
      {
         
         //This next lines gets the error
         while( i != _SIO2resource->n_object )
         {
            SIO2object *_SIO2object = ( SIO2object * )_SIO2resource->_SIO2object[ i ];
            
            if( !sio2StringCmp( _SIO2object->name, _name ) )
            { return _SIO2resource->_SIO2object[ i ]; }
            
            ++i;
         }
         
         break;
      }


Sorry if I'm being really stupid but this is so frustrating Im losing the will to carry on with the project, i really need a pointer to show me where I'm going wrong.

Cheers

Don Jaffa

Posts : 49
Join date : 2009-02-19

Back to top Go down

Custom resources Empty Re: Custom resources

Post  sio2interactive Tue May 26, 2009 4:57 am

Have you initialize the dictionary of both resources?
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Custom resources Empty Re: Custom resources

Post  Don Jaffa Tue May 26, 2009 5:04 am

Ahh, no I didn't realise that thankyou (thought now I'm getting the bad access error here):
Code:

void sio2ResourceAddEntry( SIO2resource        *_SIO2resource,
                    char              *_str,
                    SIO2parsercallback *_root,
                    SIO2parsercallback *_custom )
{
   ++_SIO2resource->n_entry;
   
   _SIO2resource->_SIO2entry = ( SIO2entry * ) realloc( _SIO2resource->_SIO2entry, _SIO2resource->n_entry * sizeof( SIO2entry ) );
   
   sio2StringCpy( _SIO2resource->_SIO2entry[ _SIO2resource->n_entry - 1 ].str, _str );
   
   _SIO2resource->_SIO2entry[ _SIO2resource->n_entry - 1 ].root  = _root;
   _SIO2resource->_SIO2entry[ _SIO2resource->n_entry - 1 ].custom = _custom;
}

1 thing I think may be giving me problems - does the resources struct refer to the 'blahblah.sio2' files? So if I want a resource called 'level' will I need a 'level.sio2' file, or can I keep all my objects in my main 'game.sio2' file?

Don Jaffa

Posts : 49
Join date : 2009-02-19

Back to top Go down

Custom resources Empty Re: Custom resources

Post  sio2interactive Tue May 26, 2009 5:07 am

No necessarily, personally I have like over a dozen .sio2, for each level, characters, UI etc... all with different name have no importance...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Custom resources Empty Re: Custom resources

Post  Don Jaffa Tue May 26, 2009 5:35 am

Is there a tutorial that uses separate sio2resources that I can take a look at and see what's going wrong with mine?

Don Jaffa

Posts : 49
Join date : 2009-02-19

Back to top Go down

Custom resources Empty Re: Custom resources

Post  monkeys Wed Aug 05, 2009 10:41 pm

I would also like to see a tutorial with multiple resources, as I really can;t seem to get my head around how to implement multiple resources.

A tutorial on that would be fantastic!!

monkeys

Posts : 8
Join date : 2009-07-22

Back to top Go down

Custom resources Empty Re: Custom resources

Post  sio2interactive Wed Aug 05, 2009 10:55 pm

Every resources in the MeditationGarden are independent... the garden, bird, fish, butterfly, UI etc... its a great resource to learn how to mix everything together. I highly suggest it to you.


Last edited by sio2interactive on Fri Aug 07, 2009 9:16 pm; edited 1 time in total
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Custom resources Empty Re: Custom resources

Post  oioioi Thu Aug 06, 2009 5:29 am

Just one quick question while we're on resources: why have you added a name to the resources in 1.4? I can't see it being used in anything but the init function

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

Back to top Go down

Custom resources Empty Re: Custom resources

Post  sio2interactive Thu Aug 06, 2009 6:09 am

well when you have multiple SIO2resource handle that call sio2ResourceRender and suddenly it crash im sure you would like to know from which SIO2resource it come from not just something like 0xa828a0 Wink
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Custom resources Empty Re: Custom resources

Post  oioioi Thu Aug 06, 2009 7:27 am

smart Smile

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

Back to top Go down

Custom resources Empty Re: Custom resources

Post  yarri Thu Aug 06, 2009 9:51 am

Hi, while I encourage everyone to sponsor Romain and I'm sure the source code to iZenGarden has a lot of cool tricks, I found it pretty straight forward to load multiple resources. My code is something like this (sorry, still at 1.3.5):

templateLoading():
Code:

   if( !sio2->_SIO2resource->n_entry )
   { sio2ResourceCreateDictionary( sio2->_SIO2resource ); }
      
   if( !sio2->_SIO2resource->uf )
   {
      char scene_name [64];
      sprintf(scene_name, "scene%02d.sio2", scene_number);
      printf("Loading %s ...\n",  scene_name);
      sio2ResourceOpen( sio2->_SIO2resource, scene_name, 1 );
   }
   
   if( i != sio2->_SIO2resource->gi.number_entry )
   {
      sio2ResourceExtract( sio2->_SIO2resource, NULL );
      ++i;
   }
   else
   {
      sio2ResourceClose( sio2->_SIO2resource );
      sio2ResourceOpen( sio2->_SIO2resource, "character.sio2", 1 );
      int i = 0;
      while( i != sio2->_SIO2resource->gi.number_entry )
      {
         sio2ResourceExtract( sio2->_SIO2resource, NULL );
         ++i;
      }
      sio2ResourceClose( sio2->_SIO2resource );
   }

Not sure if this helps you?

--doug

yarri

Posts : 81
Join date : 2009-04-10

Back to top Go down

Custom resources Empty Re: Custom resources

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum