MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

The role-playing games (I-X) that started it all and the various spin-offs (including Dark Messiah).
tnevolin
Scout
Scout
Posts: 179
Joined: 19 Oct 2015

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby tnevolin » 26 Feb 2021, 04:38

Why these tables are empty when I check them in console?

Code: Select all

> dump(vars)
  "{\
}"
> dump(mapvars)
  "{\
}"

cthscr
Golem
Golem
Posts: 613
Joined: 12 Jan 2020

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby cthscr » 26 Feb 2021, 05:45

tnevolin wrote:Do I need to initialize (override) map event every time map is loaded or it could be done once at game initialization?
Former. You Scripts/Maps/*.lua (and map events lines) will be reloaded every time the map is reloaded.
You can opt to change event directly in *.evt file, but that's a bit harder than override event in map script.
tnevolin wrote:Which event should I use to initialize map event: InternalBeforeLoadMap, BeforeLoadMap, BeforeLoadMapScripts, LoadMapScripts, LoadMap, AfterLoadMap?
Neither of them. Put it directly in map script main body.
tnevolin wrote:Do I need to explicitly remove event I am planning to override? Would assigning a function to it just override what was there before?
Yes. No, it would call a function after an original event has been processed.
tnevolin wrote:Why these [vars,mapvars] tables are empty when I check them in console?
Because you haven't put anything into them? (default behavior)

tnevolin
Scout
Scout
Posts: 179
Joined: 19 Oct 2015

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby tnevolin » 26 Feb 2021, 13:22

Thank you for response.
cthscr wrote: Neither of them. Put it directly in map script main body.
I don't understand what is map script main body? I have downloaded MME2.2 and Scripts\Maps directory is empty. Should I take one of the decompiled scripts *.lua and put it there? Should I put *.txt file there as well? Do I need to modify them both?

Or I should just create custom lua script where I programmatically delete and reassign the map event?

I guess one example would worth thousands of words if you have it somewhere on a net.
cthscr wrote:
tnevolin wrote:Do I need to explicitly remove event I am planning to override? Would assigning a function to it just override what was there before?
Yes. No, it would call a function after an original event has been processed.
I tried to remove event before reassigning the new function to it. This also deleted event hint. I would like to preserve it. Is there a way?
cthscr wrote:
tnevolin wrote:Why these [vars,mapvars] tables are empty when I check them in console?
Because you haven't put anything into them? (default behavior)
You mean these are user defined variables those will be stored in saves? So I can introduce any kind of variable and persist it through saves/reloads? How these examples in MME help work then???

Code: Select all

Game.MapEvtLines:RemoveEvent(60)  -- remove original event
evt.map[60] = function()
	local i
	if evt.Cmp("MapVar0", 4) then
		evt.StatusText(5)         -- "Nothing here"
	else
		evt.Add("MapVar0", 1)
I didn't understand this sentence about vars variables type. Should I declare them somehow or just put as key values in this table? What is the purpose of evt.VarNum constant? Isn't it suppose to describe existing variables in this table? Are they used somewhere in original code? Can I use them too?

Sorry. A lot of stupid questions.

Code: Select all

Variables in vars table. They can be accessed from anywhere and are stored in savegames.
Last edited by tnevolin on 26 Feb 2021, 13:26, edited 1 time in total.

cthscr
Golem
Golem
Posts: 613
Joined: 12 Jan 2020

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby cthscr » 26 Feb 2021, 18:20

tnevolin wrote:Thank you for response.
cthscr wrote:Neither of them. Put it directly in map script main body.
I don't understand what is map script main body? I have downloaded MME2.2 and Scripts\Maps directory is empty. Should I take one of the decompiled scripts *.lua and put it there? Should I put *.txt file there as well? Do I need to modify them both?

Or I should just create custom lua script where I programmatically delete and reassign the map event?

I guess one example would worth thousands of words if you have it somewhere on a net.
First link in my signature contains probably the biggest example of MMExtension usage. :)
Let's look at https://gitlab.com/templayer/mmmerge/-/ ... /oute3.lua (script for map "oute3" aka New Sorpigal)
Map events 15, 16 and 231 are overridden while events 140 and 232 are extended.
tnevolin wrote:
cthscr wrote:
tnevolin wrote:Do I need to explicitly remove event I am planning to override? Would assigning a function to it just override what was there before?
Yes. No, it would call a function after an original event has been processed.
I tried to remove event before reassigning the new function to it. This also deleted event hint. I would like to preserve it. Is there a way?

Code: Select all

Game.MapEvtLines:RemoveEvent(100)
evt.hint[100] = "hint" -- could be something like evt.str[10]
evt.map[100] = function()...
tnevolin wrote:
cthscr wrote:
tnevolin wrote:Why these [vars,mapvars] tables are empty when I check them in console?
Because you haven't put anything into them? (default behavior)
You mean these are user defined variables those will be stored in saves? So I can introduce any kind of variable and persist it through saves/reloads? How these examples [with MapVar0] in MME help work then???
Yes, they are user defined lua variables. MapVar0 is from Map.Vars array (from MM6 itself) rather than mapvars table (from MMExtension).
tnevolin wrote:I didn't understand this sentence about vars variables type. Should I declare them somehow or just put as key values in this table?
vars is typical lua table. So it has typical lua key-value elements which are again typical lua variables. vars is already defined in started game (it's not defined yet in, for example, party creation). So you can put something like `vars.mytable1 = {}` or `vars.newvar75 = 12` wherever you want.
tnevolin wrote:What is the purpose of evt.VarNum constant? Isn't it suppose to describe existing variables in this table? Are they used somewhere in original code? Can I use them too?
MM6/7/8 have map (and global) events coded in *.evt files. Evt file contains encoded events in binary format. Evt commands (like evt.Cmp) have their number/id. Parameters of evt commands like evt.Cmp, evt.Add, evt.Set, evt.Subtract (like "ClassIs" etc.) also have their number/id. IIRC VarNum is for these parameters. You can use number instead of string parameter name in evt command (I used it for parameter that was decoded to `nil` by MMExtension)

tnevolin
Scout
Scout
Posts: 179
Joined: 19 Oct 2015

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby tnevolin » 26 Feb 2021, 18:37

Very good explanation. Thank you. I think I can code these events properly now.

So you are the author of Community merge. Cool work!
You mentioned base merge branch there but I could not locate it anywhere on the net or description for it. Is community branch a de-facto standard for most users now?

tnevolin
Scout
Scout
Posts: 179
Joined: 19 Oct 2015

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby tnevolin » 28 Feb 2021, 03:23

Anybody knows the text color scheme? I figured out it is 2 byte value. However, I failed to understand how bits are mapped to RGB.

cthscr
Golem
Golem
Posts: 613
Joined: 12 Jan 2020

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby cthscr » 28 Feb 2021, 10:31

tnevolin wrote:So you are the author of Community merge. Cool work!
You mentioned base merge branch there but I could not locate it anywhere on the net or description for it. Is community branch a de-facto standard for most users now?
I'd say I'm main code contributor now.
"Base Merge" is the term for Merge itself (as Rodril made it) to better distinguish with Community Merge. I can't tell about user preference but for everyone who thinks about creating its own mode on top of Merge I would strongly recommend Community Merge master branch.
tnevolin wrote:Anybody knows the text color scheme? I figured out it is 2 byte value. However, I failed to understand how bits are mapped to RGB.
GrayFace has written once:
MM supports coloring. Just add StrColor(R,G,B) at the beginning and StrColor(0,0,0) at the end of the string. Note that the color has to be computed inside the game, as it is dependant on whether it's in 16 or 15 bits mode. StrColor function is here: https://github.com/GrayFace/MMExtension ... ctions.lua

tnevolin
Scout
Scout
Posts: 179
Joined: 19 Oct 2015

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby tnevolin » 01 Mar 2021, 02:03

Great pointers. Thank you.

tnevolin
Scout
Scout
Posts: 179
Joined: 19 Oct 2015

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby tnevolin » 01 Mar 2021, 02:06

By the way, I have a mm6 mod that emphasizes skills over items. People constantly asking me whether it can be combined with merge mod. Since you are the big contributor there feel free to have a look at it and port any features into merge or ask me to help you with that.
I know that I can also build another one on top of a merge but I don't want to multiply mods. That's useless. People need to play them. I only have created mine because I could not find any similar one out there.

Double_Trouble
Leprechaun
Leprechaun
Posts: 23
Joined: 27 Jun 2011

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby Double_Trouble » 04 Jun 2021, 23:00

Ok, so I tried to start solo MM7 game, but nothing changes after I do what I seem to be supposed to do. This is what it says after ctrl+f1:
———————————————————————————————————————————————————————————————————————————————————
Debug Mode Started. Press Ctrl+Enter to execute commands.
-----------------------------------------------------------------------------------
> vars.PartySize = 1
[string ""]:1: attempt to index global 'vars' (a nil value)

stack traceback:
[string ""]:1: in main chunk
[C]: in function 'pcall'
d:\games\might and magic 7/Scripts/Core/Debug.lua:89: in function 'DoDebug'
d:\games\might and magic 7/Scripts/Core/Debug.lua:131: in function 'debug'
...es\might and magic 7\Scripts\General\DebugConsoleKey.lua:6: in function 'v'
Scripts/Core/EventsList.lua:68: in function <Scripts/Core/EventsList.lua:63>

local variables of '[string ""]:1':
(*temporary) = nil
(*temporary) = 1
(*temporary) = "attempt to index global 'vars' (a nil value)"

Can someone help?

cthscr
Golem
Golem
Posts: 613
Joined: 12 Jan 2020

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby cthscr » 07 Jun 2021, 12:16

vars.* isn't set before the game has been started. Though I've never tried solo games, try to execute it after loading new game map.

Double_Trouble
Leprechaun
Leprechaun
Posts: 23
Joined: 27 Jun 2011

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby Double_Trouble » 07 Jun 2021, 14:12

Oh okay, I was kinda hoping it would remove other portraits, and not just turn them to stone :) Which is why I used the command too early.

User avatar
CATMAN
Leprechaun
Leprechaun
Posts: 26
Joined: 23 Jun 2021

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby CATMAN » 24 Jun 2021, 06:03

... did not find the text input functionality inside the game ...

Rodril
Swordsman
Swordsman
Posts: 579
Joined: 18 Nov 2016

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby Rodril » 24 Jun 2021, 19:15

CATMAN wrote:... did not find the text input functionality inside the game ...
For what purposes do you need text input? One-line input in the game can be used via Question function, other than that you can use debug console pop ups for text input - check scripts inside "Scripts\Global" folder, i don't know how exactly to do it.

User avatar
CATMAN
Leprechaun
Leprechaun
Posts: 26
Joined: 23 Jun 2021

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby CATMAN » 25 Jun 2021, 11:35

Rodril wrote:
CATMAN wrote:... did not find the text input functionality inside the game ...
For what purposes do you need text input? One-line input in the game can be used via Question function, other than that you can use debug console pop ups for text input - check scripts inside "Scripts\Global" folder, i don't know how exactly to do it.
...an example of the level Hello world? I don’t understand how to write this into the script. May be needed for gameplay...

Rodril
Swordsman
Swordsman
Posts: 579
Joined: 18 Nov 2016

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby Rodril » 25 Jun 2021, 13:06

While in the game, press ctrl+f1, debug console will pop up, write your code, and press ctrl+enter to execute it. To make ingame script, create text file with .lua extension, put this file into one of folders in the Scripts folder of your game directory, depending on your goal. Excessive tutorial is at the site, link ti which i posted in my previous message.

User avatar
CATMAN
Leprechaun
Leprechaun
Posts: 26
Joined: 23 Jun 2021

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby CATMAN » 25 Jun 2021, 14:07

... sorry, I meant functionality similar to this ...

Code: Select all

function OnMapStart()
    text = InputBox("CATMAN", 5, 1);
end
Image


User avatar
CATMAN
Leprechaun
Leprechaun
Posts: 26
Joined: 23 Jun 2021

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby CATMAN » 25 Jun 2021, 16:05

catman.oute3.lua

Code: Select all

gamername = Question("What is the gamer's name?", "Who are You?");
Message("Hello" gamername "!")
...Scripts\Maps\catman.oute3.lua:2: ')' expected near 'gamername'

cthscr
Golem
Golem
Posts: 613
Joined: 12 Jan 2020

Re: MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

Unread postby cthscr » 25 Jun 2021, 16:36

Do not use non-lua syntax. (extra semicolon; absent concatenation operator)
Examples work perfectly.


Return to “Might and Magic”

Who is online

Users browsing this forum: No registered users and 11 guests