playMaker

Author Topic: Execute JS script  (Read 2411 times)

sascham

  • Playmaker Newbie
  • *
  • Posts: 9
Execute JS script
« on: May 21, 2012, 02:28:28 AM »
Hi,
I tried to find something here in the forum, but was not able to find what I'm looking for
I got an JS script attached to an game object (Engine)
The JS script has this
GameObject.Find("Engine").GetComponent(LoadLevel).loadNewLevel(0); //Where 0 is the level number.
to execute it.
I tried it via playmaker but I end up with two copies loaded of the prefab
If i call this from another JS script it works correctly.
What are the paramaters and action I should use.

Thanks


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Execute JS script
« Reply #1 on: May 21, 2012, 01:52:46 PM »
Use the Send Message action with the name of the method.

Quote
I tried it via playmaker but I end up with two copies loaded of the prefab

Can you describe this problem more, or submit a bug with repro steps? Thanks!

sascham

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Execute JS script
« Reply #2 on: May 22, 2012, 01:04:12 AM »
I got a JS script that i assign to an empty game object "Engine"
the Prefabs i load are tagged as Level
Code: [Select]
function loadNewLevel(levelNo : int) : IEnumerator
{
if (levelNo < Levels.Length) //Make sure there is a level number high enough.
{
if (Levels[levelNo] != null) //Make sure there is a level assigned to the array position.
{
var currentLevel : GameObject = GameObject.FindWithTag ("Level");
Destroy(currentLevel);

yield WaitForEndOfFrame();
Instantiate(Levels[levelNo],levelPosition,transform.rotation);
}
else
{
Debug.Log("There is no level assigned to the Levels array at position " + levelNo);
}
}
else
{
Debug.Log("There is no level assigned to the Levels array at position " + levelNo);
}


}
i created a FSM at the same GameObject i attach a screenshot of the FSM config