Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

Detect Game Version


cristimirt

Рекомендуемые сообщения

Hi. Simple question, not sure if simple answer as well. How can we detect the game version? I'm interested in detecting if it's pre-4.0 or 4.0+.

Ссылка на комментарий
Поделиться на другие сайты

Hi. Simple question, not sure if simple answer as well. How can we detect the game version? I'm interested in detecting if it's pre-4.0 or 4.0+.

You want it not without a reason. So the reason will give you the answer.

Say, if you want to know if it has a certain function to use it, or not, just check if that function does exist.

if common.MyUsefullFunction then
DoStuff()
else
DoOtherStuff()
end

Ссылка на комментарий
Поделиться на другие сайты

But if the function does not exist, won't it give an error? Getting an error everytime you load the addon will make the mod.txt pretty big with time.

Ссылка на комментарий
Поделиться на другие сайты

But if the function does not exist, won't it give an error? Getting an error everytime you load the addon will make the mod.txt pretty big with time.

if common.MyUsefullFunction

Checks if that function exists or not. If not - it will return nil which is same as false to "if" function, so the code after "then" will not be executed, else will trigger instead.

Here's an example:

Once upon a time a function common.GetLocalTime() was moved to mission.GetLocalTime().

Here's how to fix that:

if common.GetLocalTime then 
mission.GetLocalTime = common.GetLocalTime
end

So if you use this script in a 4.0.0 - it will work with no common.GetLocalTime at all. And if you run this in an older version, it will create mission.GetLocalTime and mission.GetLocalTime in your script will work as common.GetLocalTime does.

You may download SetMyFPS and look at first couple of lines. I think you'll understand how does that work.

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования