Function Creation Help

You must understand the Game Editor concepts, before post here.

Function Creation Help

Postby Rux » Wed Nov 26, 2008 5:37 pm

Well I'm making a global code, so i can have a fademusic function. But I'm having trouble with the problems it tells me.
Heres the code
Code: Select all
int funcend;
float fadespeed, fadestop;
void fademusic(fadespeed, fadestop);
if(funcend == 0)
{
    setVolume(1, musicvol); //musicvol is a built in variable\\
    musicvol -= fadespeed;
}
if(musicvol == fadestop)
{
    funcend = 1;
}


I then try to add it but it says "unknown type 'fadespeed': possible old C type declaration"

I then tried adding char in front of the fadespeed and fadestop,
Code: Select all
void fademusic(char fadespeed, char fadestop);


It worked, but you have to put it in draw actor. When I tried it in game mode it said "view -> Draw Actor, line 1: link error: undefined function -> fademusic" I did define it in the global code. It even went yellow like a function should do. Whats wrong?
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Function Creation Help

Postby asmodeus » Wed Nov 26, 2008 6:55 pm

Write this in the global code:
Code: Select all
void fademusic(float fadespeed, float fadestop)
{
  int funcend = 0;
  if(funcend == 0)
  {
    setVolume(1, musicvol); //musicvol is a built in variable\\
    musicvol -= fadespeed;
  }
  if(musicvol == fadestop)
  {
    funcend = 1;
  }
}

And use it later in other scripts like this:
Code: Select all
fademusic(fadespeed, fadestop)

Could I help you?
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: Function Creation Help

Postby Rux » Wed Nov 26, 2008 8:49 pm

Thanks, I'll try it.

EDIT: Yes it worked. I haven't done this for a while so I sorta forgot how.
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest