Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Mapper for Achaea

Mapper for Achaea

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3  4  5  6  7  8 9  10  11  12  13  

Posted by Faedara   (106 posts)  Bio
Date Reply #105 on Fri 26 Nov 2010 09:42 PM (UTC)
Message
Tried that, it worked until I walked into a different area. And the snippet is the code that draws a circle around boundaries between two different areas.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #106 on Fri 26 Nov 2010 09:57 PM (UTC)
Message
OK, try this then:



  -- unknown area?
  if tonumber (ourroom.area) == 0 then
    room.fillcolour = ColourNameToRGB "cornflowerblue"  -- or whatever
  end -- if no area known




Note changed room.area to ourroom.area - ourroom is what we looked up on the database, so that should still have 0 in it.

As for the double exit circles, I think that will go away (maybe annoyingly late) when you explore the areas. Normally you should only see one, but I think the coordinates being missing (on the unexplored rooms) is throwing out the code.

For now you could just disable the showing of area exits, as with the change above you should simply see the unexplored rooms in a different colour.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #107 on Fri 26 Nov 2010 10:41 PM (UTC)
Message
Everything looks great now!

Also, the double circle doesn't seem to ever go away, except when there's multiple area exits in which case one or more circles might not appear ((Though some still do))

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #108 on Sat 27 Nov 2010 05:13 AM (UTC)

Amended on Sat 27 Nov 2010 05:14 AM (UTC) by Faedara

Message
Also, working off Twisol's script for music by areas



if current_area ~= new_area then
  current_area = new_area
  PlaySound (7, current_area".wav", true, -6, 0)
end


But I'm wondering if this would work, and if so where to put it. I don't want to modify something too much if I don't fully understand it.


Also, in case I messed up entirely, it's supposed to check if the room's area is now different than it was before, in which case it will play "area.wav" where area will be the label given to that area. For example, if my current_area is Hashan, then it will play Hashan.wav

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #109 on Sat 27 Nov 2010 05:35 AM (UTC)

Amended on Sat 27 Nov 2010 05:57 AM (UTC) by Nick Gammon

Message
Well in the plugin (not mapper.lua) is the code to handle room changes:


-- here when location changes, eg. : Room.Num 7476
function got_room_number (s)
  
  local room_number = s
    
  if not room_number then
    return
  end -- no room number

  current_room = room_number
  mapper.draw (room_number)
  
  if expected_exit == "0" and from_room then
    fix_up_exit ()
  end -- exit was wrong

end -- got_room_number


So after the line for mapper.draw, we have just drawn a new room (or maybe an existing room, if we just did a "look").

So after that line, let's grab the room info, and work out the area:


local ourroom = rooms [current_room]
if ourroom then
  local area_name = areas [ourroom.area]  -- get area name
  if area_name then
    if current_area ~= area_name then
      current_area = area_name
      PlaySound (7, current_area .. ".wav", true, -6, 0)
    end  -- area change
  end -- area found
end -- room found


I haven't tested it but that is the general idea.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #110 on Sat 27 Nov 2010 05:55 AM (UTC)
Message
Run-time error
Plugin: ATCP_Mapper (called from world: Achaea)
Function/Sub: OnPluginBroadcast called by Plugin ATCP_Mapper
Reason: Executing plugin ATCP_Mapper sub OnPluginBroadcast
[string "Plugin"]:1079: attempt to index global 'room' (a nil value)
stack traceback:
        [string "Plugin"]:1079: in function 'f'
        [string "Plugin"]:1256: in function <[string "Plugin"]:1250>
Error context in script:
1075 :   mapper.draw (room_number)
1076 : 
1077 :   local ourroom = rooms [current_room]
1078 :   if ourroom then
1079*:     local area_name = areas [room.area]  -- get area name
1080 :     if area_name then
1081 :       if current_area ~= area_name then
1082 :         current_area = area_name
1083 :         PlaySound (7, current_area .. ".wav", true, -6, 0)


I'm no expert, but I've returned my fair share of 'nil', it's not getting the table 'room'

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #111 on Sat 27 Nov 2010 05:58 AM (UTC)
Message
ourroom.area

Shows what comes of not testing. I amended the post above.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #112 on Sat 27 Nov 2010 06:02 AM (UTC)
Message
Testing now. Also, have you ever considered adding Midi function to PlaySound? Midi files are much smaller and less processor hungry than Wav

((I know, not the place to ask, but I'm a curious kitty))

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #113 on Sat 27 Nov 2010 08:08 AM (UTC)
Message
Also, I've come up with this:


local ourroom = rooms [current_room]
if ourroom then
  local area_name = areas [ourroom.area]  -- get area name
  if area_name then
    if ourroom.area ~= area_name then
      sound = area_name
      PlaySound (7, sound .. ".wav", true, -6, 0)
    end  -- area change
  end -- area found
end -- room found


Which will actually play sound ((Something with checking if the area has changed in your code isn't working))

So far, if I move around in an area with a music file labeled for that area ((eg. moving around in Hashan with a Hashan.wav in sounds)) it will play every time I move in that area (starting from the beginning) and keep playing continuously if I move into an area without a sound file.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #114 on Sat 27 Nov 2010 08:23 AM (UTC)
Message
From what I can see, it looks like this is testing a truism. It seems like you're testing our current area against the current area's code, which are bound to be different. You need to store the current area somewhere, and whenever you move, compare it to the current room's area. If it's changed (i.e. you passed to another area), update the current area you've stored and play the sound.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #115 on Sat 27 Nov 2010 08:30 AM (UTC)
Message
Twisol said:

From what I can see, it looks like this is testing a truism. It seems like you're testing our current area against the current area's code, which are bound to be different. You need to store the current area somewhere, and whenever you move, compare it to the current room's area. If it's changed (i.e. you passed to another area), update the current area you've stored and play the sound.


I'm pretty sure that's what Nick did, only it wasn't updating anything.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #116 on Sat 27 Nov 2010 10:01 AM (UTC)
Message
You changed it. You have:


 if ourroom.area ~= area_name then
      sound = area_name


Well, you haven't remembered the new area name. Or more accurately, you aren't testing on the remembered name. It needs to be more like:



 if sound ~= area_name then
      sound = area_name  -- now they are the same 


Inside that "if" you need to remember the new area, so you don't keep thinking the area has changed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #117 on Sun 28 Nov 2010 01:17 AM (UTC)
Message
I changed it when yours didn't update =owo=

I'll try it again with that modification when I have time.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #118 on Fri 17 Dec 2010 05:56 PM (UTC)

Amended on Fri 17 Dec 2010 06:01 PM (UTC) by Faedara

Message
I think I broke the mapper... I accidentally put in a number instead of a name for an area when I was trying to add an exit and the database broke down. Now I'm getting this:

Run-time error
Plugin: ATCP_Mapper (called from world: Achaea)
Function/Sub: OnPluginBroadcast called by Plugin ATCP_Mapper
Reason: Executing plugin ATCP_Mapper sub OnPluginBroadcast
[string "Plugin"]:470: bad argument #5 to 'format' (string expected, got nil)
stack traceback:
        [C]: in function 'format'
        [string "Plugin"]:470: in function 'supplied_get_room'
        ...and Settings\Gizmo\Desktop\MUSHclient\lua\mapper.lua:210: in function 'get_room'
        ...and Settings\Gizmo\Desktop\MUSHclient\lua\mapper.lua:923: in function 'draw'
        [string "Plugin"]:1075: in function 'f'
        [string "Plugin"]:1246: in function <[string "Plugin"]:1240>
Error context in script:
 466 :   if tonumber (areaname) then
 467 :     areaname = areas [tonumber (areaname)]
 468 :   end -- convert to name
 469 :     
 470*:   room.hovermessage = string.format (
 471 :       "%s\tExits: %s\nRoom: %s\nArea: %s%s%s%s",
 472 :       room.name, 
 473 :       table.concat (texits, ", "),
 474 :       uid,


Is there any way to fix this without deleting the existing database I've been working on?

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Faedara   (106 posts)  Bio
Date Reply #119 on Fri 17 Dec 2010 06:14 PM (UTC)
Message
Figured it out, I removed:
Area: %s%s%s%s

So that the mapper would show, and then edited the area. Now I'm going to try putting
Area: %s%s%s%s

back into the code.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


501,806 views.

This is page 8, subject is 13 pages long:  [Previous page]  1  2  3  4  5  6  7  8 9  10  11  12  13  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.