- 积分
- 52365
- 威望
- 258
- 魅力
- 268
- 经验
- 34451
- 热心度
- 37
- 注册时间
- 2006-7-9
- 最后登录
- 2024-8-28
- 主题
- 408
- 回帖
- 9896
- 精华
- 19
- 阅读权限
- 200
TA的每日心情 | 开心 2020-9-19 16:27 |
---|
签到天数: 7 天 连续签到: 1 天 [LV.3]火元素使者
管理员
风侠
- 积分
- 52365
|
发表于 2011-7-16 08:34:53
|
显示全部楼层
Hello!
I would want to introduce a new thing for Heroes 3 WOG, ERA Platworm by Berserker.
Its a .DLL file, still in development, which replaces standard ERM scripts with .LUA scripts.
I have already said why LUA is better than ERM in other topic, so I'll just quote myself:
[quote]
I cannot create my own temat for that so I will write here.
I'm developing a DLL for ERA platworm with LUA Scripting system instead of regular ERM. The cons of this solution are great:
> more language flexibility, allowing to create much better things with LUA (tables, iteration, datatypes etc)
> system reads all .LUA files from .\Data\Lua\ directory and scripts have their own variables, so one script won't mess another like in ERM (even with official 3.58f+script update, there are many variables used by several scripts at once and messing game, causing glitches like ballista named "The first aid tent heals ETC hitpoints" or creatures turning into first aid tents after battle, and even a glitch with 4095 wandering monsters (entering battle = CRASH). with LUA there is NO WAY for scripts to mess up themeselves as every script is handled by his own interface.
> also other "indexed" things like !!FU numbers are overlapping from script to script
> better looking code
> more interesting functions like including other files, math functions (like power, abs, min, max), even saving/loading things on xml, ini files, controlling mouse pointer, running winapi functions and much more
> better random generator as it now supports FOUR random generators:
* doGenerateRandomNumber(min, max) - generates random number using !!VR:T erm function
* lua math.random(min, max) - generates random number using LUA library function
* RandomNumber(min, max, seed) - generates random number using Pascal random number generator
* BoxMuller(min, max) - generates random number using box muller alghoritm
> MUCH more easier to develop a script for H3, a typical newbie-scripter dont have to read 32523523 pages of ERM manual and choosing clean variables from 358f_Claimed.txt, instead he runs a notepad and start writing
> I'm planning to develop a script editor for that as well
For now system works stable, and allows to use around 90% of "triggers" and around 40% of "receivers" from ERM (its using ERM interface). Also I icluded few nice things from this forum (like lua function that allows shooting with non-shooters, by Salamandre). It works like a some kind of wrapper:
instead of ERM -> Heroes3
we got LUA -> ERM -> Heroes3
The project is not finished, its still in development. If someone wants to check a BETA, UNTESTED and UNFINISHED LUAErm mod, here is the link:
http://www.speedyshare.com/files/24922358/_LUA_ERM.rar
Install instructions:
1. THIS REQUIRES A PLATWORM ERA 1.6 OR 1.8 BY BERSERKER. ENGLISH COMMUNITY VERSION IS ENOUGH TO MAKE IT WORK. IT CAN BE DOWNLOADED FROM WOGARCHIVE.RU AND PERHAPS FROM OTHER SITES.
2. RENAME YOUR HEROES3\DATA\S\ FOLDER TO SOMETHING OTHER (AS BACKUP), BECAUSE ALL SCRIPTS HAVE TO BE DELETED
< ~-- VERY IMPORTANT --~ >
3. MAKE SURE THAT IN YOUR DATA\S\ DIRECTORY, THERE ARE NO ERM SCRIPTS
< ~-- VERY IMPORTANT --~ >
4. UNPACK ARCHIVE INTO ROOT HEROES3 FOLDER
5. IF CORRECT, FILES WILL BE THERE:
> Heroes3\Celtica.dll
> Heroes3\lua.dll
> Heroes3\lualib.dll
> Heroes3\luareceivers.txt
> Heroes3\luatriggers.txt
> Heroes3\Data\lua\test.lua
> Heroes3\Data\lua\xxx.lua
> Heroes3\Data\lua\global\global.lua
> Heroes3\s\Script00.erm
6. LAUCH GAME AND START A SCENARIO. IF CORRENT, A DEBUG.TXT FILE WILL BE CREATED IN ROOT H3 DIRECTORY.
But beware! It wasnt supposed to be released now, its just untested and still in development. I have uploaded it, because I wanted to show that I'm doing real thing, not only words.
Most of receivers are still untested and not guarantee to work. The most part that's done are !!OB, !!UN, !!MO, !!SN and similar. The list of lua functions are in text files luareceivers.txt and luatriggers.txt.
---
How this does work?
After Heroes3 map is started, Celtica.dll is called from ERM. For now all scripts in .\Data\Lua\ directory are parsed and translated into byte code by LUA library. Now on certain events (90% of triggers are working now), lua functions from all files are called. LUA Functions are handled by Celtica.dll which passes variables out and in and calls standard ERM !!FU's from Script00.erm. The script00.erm should not be modified as its now only used as a engine.
Also few notes:
> saving and loading game is still not implemented. scripts should work after loading game, but its not handled and variables will get reset after loading. its just still not done yet.
> lua comments are strict and must start with two -- chars
> list of lua functions sometimes refer to "pos" as parameters/function results. pos is a lua table with three fiels - X,Y,Z.
in order to delete an object from pos 25/22/0, you must create a pos table and push it into function:
local ourBadPos = {x=25, y=22, z=0}
doDeleteObject(TRUE, ourBadPos)
if position is passed as parameter from a function, you can refer to it by typing this in script:
ourBadPos.x = 55 --this will set X of ourBadPos to 55
local mySuperVar = ourBadPos.y --this will set mySuperVar equal to Y of ourBadPos
other parameters are mostly string and integer-based. for example function
function onHeroMove(hero, pos)
hero is a number from 0..155 indicating hero ID.
> global.lua is a special file which is ALWAYS parsed as primary file for all script. it contains few definitions to make scripting more useful, if you need some constants, there is a good list in global.lua
for example, you don't have to remember which color is which number - you can only write PLAYER_BLUE and this will equal 1 (as 1 = blue for Heroes3 and ERM)
> if script is not doing anything, make sure that it have loaded properly. scripts are not parsed in runtime, they are translated to bytecode during loading - this means that if there is a syntax error in code, it wont load at all, just drop an error in debug.txt file.
Thats all from my side. Thanks.[/quote] |
|