No Linked Lists in gE?

Non-platform specific questions.

No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 6:29 am

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?
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby skydereign » Sat Oct 15, 2011 6:41 am

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 6:54 am

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?
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 6:58 am

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;
 
        }
}
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 7:37 am

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...
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 7:58 am

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.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby skydereign » Sat Oct 15, 2011 8:19 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 8:28 am

Alright thanks! I will just have to design either a list or function that will do what I need and update using getclone.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby Game A Gogo » Sat Oct 15, 2011 1:28 pm

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!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 5:16 pm

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.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby Game A Gogo » Sat Oct 15, 2011 5:54 pm

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
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 6:38 pm

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.
Last edited by EvanBlack on Sat Oct 15, 2011 6:47 pm, edited 2 times in total.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby Game A Gogo » Sat Oct 15, 2011 6:42 pm

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:
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: No Linked Lists in gE?

Postby EvanBlack » Sat Oct 15, 2011 6:47 pm

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...
Attachments
weirdglitch.png
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: No Linked Lists in gE?

Postby Game A Gogo » Sat Oct 15, 2011 6:51 pm

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
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest