Current time: 21.04.2024, 03:53 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Школа ERM 2
» ERM 2.0 для ERA III
Author Message
Archer30 Offline
Moderators

Posts: 1117
Post: #151

Hi! I have a question about arrays in ERM 2.
Is it possible to make a variable in a variable with array?

Looks like %(firstLevelMon[%(value)]) is wrong 102


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 10.03.2021 10:51 by Archer30.)
10.03.2021 10:26
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #152

Archer30, nope, ERM is too low level. We have to define pointer to array item and access it indirectly.

In Lua it would be firstLevelMons[value], but in ERM 2:


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
10.03.2021 14:00
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1117
Post: #153

Hmmm, in this particular case, the name variable is worse than v-variable. I can simplify the code by:



Latest ERA mods and scripts in development - My GitHub
10.03.2021 14:40
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #154

It's awful code. Do not use global variables for almost the same purpose but with invalid logics. You th code I gave above, press F11 and see, what it's compiled too.
Even better try this code for testing:

You'll see something like


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
10.03.2021 17:06
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1117
Post: #155

Berserker, I understand you are not a fan of mixing variable type. I myself never want to mess up with that, but it's sometimes necessary to use v. Check this:


The command uses v index. What should I do to get rid of v-variable in this case? 102


Latest ERA mods and scripts in development - My GitHub
(This post was last modified: 10.03.2021 20:58 by Archer30.)
10.03.2021 17:50
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #156

Array access code via pointers does not need v-vars at all. The code above can be converted to safe:


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
10.03.2021 19:15
Find all posts by this user Quote this message in a reply
Archer30 Offline
Moderators

Posts: 1117
Post: #157

Hmmm, maybe I was wrong about coding. I thought your code would require much more calculation (as you loop through all heroes) and may extend the time of passing the day a little bit.


Latest ERA mods and scripts in development - My GitHub
10.03.2021 20:06
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #158

Try it, it won't. 255 iterations, 2 commands and one condition evaluation. ERM speed is about 400 000 lightweight receivers/sec.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
10.03.2021 21:12
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #159

In response to igrik and Archer30 array indexing request, ERA Team presents v3.3.7:


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
11.03.2021 18:03
Find all posts by this user Quote this message in a reply
daemon_n Offline
Administrators

Posts: 4338
Post: #160

Berserker, что за -1? прочитал в теме обновления.
Божечки, скоро ERM превратится в c++96-copy

P.S: вместо гномов кентаврыYes


Image: widget.png?style=banner2

Новейший Heroes 3 Launcher
11.03.2021 20:39
Visit this user's website Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #161

daemon_n, 5-й параметр был введён сто лет назад. Конечное значение счётчика всегда ограниченно суммой пятого и третьего параметра.
Большинство цикло идут от 0 до КОЛВО_ЧЕГО-ТО - 1. Иногда нужно пропустить последний элемент вообще. Тогда будет -2.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
11.03.2021 21:47
Find all posts by this user Quote this message in a reply
igrik Offline
Administrators

Posts: 2814
Post: #162

(11.03.2021 18:03)Berserker Wrote:  
119 Аллилуйя!


game bug fixes extended.dll || My Plugins || My GitHub
11.03.2021 21:52
Visit this user's website Find all posts by this user Quote this message in a reply
Bes Offline

Posts: 5422
Post: #163

igrik, ты теперь часть ERA Team, как я понимаю, а потому все твои взывания к неким нужностям будут так или иначе воплощаться в ERA3 Spiteful Пора засчехлять мешок с отложенными хотелками Spiteful
11.03.2021 22:33
Visit this user's website Find all posts by this user Quote this message in a reply
igrik Offline
Administrators

Posts: 2814
Post: #164

Bes, не поверишь, но хотелок у меня больше нет.
Раньше были 3: расширенное UN:C, получение структуры героя и стека. Теперь они есть.

В ERM2 сложно работать с массивами в циклах. Решение тут крайне необходимо. Надеюсь оно в скором времени появится в реальности.
Итого - мой мешок с хотелками пуст ))

Вот WoG Scripts 2 допилю (через год, два) и вообще на пенсию уйду.
11.03.2021 23:31
Visit this user's website Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16486
Post: #165

igrik Wrote:Надеюсь оно в скором времени появится в реальности.
Так уже же: https://mods.hmm35.ru/Era%20Update.exe


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
12.03.2021 01:14
Find all posts by this user Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Forum Jump:

Powered by MyBB Copyright © 2002-2024 MyBB Group