function not found

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
racer_simon
Posts: 52
Joined: 02 Jul 2011, 11:40

function not found

Post 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
The_Big_Boo
Posts: 1026
Joined: 15 Jun 2010, 15:46

Re: function not found

Post 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.
OS: Win 7 Pro x64
RAM: 2x4GB Corsair @ 1600MHz
CPU: Intel i5 760 @ 3.6GHz
Mobo: Asus P7P55D-E
GPU: NVidia GTX 760 2GB
HDD: WD Black 1TB
Sound: VIA VT1828S (onboard)
Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
User avatar
racer_simon
Posts: 52
Joined: 02 Jul 2011, 11:40

Re: function not found

Post 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
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 10 guests