Page 1 of 1

Look, skydragon made an attempt, now you try

PostPosted: Sun Aug 16, 2009 7:31 pm
by Hblade
IT SHOULDNT BE THIS COMPLICATED
Ok, in the Game Editor file, this works PERFECTLY >.> Ok I have this global code
Code: Select all
void TypeMessage(char *message, double speed)
{
    if (messagecomplete == 0)
    {
        strncpy(text, message, i);
        framecount = framecount + 1;
        if (framecount >= speed)
        {
            i++;
            if (i<strlen(message))
            {
                PlaySound2("data/typing sound.wav", 0.422222, 1, 0.000000);
            }
            framecount = 0;
        }
        if (i>strlen(message))
        {
            messagecomplete = 1;
            CreateActor("continuwsymble", "continue", "(none)", "(none)", textbox.xscreen, textbox.yscreen, false);
        }
    }
    if (messageclear == 1)
    {
        strncmp(text, message, 0);
        strncpy(text, message, 0);
        i = 0;
        messageclear = 0;
        strcpy(message, " ");
    }
}

Now, when I press Enter, it adds the next message blah blah, so it types the next message, also when I press enter I have it delete the old text actor and make a new one so that it wont you know, type over the original message, this works untill I compile it...



To put it short
I need a way to erase the old message and write the new one, but not in a manner of it typing over the original message, for example say I have this, "We are up high on this mountian", then the next message is "We are pretty high up, huh?", now how can I erase "We are up high on this mountian" before it types out "We are pretty high up, huh?"... I tried deleting it then creating a new one and it works in the game editor, but when you run the .exe it just shows the older message like it didnt even delete

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 8:57 pm
by skydereign
Code: Select all
void *
mymemset(void * s, int c, size_t n)
{
    char * t = s;
    int i;
    for(i=0;i<n;i++)
    {
        t[i]=c;
    }
    return(t);
}



Normally memset is what you want, but it seems to mess up when setting things to 0, NULL. I tried to make this like the real function, but it really is for char *. It takes char * s, sets all its values from 0 to n to int c. So if you want to clear it, put c as 0. This should work, as it works for my char * work.

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 9:40 pm
by Hblade
Right and uh... how the heck would I use this function O.o

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 9:43 pm
by Hblade
I tried using mymemset("textactor", 0, 0); but that dosnt work either

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:08 pm
by skydereign
You would insert the char*, if you are using one. If not, try using textactor.text. You gave it const char *, but what you need is a the pointer to the array.
Code: Select all
mymemset(textactor.text, 0, 1);


1 should be enough as if a string starts with a 0, it should be empty. If that does not work, set it to 256.

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:12 pm
by Hblade
Thanks, i'ma try it


Tried it but uh.. the next messages dont come up, here how about this, uh, take this file let me know when you got it I dont want other people seeing it, if you can fix it I'll add you in the programmers credit, here, thats what I got done as far as the game goes

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:22 pm
by skydereign
Got it. I am looking at it now. They don't go into game mode, but I will continue looking.

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:25 pm
by Hblade
O.o it dosnt? Huh.. well thats strange, the only time this works is when its in game mode, but when i compile it THEN the text starts glitching

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:38 pm
by skydereign
Okay, I know your's is a bit more complex, but it is a similar principle. I have a show of how the function I said to use works. You would clear the text first, and then implement your function.

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:46 pm
by Hblade
All that does is erase the text of that actor, I need it to erase message, the string held inside of the text, in other words, its the thing that apends it's self to the text in the actor so erasing the text in the actor will just result in it simply repeating the text inside of message

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:53 pm
by skydereign
Is this not what you wanted? Text is typed. "We are up high on this mountain" You press enter, to move to the next text, so it clears it, "". Then since the variable determining your message count is increase is increased, it types a new message "We are pretty high up, huh?"?

That is what I thought you were trying to do. If you want to clear a char *, then you insert the char *, but what I have seen from your code, that is not what you are doing. You are inserting a const char * depending on what message variable, the draw actor event for the text.

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 10:58 pm
by Hblade
Hmm, let me try to explain this better, ok, when in Game Mode, it works perfect, the next message becomes clean and ready to type new oens, but when I compile the game, its as it dosnt even erase, run the .exe file of Map1 to see what I mean

Re: THIS SHOULDNT BE THIS COMPLICATED, MAKSLANE READ THIS

PostPosted: Sun Aug 16, 2009 11:25 pm
by skydereign
Okay, I see it now. I can't make exes, so even if I edit the way you do it, I won't be able to test it. I think it is due to your destroy actor. Since you are creating the same actor, same clonename, it maintains its text. You need to clear it before it is created. That should work, that is why I made the mymemset function, as I had reoccurring text. So if you can implement that method, instead of the destroy method, it should work. You might be able to add it just to your method. Try this though, it works in the ged, and I think it could fix the problem
textbox -> Key Down (return) -> Script Editor
Code: Select all
if (messagecomplete == 1)
{
    mymemset(message.text, 0, 1);
    DestroyActor("message");
    i = 0;
}

Re: Look, skydragon made an attempt, now you try

PostPosted: Mon Aug 17, 2009 12:17 am
by Hblade
When i did that it just erased the message completly