Page 1 of 1

function not found

Posted: 19 Oct 2014, 11:19
by racer_simon
Hey guys,

Code: Select all

Void ProcessEvents ()
{
	foreach (Event in PendingEvents) 
	{ 
                if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject)
		{
			if ((Event.Player != Null) && (Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) && (Event.Landmark != Null))
			{
				PickUpObject (Event.Player, Event.Object, Event.Landmark);
				PassOn (Event);
			}
			else
				Discard (Event);
		}
		else 
			PassOn(Event);
	}
}

Void PickUpObject (CSmPlayer Player, CSmObject Object, CSmMapLandmark Landmark)
{
	if ((Landmark.Tag == "Armor") && (Player.Armor < Player.ArmorMax))
		AddPlayerArmor (Player, 100, Player, 1);
	Object.SetPlayer (Player);
	//ObjectDestroy (Object);
}
Error: "Function PickUpObject not found".
Why does the compiler not find my function?

edit: full script

Re: function not found

Posted: 19 Oct 2014, 11:57
by The_Big_Boo
Because in ManiaScript a function has to be declared before calling it, thus the reason why the main function is always the last one. Here you just need to put the PickUpObject function above the ProcessEvents one.

Re: function not found

Posted: 19 Oct 2014, 13:05
by racer_simon
Thanks. I remembered that Maniascript does not have Forward Declaration, but I forgot somehow that I still have to declare the function before the call. :D