New Era in Map-Making!

Room-to-image javascript code are thanks to KV and mrangel.

http://textadventures.co.uk/games/view/mctudqh-00mot77wz2zigg/map-rpg-demo

Please be sure to DOWNLOAD the demo instead of playing it online in order to make it work!


Really nice! But there seems to be some wrong exits. When I go west, the map sometimes moves nw, then sw and so on


I got the same thing, Pertex.


Due to the hexagonal layout, west (and east) movement has to snake its way west instead of moving in a straight line. So you're supposed to go nw once, then sw twice, then nw twice, sw twice, etc. etc. That way you are headed west on the average. I guess if I showed the borders for each room, it would be more obvious.


OK, but why do you use a hexagonal layout? The problem is, that when moving west it shows white blocks under the grafic tiles:
https://imgur.com/a/OQY5p


It should work properly if you download and run the demo instead of playing it online.


I am using the offline version!


I'm not sure what the problem is. I just downloaded and opened it, and downloaded, saved, and opened it, and it works both ways for me.


You are working with the latest version of quest?


Yes


Using the desktop version (5.7.2, the latest release) on Windows 10, I see the a small, white rectangle at the bottom of one of the placeholder images.



Online, I see the white squares of which Pertex speaks.


Then, moving towards the white square fills it in:


I see this error message in the console online:

ReferenceError: addToMap is not defined[Learn More] Play.aspx:1:1
	onload http://play2.textadventures.co.uk/Play.aspx:1:1


Stockfreeimages?
I'm guessing the issue could be something to do with them checking referrers to prevent people hotlinking images without buying them.

Does it work if the images are non-stock images hosted somewhere you control?


@KV
The "little" white rectangle is not a bug, that's just part of the free image I used (that's what it actually looks like). You could use any image and it would look different.

As for the online play (that Pertex sees), I could not get that to work right which is why you see the larger half-white rectangles. That is why you have to download the demo and bypass the web player. The demo uses double attributes for some of the map coordinates, but the web player doesn't recognize those (hence the half-white rectangles). The offline player does recognize double attributes and so works properly.


not a bug, that's just part of the free image I used (that's what it actually looks like).

Yeah, I know. I had an image of that image posted underneath the first image to show that, but it isn't displaying in the post.

(Sometimes things look right in the preview of a post, but not in the actual post.)


...and now I see why the doubles matter.

(I thought you were just observing how it printed the room names! (I am slow sometimes.))


You are anything but slow, KV. My explanations are probably too terse!

I should use your HTML trick to get people to download instead of play online, but that would take me another day of learning : )


Pertex said he was using the desktop player, and he isn't in the US or the UK (I don't think). So, when he uses Quest on his PC, it may behave differently than ours.

(He's never led me astray. In fact, he's saved me from making quite a few errors!)


I wish I was good with things concerning mapping the game world...

I searched and searched for people having problems with doubles when playing online, but I came up empty-handed.

You may be able to use replace() to make it work online or offline somehow...

Or...

In JS, you can check if you're playing online like this:
if (webPlayer)

That may come in handy somehow...

You could set up a Quest function in the game:

<function name="SetQuestPlayer" params"bool">
  game.webplayer = bool
</function>

Then, you could use an ASLEvent to pass the value to Quest from JS. (NOTE: This will cause a turn to finish.)

In your start script:

SetTimeout(2){
  JS.eval("function setQuestPlayer(){  ASLEvent('SetQuestPlayer',webPlayer);};setQuestPlayer();")
}

From there, you could check from within Quest:

if(game.webplayer){
  //do stuff
}
else{
  //do different stuff
}

I did that experiment for the online demo where I created an attribute with a double value and then printed that value every turn. The period always prints as a comma (online only). So I figured that if I can't get the web player to do such a simple operation right, using doubles online is probably not going to work.

As a workaround, I can do away with double attributes altogether and instead double the numerical value of each unit (integer value) that the player moves in one turn; i.e., if you move north 1 space, the y coordinate will change by 2 units. If you move northwest 1 space, the x coordinate will change by 2 units, and the y coordinate by 1 unit (instead of .5 units). This was not ideal though, since if you move north one space, the room name will change from "area500_500_0" to "area500_498_0". I wanted a more intuitive feel for the map movement.

As I write this, I realize I could halve the units moved and then add that to the new room alias so it will display properly to the player. This would entail a two-tiered coordinate system -- a coordinate system that Quest uses based on integers that uses the room name, and one that the player sees based on doubles that uses room aliases. This is doable but might create complications down the line. Anyway, I'm too tired to fool around with this anymore! I can provide the code and someone else might want to make improvements...


Actually, I don't think my workaround will work because when Quest draws the map, each room will be 2 spaces away instead of 1 space. Then would I just have to make each room twice as long and wide?


Where is DL when we need him?

Help us, DarkLizerd!!! You're our only hope! (Unless someone else has a solution. Hehehe.)


When I have time, I will recode this and get it working with integers only...


Just for kicks, here's a small script to experiment with:

stringVar = "1.5"
msg ("stringVar:")
msg (stringVar)
JS.alert (stringVar)
doubleVar = 1.5
dblString = "this is " + doubleVar + "."
msg ("doubleVar:")
msg (doubleVar)
JS.alert (doubleVar)
msg ("dblString:")
msg (dblString)
JS.alert (dblString)
msg ("Alert displaying toString(doubleVar)")
JS.alert (toString(doubleVar))
msg ("Alert displaying doubleVar added to a string.")
JS.alert ("This is the alert version: "+doubleVar)
msg ("Here comes the addTextAndScroll(doubleVar):")
JS.addTextAndScroll (doubleVar)
JS.addTextAndScroll ("<br/>This is the addTextAndScroll version added to a string: "+doubleVar)

Watch what prints via msg() while each alert pops up to (sort of) see what's going on.

The doubles are still doubles, the . is just displayed as , in a msg.


Hrmm...

Try this in place of your MovePlayer() script :

(Revision 2)

game.NewAreaStringName = "area" + player.x + "_" + ToString(player.y) + "_" + player.z
// If entered area already exists, then move player there; else, create the new area and its exits and move player there.
if (GetObject(game.NewAreaStringName) <> null) {
  MoveObject (player, GetObject(game.NewAreaStringName))
}
else {
  // CREATE NEW AREA -
  // If "Type" (directly below) is set to "Editor_Room", movement errors will be generated, but only when playing online.
  create (game.NewAreaStringName, "defaultobject")
  game.NewArea = GetObject(game.NewAreaStringName)
  game.NewArea.alias = game.NewAreaStringName
  game.NewArea.parent = THE WORLD
  game.NewArea.grid_render = True
  game.NewArea.grid_borderwidth = 0
  TerrainGenerator
  // CREATE EXITS -
  create exit (game.NewArea + "N", "north", game.NewArea, THE WORLD, "northdirection")
  create exit (game.NewArea + "NE", "northeast", game.NewArea, THE WORLD, "northeastdirection")
  create exit (game.NewArea + "E", "east", game.NewArea, THE WORLD, "eastdirection")
  create exit (game.NewArea + "SE", "southeast", game.NewArea, THE WORLD, "southeastdirection")
  create exit (game.NewArea + "S", "south", game.NewArea, THE WORLD, "southdirection")
  create exit (game.NewArea + "SW", "southwest", game.NewArea, THE WORLD, "southwestdirection")
  create exit (game.NewArea + "W", "west", game.NewArea, THE WORLD, "westdirection")
  create exit (game.NewArea + "NW", "northwest", game.NewArea, THE WORLD, "northwestdirection")
  // If the above exits exit to "area500_500_0" instead, the player is drawn in the wrong location on the map upon starting area re-entry.
  foreach (exit, ScopeExitsForRoom(game.NewArea)) {
    exit.grid_length = 0
  }
  // CONNECT EXITS (if adjacent areas are already present) -
  foreach (exit, ScopeExitsForRoom(game.NewArea)) {
    if (HasAttribute(exit, "northdirection")) {
      game.AdjacentAreaStringName = ToString("area" + player.x + "_" + player.y - 1 + "_" + player.z)
      AdjAreaConnectExits (game.NewArea + "N", southdirection)
    }
    else if (HasAttribute(exit, "northeastdirection")) {
      game.AdjacentAreaStringName = ToString("area" + player.x + 1 + "_" + ToString(player.y - .5) + "_" + player.z)
      AdjAreaConnectExits (game.NewArea + "NE", southwestdirection)
    }
    else if (HasAttribute(exit, "southeastdirection")) {
      game.AdjacentAreaStringName = ToString("area" + player.x + 1 + "_" + ToString(player.y + .5) + "_" + player.z)
      AdjAreaConnectExits (game.NewArea + "SE", northwestdirection)
    }
    else if (HasAttribute(exit, "southdirection")) {
      game.AdjacentAreaStringName = ToString("area" + player.x + "_" + player.y + 1 + "_" + player.z)
      AdjAreaConnectExits (game.NewArea + "S", northdirection)
    }
    else if (HasAttribute(exit, "southwestdirection")) {
      game.AdjacentAreaStringName = ToString("area" + player.x - 1 + "_" + ToString(player.y + .5) + "_" + player.z)
      AdjAreaConnectExits (game.NewArea + "SW", northeastdirection)
    }
    else if (HasAttribute(exit, "northwestdirection")) {
      game.AdjacentAreaStringName = ToString("area" + player.x - 1 + "_" + ToString(player.y - .5) + "_" + player.z)
      AdjAreaConnectExits (game.NewArea + "NW", southeastdirection)
    }
  }
  // SET AREA COORDINATES AND MOVE PLAYER -
  Grid_SetGridCoordinateForPlayer (game.pov, game.NewArea, "x", player.x)
  Grid_SetGridCoordinateForPlayer (game.pov, game.NewArea, "y", player.y)
  Grid_SetGridCoordinateForPlayer (game.pov, game.NewArea, "z", player.z)
  game.pov.parent = game.NewArea
  Grid_CalculateMapCoordinates (game.NewArea, game.pov)
}

Everything still works in the desktop version, but I'd have to upload your game to test it online...

I bet it fixes the way the names print out, but nothing else.


It looks to me like this default function is turning each coordinate into a double:

Grid_SetGridCoordinateForPlayer

coordinates = Grid_GetPlayerCoordinatesForRoom(playerobject, room)
if (DictionaryContains(coordinates, coordinate)) {
  dictionary remove (coordinates, coordinate)
}
dictionary add (coordinates, coordinate, value * 1.0)

In fact, all sorts of scripts concerning the grid are using doubles.


In fact, all sorts of scripts concerning the grid are using doubles.

Thanks for playing with it, KV. If that's the case, it's not going to be that easy converting everything to integers. I'm going to leave the demo as it is then. We need the Pixie to edit the web player to accept doubles (that is my solution when all else fails, haha).


Now updated with characters you know from real life!

http://textadventures.co.uk/games/view/mctudqh-00mot77wz2zigg/map-rpg-demo


Ha!

"Git off my lawn!"


I admired Anonynn's flowers, just after having eaten a mushroom from The Pixie's Forest.


Log in to post a reply.

Support

Forums