Not logged inOpenClonk Forum
Up Topic General / Help and Questions / Goal can it work?
- - By Kandif [pl] Date 2013-06-08 14:41
I tried long time ago to do my test goal:

#include Library_Goal

local orangepoints;
local whitepoints;

protected func Initialize()
{
  orangepoints = 0;
  whitepoints = 0;
}

public func IsFulfilled(int player)
{
  if(GetPlayerTeam(player)==1)&&(orangepoints>12))
  return true;
  if(GetPlayerTeam(player)==2)&&(whitepoints>12))
  return true;

  return false;
}

public func addorn()
{
  orangepoints+=1;
}

public func addwhi()
{
  whitepoints+=1;
}

and in one of object have this:

    FindObject(Find_ID(Goal_WinTM))->addorn();

But it doesn't work. Why? And how to fix it ?
I add this goal by:
CreateObject(Goal_WinTM, 0, 0, NO_OWNER);
Parent - - By Zapper [de] Date 2013-06-08 14:52
Mh, one reason could be that the Library_Goal does something itself in the function Initialize() and you overwrite that function with your own Initialize().
You can call the original Initialize() with _inherited.
Your Initialize() would then look like that:

protected func Initialize()
{
  orangepoints = 0;
  whitepoints = 0;
  return _inherited();
}
Parent - By Kandif [pl] Date 2013-06-08 14:57
Still Doesn't work
Parent - - By Kandif [pl] Date 2013-06-08 15:06
I fix it:
it was:
if(GetPlayerTeam(player)==1)&&(orangepoints>12))
but should be like:
if((GetPlayerTeam(player)==1)&&(orangepoints>12))

:P
Parent - By Zapper [de] Date 2013-06-08 15:24
Oh, yes, you should always check if you get warnings or errors when you start the engine, first :)
You can find them either directly in the console or in the OpenClonk.log-file
Up Topic General / Help and Questions / Goal can it work?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill