View unanswered posts | View active topics It is currently Wed May 23, 2018 8:59 am



Reply to topic  [ 9 posts ] 
 #if condition 
Author Message
Rank 6
Rank 6

Joined: Wed May 17, 2017 7:35 am
Posts: 25
This preprocessor condition doesn't throw any errors on compile or runtime:

Code:
#if (PC == "fast")  // PC #defined in initial _init.dat
#include "FASTPATH/objects/objects.dat"
#else
#include "STORYPATH/objects/objects.dat"

However, nothing after the #if seems to be checked. Is there a different format for it, or is implementation not complete yet?


Mon May 22, 2017 9:04 pm
Profile
Rank 17
Rank 17
User avatar

Joined: Fri Feb 27, 2015 2:06 pm
Posts: 520
Location: Australia
XPAdmin would have to confirm but i don't that that would work
Best way would to just have both or only use one set (since they have all the tasks)
Unless you are trying to merge the story and fast together and i don't think that is possible

_________________
Pickled Cow's USING THE FILEMAKER

ESKARN'S TUTORIALS

Eskarn's Dungeon Mod(BETA)

Eskarn's puzzle map (story)


Tue May 23, 2017 1:14 am
Profile WWW
Rank 6
Rank 6

Joined: Wed May 17, 2017 7:35 am
Posts: 25
Why wouldn't it be possible? The majority of tentacle dreams and dungeon packs is duplicated scripts, and any variants can be conditionally included. Could also merge all character types' storylines in the same way.

I guess I could use the regular conditional, or case, but the point of using a preprocessor directive is to cut down runtime processing and memory.


Tue May 23, 2017 1:52 am
Profile
Rank 17
Rank 17
User avatar

Joined: Fri Feb 27, 2015 2:06 pm
Posts: 520
Location: Australia
I'm not to sure what you are trying to do

The packs only uses the stuff in that pack as specified in the story.txt
Code:
    code = "init/stories/dungeon/init_monsai.dat"; 

_________________
Pickled Cow's USING THE FILEMAKER

ESKARN'S TUTORIALS

Eskarn's Dungeon Mod(BETA)

Eskarn's puzzle map (story)


Tue May 23, 2017 6:11 am
Profile WWW
Rank 6
Rank 6

Joined: Wed May 17, 2017 7:35 am
Posts: 25
The code is actually:

Code:
#define STORYSSET "stat_monsai.dat"


The distinction is important because you can use #defines to do elegant scripting like this:

Code:
#include "init/stories/dungeon/settings/STORYSSET"


That's equivalent to a case statement resolved at compile time. If I have PC defined in init_*.dat as "fast", "nerd", "old", "pretty" or "fat", then later I name files and folders to those and have the correct ones for the episode load.

Right now I'm just organizing for easy workflow later, and browsing scripts. Most of my pack files actually point to files in other packs.


Tue May 23, 2017 9:20 am
Profile
Rank 16
Rank 16
User avatar

Joined: Wed Aug 07, 2013 4:51 pm
Posts: 306
My C*/Preprocessor knowledge is rusty, but if this works as in C wouldn't you need a #endif? That should throw an error though I believe.


Tue May 23, 2017 5:21 pm
Profile
Rank 6
Rank 6

Joined: Wed May 17, 2017 7:35 am
Posts: 25
You're correct, it does throw an error without an #endif, and in my actual script that came after many more #includes. With that at the end it doesn't throw any errors, but it also doesn't appear to evaluate the #if condition.

Does it not work with strings?

EDIT: That was the reason; it'll only evaluate integers and single chars.


Tue May 23, 2017 11:22 pm
Profile
Rank 16
Rank 16
User avatar

Joined: Wed Aug 07, 2013 4:51 pm
Posts: 306
Yeah lol. C and strings.

You could maybe use something like this to make it more sane:

Code:
#define PC_FAST 1
#define PC_NERD 2

#define PC PC_FAST

#if PC PC_FAST
  #define.....
#elsif PC PC_NERD
  #define.....
#endif


Wed May 24, 2017 4:34 pm
Profile
Rank 6
Rank 6

Joined: Wed May 17, 2017 7:35 am
Posts: 25
Yeah, I thought of that, but after further testing I found that it's just broken, no matter what I put after #if it never resolves as true.

#ifdef and #ifndef still work, so I'll have to use those.


Wed May 24, 2017 6:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group.
Designed by X-Moon Productions.