Page 1 of 3

No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:29 am
by EvanBlack
Code: Select all
typedef struct ActorNode{
    Actor * ThisActor;
    ActorNode * NextActor;
    }ActorNode;


Line 3: Expected {
Line 4: Expected ;

Also, there is no NULL? So what defines a Null pointer?

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:41 am
by skydereign
There is NULL, and you have to write struct ActorNode, since the typedef wasn't processed at that point.
Code: Select all
typedef struct ActorNode{
    Actor * ThisActor;
    struct ActorNode * NextActor;
    }ActorNode;

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:54 am
by EvanBlack
Ok thanks it was just how I had written it. I dunno what was going on, I tried it that way and several other ways but was getting weird errors. I got one error in line 80,000 declaration error. It seems to be working now. I think im really tired...


Code: Select all
ActorNode * parentActor;
parentActor = NULL;


This is not allowed as NULL is const int. This is what I meant, how do I fix this? Just assign both my pointers to NULL rather then setting the structure pointer to NULL?

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:58 am
by EvanBlack
Here is the entire script:

Code: Select all
typedef struct ActorNode{
    Actor* ThisActor;
    struct ActorNode* NextActor;
    }ActorNode;


ActorNode* currentActor, parentActor;
int i;

parentActor = NULL;



//In this case the list is initialize in reverse order child then parent.
void initializeLinkedList()
{
 
    for(i=1;i<=10;i++) {
        //Allocate space for the new actor node
 
        currentActor = (ActorNode *)malloc(sizeof(ActorNode));
 
        //Create the new actor and have the actor node point to it.
        //CreateActor() returns a pointer to the actor.
        currentActor->ThisActor = CreateActor("myNewActor", "icon", "(none)", "(none)", 0, 0, false);
       
        //Sets the last Actor node to be the parent of the Current Node
        currentActor->NextActor  = parentActor;
       
        //Sets the Current Node as the current parent for the next node
        parentActor = currentActor;
 
        }
}




I finally got it to accept it by doing this:

Code: Select all
typedef struct ActorNode{
    Actor* ThisActor;
    struct ActorNode* NextActor;
    }ActorNode;


ActorNode* currentActor;
int i;

//Have to initiate as null on declaration
ActorNode* parentActor = NULL;




//In this case the list is initialize in reverse order child then parent.
void initializeLinkedList()
{
 
    for(i=1;i<=10;i++) {
        //Allocate space for the new actor node
 
        currentActor = (ActorNode *)malloc(sizeof(ActorNode));
 
        //Create the new actor and have the actor node point to it.
        //CreateActor() returns a pointer to the actor.
 
        currentActor->ThisActor = CreateActor("myNewActor", "icon", "(none)", "(none)", 0, 0, false);
 
        //Sets the last Actor node to be the parent of the Current Node
        currentActor->NextActor  = parentActor;
 
        //Sets the Current Node as the current parent for the next node
        parentActor = currentActor;
 
        }
}

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 7:37 am
by EvanBlack
I had to write it out like this:

Code: Select all
ActorNode *currentActor, *parentActor;

parentActor = NULL


That worked out. Now I am just trying to figure out how to change the color... it doesn't seem to be working through the linked list...

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 7:58 am
by EvanBlack
Still having problems and it doesn't make any sense at all...

First problem: Cannot access the last clone.

Second problem: Cannot access the Actors directly through the linked list, have to use call to get clone.


I realize I was calling the child node the parent lol, I am changing that now. I thought it was creating it differently.

here is the ged


The second version, I just linked the last actor to the first actor and that lets me iterate through them. But I still cannot access the actor directly.

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 8:19 am
by skydereign
The second problem is a bug in gE. I think you can read about it here.
http://game-editor.com/forum/viewtopic.php?f=2&t=10615&p=75404#p75404
If I recall correctly, gE needs the getclone call to know to update the actors. It is very similar to the global code problem, which is probably related.

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 8:28 am
by EvanBlack
Alright thanks! I will just have to design either a list or function that will do what I need and update using getclone.

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 1:28 pm
by Game A Gogo
skydereign wrote:The second problem is a bug in gE. I think you can read about it here.
http://game-editor.com/forum/viewtopic.php?f=2&t=10615&p=75404#p75404
If I recall correctly, gE needs the getclone call to know to update the actors. It is very similar to the global code problem, which is probably related.


I'm wondering if this is related to the fact that you can't change an actor's text through a global function without commenting it's name somewhere in the script...
Code: Select all
//MyTextActor
ShowMessage("Hello World");

ShowMessage setting a string to MyTextActor... it wouldn't work without the //MyTextActor

Perhaps the same is happening for color setting and all?

If not, please ignore me!

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 5:16 pm
by EvanBlack
Game A Gogo wrote:
skydereign wrote:The second problem is a bug in gE. I think you can read about it here.
http://game-editor.com/forum/viewtopic.php?f=2&t=10615&p=75404#p75404
If I recall correctly, gE needs the getclone call to know to update the actors. It is very similar to the global code problem, which is probably related.


I'm wondering if this is related to the fact that you can't change an actor's text through a global function without commenting it's name somewhere in the script...
Code: Select all
//MyTextActor
ShowMessage("Hello World");

ShowMessage setting a string to MyTextActor... it wouldn't work without the //MyTextActor

Perhaps the same is happening for color setting and all?

If not, please ignore me!


I don't understand what you said... It worked fine for me...

Code: Select all
void UpdateTextv1(char buffer[30])
{
    strcpy(myText.text, buffer);
}

void UpdateTextv2(char buffer[30])
{
    Actor* myActor;
    myActor = getclone("myText.0");
    strcpy(myActor->text, buffer);
}
 



Both versions work flawlessly with create actor event and a timed event.

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 5:54 pm
by Game A Gogo
Well here is an exemple of what I mean:
robomaze.zip
(12.14 KiB) Downloaded 73 times


run the "game" as it is and press a, you will see the text changing rapidly, then click on the canvas actor that draws the maze and remove the comment "//Action" and you will see the text will not change.

if you're wondering this was done for college as an extra to an assignment, I had upgraded the AI but that version is on the college's network
Also sorry if I'm stirring this off-topic

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:38 pm
by EvanBlack
that is just weird.. Is it because you are updating the text with a call from canvas? Or maybe just a call outside of the text actor itself?

I wonder if this would work for the linked list too.

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:42 pm
by Game A Gogo
EvanBlack wrote:Or maybe just a call outside of the text actor itself?

that is it, it's a GE specific bug.

Perhaps it could be the same for your linked list, at least that's what I'm thinking S:

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:47 pm
by EvanBlack
Well, it didn't work.. Im not sure how it would or how it does work at all but... After running the ged, it spawned clones in gE that I couldn't access. I think its because I didn't free the memory but its weird...

Re: No Linked Lists in gE?

PostPosted: Sat Oct 15, 2011 6:51 pm
by Game A Gogo
Yeah that happened to me too at times, mostly with particles. Go ahead and save your GED and load it again, they won't get saved so you can ignore them. If they had xvelocity or yvelocity set on them they will continue moving in the editor. odd bug if you ask me.

As for your main problem, well I guess skydereign or anybody could help you more than I S: , I suppose it was only for text actors