Author Topic: Simple moving platform script...  (Read 590 times)

0 Members and 1 Guest are viewing this topic.

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 774
  • Karma: +30/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #15 on: December 20, 2015, 10:06:15 PM »
Looks like that loop is stopping the game from going to the platform_2 function.

I changed them to threads (add "thread" before "platform_1" & 2) and then it works.

You can remove that sys.wait(0.001).  That's so small it won't matter.

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 56
  • Karma: +11/-0
  • :3
    • View Profile
    • Mod Page
Re: Simple moving platform script...
« Reply #16 on: December 20, 2015, 10:08:06 PM »
EDIT: THF beat me to it ;P

The main thread for the map script is still running platform_1 (), but it never stops because it contains a while loop that runs forever. This means platform_2() will never get called.

The solution is to thread those functions so they can continue looping without locking the main thread. All you have to do is change the main function to this:

Code: [Select]
void main ()
{
// Call Moving Platform 1 to function
thread platform_1 ();

// Call Moving Platform 2 to function
thread platform_2 ();
}

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 774
  • Karma: +30/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #17 on: December 20, 2015, 11:47:30 PM »
Using an in game trigger would also be another way to solve this.

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #18 on: December 21, 2015, 07:11:44 AM »
Ah that's great guys, thanks. Working well now. Thanks again.
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine