Issue with creating timers in the script editor

Non-platform specific questions.

Issue with creating timers in the script editor

Postby CrackedP0t » Sat Mar 15, 2014 9:30 pm

So, I have this code in the Global Code:
Code: Select all
struct {
    struct {
        int xoffset;
        int y;
        int wait;
        int end;
           } movements[5];
    int columns;
    int waittime;
    int enemytype;
    int rows;
    int untilnext;
       } levels[5][5];

oid startsquad(int levelno, int squadno) {
    Actor * view = getclone("view");
    int c;
    Actor * enemy;
    int offint;
    int r;
    for (c = 0; c < levels[levelno][squadno].columns; c++) {
         offint = view->width / (levels[levelno][squadno].columns + 1);
         for (r = 0; r < levels[levelno][squadno].rows; r++) {
             enemy = CreateActor("enemy", "enemy0", "(none)", "(none)", view->x + offint * (c+1),
              levels[levelno][squadno].movements[0].y, true);
              CreateTimer(enemy->clonename, "linetimer", levels[levelno][squadno].movements[0].wait * r);
                                                             }
                                                             }
                                            }

I call startsquad(0,0) in an actor.
It mostly works, but the timer's not working when I create it from the function. It works fine when I create it otherwise.
Please help
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Sun Mar 16, 2014 3:45 pm

It's kinda hard to try to solve your problem without having it in a .ged, and it's quite difficult to make one since all the actor names and animations and timer names should match. Could you make an example .ged with only this thing in case you don't want to share your entire project with everyone? :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby CrackedP0t » Sun Mar 16, 2014 4:08 pm

Nah,I'll just post the whole thing. I'm not worried about it.
Attachments
bullethell.zip
(158.68 KiB) Downloaded 189 times
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Sun Mar 16, 2014 6:44 pm

The problem is that the CreateTimer -function tries to create a timer that doesn't exist in the project.

It appears that new timers created while in the Global Code (not created like in Game Mode, but created as added to the game project via the Create Timer -menu) are not usable anywhere - you can't add events to them, Game Editor doesn't add the whole timer to the project.
Changing the name of the timer to be created to shottimer, which you already have created in the player actor's Create Actor event fixes it.
But you won't be able to see it working before adding some event to the timer, which you hadn't done.

I added this to the enemy actors timer event for shottimer:
Code: Select all
r = g = 0;

And it changes color after a while.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby CrackedP0t » Sun Mar 16, 2014 9:29 pm

Thanks. However, I need the shottimer for something else... how can I use linetimer?
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Sun Mar 16, 2014 9:41 pm

CrackedP0t wrote:Thanks. However, I need the shottimer for something else... how can I use linetimer?

What's the problem with using shottimer? Really the only difference is the name, aince you modify its length anyway. Different actors can use the same timer for different things.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby CrackedP0t » Sun Mar 16, 2014 10:20 pm

The shottimer shoots periodically and constantly. The linetimer will be used to make them move forward in a line.
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Sun Mar 16, 2014 10:26 pm

Well, then you just have to have the timer in some actor, defined in an event, not Global Code.
For example, you can create an actor called timer actor. Put the timer in its create actor and destroy the actor in the timer event. It's an ugly fix but should allow you to use the timer everywhere on the project, even in Global Code.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby CrackedP0t » Mon Mar 17, 2014 7:00 pm

OK; I tried to use a timer actor, but it didn't work.
Could you please add it to the GED and post it?
:)
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Mon Mar 17, 2014 7:30 pm

CrackedP0t wrote:OK; I tried to use a timer actor, but it didn't work.
Could you please add it to the GED and post it?
:)

How did you try it?
You have to first define the timer in the timer actors event.
I can add it but not today. I'll send it to you tomorrow if you don't get it fixed by that time.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby CrackedP0t » Thu Mar 20, 2014 2:26 am

OK, I need that GED; maybe it's just a bug.
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Thu Mar 20, 2014 3:11 am

CrackedP0t wrote:OK, I need that GED; maybe it's just a bug.

Yes, it is a bug, as I said. I did some testing, and it appears that if a timer is not a part of any actor's event (and using a timer through another function doesn't count)
as a CreateTimer() call or as the selected timer for the timer event, it will disappear from the project.

So, for adding a timer that will be only created through a function defined in the Global Code, there's one way you can do it.

Go to any actor's any event (for example view's create actor event), and first define the timer there by using a CreateTimer call.
Then go to Global Code and add your timer creation code to you function. Then give the timer event to the actor the timer will be created to
with that function. After that you can erase the CreateTimer call from the event you first defined the timer in, (this would mean view actor's create actor event in this example of mine).

So while you don't actually need a specified timer actor as I first suggested, you still need to first define the timer straight in an actor's event.

With this explanation you should be good even without me sending an example ged for you, but here's one anyway.
Attachments
bullethellTimerFix.ged
here
(23.76 KiB) Downloaded 181 times
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby lcl » Sat Mar 22, 2014 6:00 pm

So did it work / did you understand it now? :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Issue with creating timers in the script editor

Postby CrackedP0t » Sun Mar 23, 2014 12:01 am

Yep. Thank you!
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron