• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Constants

Is there any reson why its #define and not just const ? I also see that its MANDATORY_TO_USE_CAPS when defining constants
tried to acquire walk speed and runspeed to keep them as constant, got weird result, so the only way is to keep variable if i want to get default speeds of entities to compare with other values later? I thought constant would do that for me as well
 
bWWd,

#define and const are very different things.

- #define is really a macro. You can use it to define constant values as in my tutorial or define bits of code to execute. It's also 100% free. There is absolutely no memory or runtime resource cost with creating #defines.

- Consts are just variables that can't change at runtime - full stop. Otherwise they follow the same rules about acceptable values and have the same associated resource cost.

Generally const is recommended for constant values over #define because the restrictions are actually a good thing. Const also gives you more meaningful errors when things go wrong. At this time though, OpenBOR script doesn't support const. The only way to make named values that are impossible to change at runtime is to #define them.

Also, CAPS are not mandatory at all, just highly recommended. You can use whatever you feel like, but CAPS are the most widely accepted naming convention for #defined constants.

DC
 
Back
Top Bottom