Creating a core that eliminates pausing.

Started by Courtesy, September 28, 2014, 06:40:20 AM

Previous topic - Next topic

Courtesy

I can't seem to get this down. I've been working on it for like half an hour, and it felt like such an easy thing, so I'm wondering what argument I'm entering wrong or something, since it all compiles.

I currently have this

# no pause.crpl
# Created on: 9/28/2014 3:15:37 AM
# ------------------------------------------
# Unpauses the game if currently paused
:awake
OperateWhilePaused TRUE

do
IsPaused if TRUE
return UnpauseGame endif

loop


_________

OperateWhilePauses(TRUE) is another way I've had the top line written before.

knucracker

#1
You have a whole lot of errors there.  Arguments order, no args on 'do', no need for a do loop, everything is part of the "Awake" function, etc...  Below is a script that should work.  Note the use of parentheses and that the Awake function is at the bottom.  (--edit-- see the post below this one for a better explanation of the problems and an identical script that doesn't use warp operators)


if (IsPaused)
  UnpauseGame
endif

:awake
  OperateWhilePaused(TRUE)


ParkourPenguin

There are a few things wrong with that code:

  • Everything below the :awake line will be called only once when the core is created. So, since it's only being run once, it won't loop through the check to see if the game is paused during runtime.
  • I can kind of see your logic behind the do loop; however, it's incorrect and unnecessary. The game will execute the script at every available frame it can, meaning that it will loop through the script for you. Don't use the do loop.
  • You don't need the "TRUE" after the "if". The "if" command will pull a boolean from the stack (in this case, IsPaused provides said boolean), and if it's true, then it will execute the code below it. If it's false, then it will go to endif, and continue from there. So that "TRUE" after the "if" is unnecessary.
  • Why the "return" statement? I can see why you made those other mistakes, but I don't know why "return" would have anything to do with this script.

I believe that's about it. Here's a version of that script that should work:
# no pause.crpl
# Created on: 9/28/2014 3:15:37 AM
# ------------------------------------------
# Unpauses the game if currently paused
IsPaused if
UnpauseGame
endif

:awake
True OperateWhilePaused
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Courtesy

It's kinda good to know I had it right the first time, several renditions ago. I started adding other variables like the "true" to if because I started trying to interpret the code differently.
So like I knew that it was checking for if it was paused: if it was paused, a variable comes back "True", so I thought 'maybe it's not working because I didn't tell the If that it's looking for a True", so I set that. It compiled, so I thought it might be right, but then, nope.

Turns out, initially, the only thing I'd done wrong is not knowing that the :awake: commands needed to be at the bottom. I didn't know they affected every line/made all lines only occur once. Even if it did, I thought a loop would fix that. Thanks, sorry for being dumb with code, but thanks for all the patience you give me ^^