Skip to main content
↑
↓
Spherical forums
Community for the
Sphere game engine
New?
Contact Us
to register an account!
1 Hour
1 Day
1 Week
1 Month
Forever
Community
Help
Search
Recent Posts
Log in
Contact Us
News
Spherical
Facebook
-
Twitter
-
Discord chat
New?
Contact us
to register an account!
Sphere Development
Sphere Support
Script Support
Require/Evaluate Script
1
Print
Topic: Require/Evaluate Script
(Read 5243 times)
previous topic
-
next topic
0 Members and 1 Guest are viewing this topic.
Harry Bo21
Low Poster
Posts: 68
Logged
Require/Evaluate Script
May 15, 2013, 09:11:16 pm
Why would you use evaluate if you have require? surely require is just the more efficient equivalent right?
N E O
Hero Poster
Posts: 585
Making it happen!
Logged
Administrator
Senior Administrator
Re: Require/Evaluate Script
Reply #1
–
May 16, 2013, 01:47:04 am
I think the main difference between the two is that require would abort out if it couldn't include it, while evaluate wouldn't.
This just had me realize there's no equivalent to include_once/require_once in Sphere's API. Hmm.
Radnen
Big Chungus
Posts: 1,440
Sphere Studio Developer
Logged
Senior Staff
Wise Warrior
Re: Require/Evaluate Script
Reply #2
–
May 16, 2013, 02:12:44 am
RequireScript was supposed to only be required once. But I don't think that's true.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.
Sphere-sfml
here
Sphere Studio editor
here
Fat Cerberus
Big Chungus
Posts: 2,774
*MUNCH*
Logged
Global Moderator
Sphere Developer
Re: Require/Evaluate Script
Reply #3
–
May 16, 2013, 02:43:28 am
RequireScript is like #pragma once in C++, if the same script has already been included, it won't evaluate it again. This is so you can put your dependent scripts at the top of each of your classes without worrying about the same script being eval'd again and potentially overwriting globals in the process.
neoSphere 5.9.2
-
neoSphere
engine -
Cell
compiler -
SSj
debugger
forum thread
|
on GitHub
Flying Jester
Legendary Poster
Posts: 1,161
Logged
TurboSphere Developer
Re: Require/Evaluate Script
Reply #4
–
May 16, 2013, 04:59:31 pm
I'm not sure it actually works that way, though. I seem to recall having issues with RequireScript running the script even if it was previously included.
Learn some history?
The Flying Jester's Blog of Sorts
Fat Cerberus
Big Chungus
Posts: 2,774
*MUNCH*
Logged
Global Moderator
Sphere Developer
Re: Require/Evaluate Script
Reply #5
–
May 16, 2013, 05:08:31 pm
Odd, I use it all over Specs and never had an issue. Of course I'm using Sphere 1.5 still, maybe there was a regression in 1.6?
neoSphere 5.9.2
-
neoSphere
engine -
Cell
compiler -
SSj
debugger
forum thread
|
on GitHub
alpha123
Medium Poster
Posts: 152
Logged
Re: Require/Evaluate Script
Reply #6
–
May 17, 2013, 01:10:03 am
From when I was working in the C++ source more often doing Sphere 1.7,
RequireScript()
is definitely supposed to only load the script once, while
EvaluateScript()
will load the script every time it is called. However, I did have an issue recently that suggested it might not actually work.
So really I'm not quite sure. Given that I don't think anybody relies upon RequireScript bugs, that would be a nice fix for TurboSphere.
1
Print
Sphere Development
Sphere Support
Script Support
Require/Evaluate Script