Page 35 of 38

Re: Generic Mapping Script

Posted: Fri Aug 10, 2018 11:44 am
by Jor'Mox
I didn't see any colors at all, but I think that is because it disabled ANSI after some test where it seemed like it was trying to write text, delete it, and then write more text, which Mudlet obviously has decided not to allow. But, presumably one could lie during that test and just get a more cluttered screen as a result, but have color.

Side note, I have been pondering how to both just improve mapping in general, and to allow it to be used in other languages most easily, is there any chance we could just make ALL mapping functions that need a direction accept the direction number instead of the various requirements, in which some need a number, but others won't take a number, and instead need text? Similarly, if an extra argument was added to functions that returned map info with directions to return those directions in number form, then someone could always interact with the direction numbers once in code, and all they would need to do would be to convert their direction words to the correct numbers when working with in-game text.

Re: Generic Mapping Script

Posted: Thu Aug 16, 2018 6:52 pm
by Jor'Mox
An issue wherein the mapper would reappear after being hidden was brought to my attention, and has been fixed in the current package file. The problem was because, for whatever reason, I had an old version of the window manager script I was using included with the package, instead of the most up to date version. If you don't plan on hiding the mapper window, then this change won't impact you one way or the other. If you are, you can either get the new script version from the package, or you can use the link on the first post of this thread to go to the Simple Window Manager thread, and grab the most up to date version of the script from there.

Re: Generic Mapping Script

Posted: Wed Aug 29, 2018 3:22 pm
by Intort
first off, thanks for making this great plugin.
but unfortunately, there are too many things i can't understand yet.

im so confusing now.
what exact things do i have to do ?

well, first things first. how/which do i need to install ?

which install method should i take ?
1) copy&paste of script of OP to create xml file then install
2) do same things with 1) but for Small Window Manager from link in OP
3) use single line lua script (posted in May, 2017) after connection to download mpackage file ?

then, what triggers do i need to add ?
from what i have read posts, i can understand 3 of these are necessary.
1) Exits
2) Room Name
3) Prompt (i don't get why it needed. its irrelevant to room. and i want to hide it. cuz there is already nice graphical plugin to change each part of prompt into static gauge.)

and what about room's description and objects ?
i don't know if they are needed or not.

i have tried both of install method and made triggers with copying older posts, but still seems to be short on something. (i just added above 3.)
and how about triggers' name ? do i need to set them to be specific ?

anyway, "start mapping <new area name>" command never works for me.

my target is Avatar Mud.
when "look"ed, room description + prompt are shown like this.

[Exits: north east south west]
A marble fountain is here and looking up, you can see a railing along the
second floor to look down upon this floor. Here is the center of the
wayhouse and there is no other spot in the building that raises a person's
spirits as much as here.
(Glowing) Are you lost? Type <look sign>
A round marble fountain gurgles here.
Sol the Healer sits here, ready to aid you to health.
#<-201/201hp 145/145mp 242/323mv 1000 1148tnl-> <-/->

screenshot with some notes is this
avatarmud room desc.jpg
Avatar mud can use 2 prompts at the same time.

Re: Generic Mapping Script

Posted: Wed Aug 29, 2018 4:07 pm
by Jor'Mox
Okay, so this is brilliant, you gave more or less all of the info I could possibly need to help get this going for you. In return, let me answer your questions. First, either of the two installation methods should work fine, though I typically recommend what you have as option 3, as it also creates some example triggers to help smooth things out, especially for the less experienced.

As to what triggers you need, for the most basic of functionality, you need just three, one to capture the room name, one to get the exits, and one for the prompt. As for why there is a prompt trigger when it has, as you rightly point out, no relation to mapping, it is simply a reliable indicator of being done getting data from the room. Pointedly though, you can still make this work even if you are hiding the prompt, since the text still comes in, so you can simply add the extra bit of code into whatever trigger you have that you are using to transform the data from the prompt into gauges as you mentioned doing. Realistically, you could also use some other indicator as well, it just so happens that the prompt works reasonably for most games.

You may also want some extra triggers in place to catch when you try to go a direction that you cannot (for example you just accidentally put in a direction where there is no exit, or you try to go through an exit with a closed door, for example), as this will help reduce errors and frustration while creating the map. There are a couple of other triggers that are helpful for so called quality of life purposes, but none are critical for getting started.

When I first was developing this script, I did have it capture room descriptions and use them to help further identify the room, but I ultimately decided to cut that out for two reasons. First because many games have a "brief" mode, in which rooms are shown only as room name and exits, with no description, which would make a room not match up when viewed in brief vs normal mode, because the description would be different. And secondly because some games have rooms in which the description changes, so that even though it is the same room, and you are seeing the description, it may have different text at night vs during the day, for example, which again raises an issue because the room won't be able to be recognized by the script. This applies doubly so to items or creatures in the rooms, as those are changeable in essentially all games, and there is not necessarily any rhyme or reason for those changes (programmatically speaking of course, as the most likely reason is that a creature was killed or moved, or a person picked up or dropped an item).

Trigger names are totally unimportant as far as the script is concerned, but in order for the "start mapping" command to be functional, four things need to happen first. One, something needs to be stored in (this should be the room name). Two, something needs to be stored in map.prompt.exits (this should be the actual exits, in the case of your example, it should be "north east south west"). Three, the onNewRoom event needs to be raised. And four, the onPrompt event needs to be raised. Every time you see a room, those four things need to happen, and the mapper will work. So, since it isn't working for you, that means that there is a failure in one of those steps.

To double check what is going on with your triggers, I recommend adding some code to the triggers to help you see on the screen what is happening. For example, for your room name trigger, you could do something like this: print( -- this will not only let you know that the trigger is firing, but help you be confident that you are getting the right text stored as the room name. Ask it to print something out at the beginning of each trigger, and you will know if the triggers are working in general, and if you print something at the end of those triggers, you will know that they are executing all of the code within them successfully.

So, do that, and come back with either, "This trigger with this specific pattern or method isn't working, and I can't figure out why", or "all the triggers seem to be working but it still doesn't work". So far, I have never been unable to get this script to work for someone, though some games have been much trickier than others. Fortunately for you, yours looks pretty straight forward.

Re: Generic Mapping Script

Posted: Wed Aug 29, 2018 7:21 pm
by Jor'Mox
Quick comment here, it looks like the package version of this was messed up for some reason, but that has now been fixed. Also, a few less common bugs have also been squashed, as well as the script being adapted to using UTF-8 in place of the string library, so it should now better support non-Latin characters.

Edit: Just as a reminder, if you already installed the package, you need to uninstall it before trying to install it again, otherwise nothing changes.

Re: Generic Mapping Script

Posted: Thu Aug 30, 2018 12:36 am
by Intort
thanks for quick and precise explanation. :)

capturing prompt was to check the end of room's whole expression. i got it.

i will try editing 3 triggers in the way as you suggested.
of course after re-install of new mpackage version.

Re: Generic Mapping Script

Posted: Thu Aug 30, 2018 5:10 pm
by Intort
after hours of trial&errors, i finally got Generic Mapper working... Once.
at the same time, 2 of new problem raised heads
nonetheless, it is a big progress. thanks for many advice. :)

in successful case, 3 basic triggers become like this. (im working on adapting to Avatar MUD)

1) 'Exits' trigger
^\[Exits\: ([\w\s]+)\]$
Code: [show] | [select all] lua
map.prompt.exits = matches[2]
print(map.prompt.exits)  -- additional 'debug' line. can be DELETEd after checking

2) 'Room name' trigger
fg color = dark yellow, bg collor = black (from gui menu)
Code: [show] | [select all] lua
map.prompt.exits = matches[1]
print(map.prompt.exits)   -- additional 'debug' line. can be DELETEd after checking

3) 'Prompt' trigger
Code: [show] | [select all] lua
map.prompt.name_found = false  -- ADDED AFTER checking. to hide 'searching special exits' text.

other than those 3, i added 4th and 'Failed Move Trigger' (pre-made one).

4) 'onVisionFail' trigger
^It is pitch black\.\.\.$
Code: [show] | [select all] lua

unfortunately, i must say such success was temporal.
if i tried same thing on new profile, i get all the same error again. "Start Mapping Error: No room detected!"

i used same 3 basic triggers in 'debug mode' to check if expected output being shown.
the result was... only Prompt trigger seems to fail. but i bet its enough for disturbing generic mapper's work.
it never shows "searching special exits" text again.
tried changing patterns, but no success...
i don't understand why these same triggers worked once, and don't for newly created profile.
it should be on the same condition. :roll: :roll: :roll:

besides, there is one another big problem. (*note*: this is a case that Generic Mapper already working.)
which is what i was afraid in former post... a confliction with other plugins.

when i turned promptbar (graphical HP gauge) on again, naturally old in-line prompt disappears. and Generic Mapper stops working.
can't 'start mapping' nor 'start mapping <new area name>'.
and i see old error message again.
while loading existing "map.dat" is automatically done on login if i put it in the root folder of profile.

i guess promptbar keeps holding prompt's data. cuz it needs to monitor them.
so that there is no chance for Generic Mapper to get prompt's info.

i have tried changing trigger's order(position) in gui menu to change their priority, but no success yet.

the plugin consists of 2 part. trigger and script.

--trigger of promptbar
^(.*)<-(\d+)/(\d+)hp (\d+)/(\d+)mp (\d+)/(\d+)mv (-?)(\d+) (\d+)tnl-> <(.+)/(.+)>
Code: [show] | [select all] lua
PromptBar.setALIGN(matches[9], matches[10])
the last line seems to be working as kill-switch once all necessary datas get processed.

is there any possible way for both to co-exist ?
preferably in the way of only gauge to be shown. (original re-appearing prompt hurts my eyes.)

next is script. btw, i have changed 'PromptBar.startY' from original correlation equotion to fixed '882' value to fit in my window size.

--script of promptbar
Code: [show] | [select all] lua
PromptBar = PromptBar or {}
PromptBar.width = 700
PromptBar.height = 30
PromptBar.buffer = 5
PromptBar.gaugeWidth = 95
mainWidth, mainHeight = getMainWindowSize()
PromptBar.startX = 2
PromptBar.startY = 882

-- default label creation
createGauge("HP", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + PromptBar.buffer, PromptBar.startY, nil, 255, 0, 0)
createGauge("MP", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + 2 * PromptBar.buffer + PromptBar.gaugeWidth, PromptBar.startY, nil, 0, 255, 0)
createGauge("MV", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + 3 * PromptBar.buffer + 2 * PromptBar.gaugeWidth, PromptBar.startY, nil, 255, 255, 0)
createGauge("ALIGN", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + 4 * PromptBar.buffer + 3 * PromptBar.gaugeWidth, PromptBar.startY, nil, 255, 0, 255)
createGauge("TNL", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + 5 * PromptBar.buffer + 4 * PromptBar.gaugeWidth, PromptBar.startY, nil, 0, 0, 255)
createGauge("MONITOR", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + 6 * PromptBar.buffer + 5 * PromptBar.gaugeWidth, PromptBar.startY, nil, 0, 255, 255)
createGauge("STATUS", PromptBar.gaugeWidth, PromptBar.height, PromptBar.startX + 7 * PromptBar.buffer + 6 * PromptBar.gaugeWidth, PromptBar.startY, nil, 128, 128, 128)

function PromptBar.setStatus(status)
	length = string.len(status)
	if length > 9 then
		length = 0
	setGauge("STATUS", length, 9, status)

function PromptBar.setHP(current, max)
	setGauge("HP", current, max, current .. " / " .. max)

function PromptBar.setMP(current, max)
	setGauge("MP", current, max, current .. " / " .. max)

function PromptBar.setMV(current, max)
	setGauge("MV", current, max, current .. " / " .. max)

function PromptBar.setALIGN(sign, align)
	setGauge("ALIGN", align, 1000, sign .. align)

function PromptBar.setTNL(current, max)
	current = max - current
	setGauge("TNL", current, max, current .. " / " .. max)

function PromptBar.setMONITOR(current, max)
	if current == "-" then
		setGauge("MONITOR",0,1,nil) else
		setGauge("MONITOR", current, max, current .. " / " .. max)

--align and tnl and monitor will be tricky as will displaying the rest of the status

Re: Generic Mapping Script

Posted: Thu Aug 30, 2018 5:18 pm
by Jor'Mox
Okay, so first the code you have for the room name trigger is dealing with the exits, not the room name, so clearly something isn't right there. I would have it with code like the following:
Code: [show] | [select all] lua
if matches[1] == line then = matches[1]
And since you have two prompt triggers that are conflicting, the easiest solution is to just add the raiseEvent("onPrompt") line to the one for the promptbar, and delete the entire prompt trigger that was created for the mapper script.

Edit: I logged into Avatar MUD, used the trigger setup you had, with the changed code I recommended, and it worked for me, though I didn't add in the promptbar script.

Re: Generic Mapping Script

Posted: Thu Aug 30, 2018 7:26 pm
by Intort
i started again with creating new profile from scratch.
short version:
after checking and following your instruction... it worked !! thanks !!! woohoo !!!!

long version:(THIS IS NOT SCRIPT)
Code: [show] | [select all] lua
--i changed 'room' trigger's script as your instruction and debug line as well into 'print('.

--echoes of 'room name' and 'exits' are shown properly, but not for 'prompt' at first.
--i could make first area and input "start mapping" again to fire up auto-mapping.
--prompt trigger started to show 'new room found' text along with my move. (why the text changed from 'searching special exit' is mystery but i bet which is from the change of room trigger.)
--saving and loading of map.dat are quite smooth as well.
--seems things are sorted out at last.
so, my mistake was not in prompt's but in room's after all, which i overlooked so easily. my bad....
thank you again for your pinpointing answer.

(exhaling deeply) i can sleep in peace now...
i will check conflict issue of promptbar tomorrow.

Re: Generic Mapping Script

Posted: Fri Aug 31, 2018 8:15 am
by Intort
i could merge promptbar's trigger into promp's. after merging i deleted original promptbar's trigger. seems fine now.
thanks again for suggesting easiest way :)

modified prompt trigger
^(.*)<-(\d+)/(\d+)hp (\d+)/(\d+)mp (\d+)/(\d+)mv (-?)(\d+) (\d+)tnl-> <(.+)/(.+)>
Code: [show] | [select all] lua
PromptBar.setALIGN(matches[9], matches[10])

and here is updated Exit trigger's pattern.
as there were some serious cases which 'direction->closed' expression screwed up auto-mapper. (script is unchanged.)

Exit trigger
^\[Exits\: ([\w\s\-\>closed]+)\]$

i added Random/follow trigger. but it isn't tested since i made this trigger after finding such case.

Random/Follow move trigger
^You now follow (.*)\.$
Code: [show] | [select all] lua

so far, it have set 6 triggers for Generic Mapper.
Room Name
Failed Move
Non-Visible Move
Random/Follow Move

eventually i should come across 'onForcedMove' event.
but i don't know how/when it comes for now.