Map gui?
by Nathan Cox · in General Discussion · 01/12/2009 (10:35 am) · 5 replies
How would I make a map gui? That shows the location of the player?
About the author
#2
01/12/2009 (11:38 am)
The radar and/or commander map resources would be what you're looking for.
#3
03/07/2009 (4:30 am)
ok, i made a script that will show a map. Why won't it move vertically? I've tried everything but the map only moves horizontally to my position not vertically. It's been bugging me for ages.//Map
//By DarkSilence
//--- OBJECT WRITE BEGIN ---
new GuiControl(MapParch) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 2";
visible = "1";
new GuiWindowCtrl() {
profile = "GuiWindowProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "129 38";
extent = "438 438";
minExtent = "8 2";
visible = "1";
maxLength = "255";
resizeWidth = "1";
resizeHeight = "1";
canMove = "1";
canClose = "1";
canMinimize = "1";
canMaximize = "1";
minSize = "50 50";
new GuiBitmapCtrl(mapPic) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "-200 -550";
extent = "1039 938";
minExtent = "8 2";
visible = "1";
bitmap = "./aotmap.png";
wrap = "0";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "215 170";
extent = "8 9";
minExtent = "8 2";
visible = "1";
text = "V";
groupNum = "-1";
buttonType = "PushButton";
};
};
};
//--- OBJECT WRITE END ---
function openMap()
{
commandtoserver('dropCameraAtPlayer');
onchatmessage("Loading map...");
schedule(500, 0, "refresh", "");
}
function openGui()
{
canvas.pushDialog("mapparch");
}
function closeMap()
{
canvas.popDialog("mapparch");
}
function refresh()
{
%camera = serverconnection.getcontrolobject();
%pos = %camera.getPosition();
XPos(%pos);
YPos(%pos);
mapPic.position = ""@$finposx@" "@$finposy2@"";
schedule(200, 0, "openGui", "");
onchatmessage("Map loaded successfully!");
}
function XPos(%pos)
{
$posx = getWord(%pos, 0);
$posx2 = "-"@$posx / 2.7@"";
$deposx = "-200";
$finposx = $posx2 + $deposx;
}
function YPos()
{
$posy = getWord(%pos, 1);
$posy2 = "-"@$posy / 2.7@"";
$deposy = "-550";
$finposy = $posy2 + $deposy;
$finposy2 = strreplace($finposy," ","");
}
package mapPackage
{
function BrickSelectorDlg::onWake(%this)
{
Parent::onWake(%this);
for(%i=0;%i<$numClientInvSlots;%i++)
{
if($clientinv[%i] $= MapItem)
return;
}
createMapItem();
$numClientInvSlots++;
$numClientInvSlots--;
$clientInv[$numClientInvSlots] = MapItem;
$numClientInvSlots++;
BSD_LoadBricks();
}
function BSD_Use()
{
%item = $clientinv[$bsd_currclickindex];
if(%item.getName() $= "MapItem")
openMap();
else
Parent::BSD_Use();
}
};
activatePackage(MapPackage);
if(!isObject(MapData))
{
new ItemData(MapData)
{
catName = "Items";
subCatName = "Quest Items";
mat1name = "metat1";
mat2name = "wood1";
shapefile = "base/data/shapes/player/parchment.dts";
};
}
function createMapItem()
{
if(isObject(MapItem))
return;
new ScriptObject(MapItem)
{
class = ClientInventorySO;
name = "Map";
mat1 = 4;
mat2 = 2;
dyecolor = "255 255 200";
baseid = MapData;
};
}
moveMap.bindCmd(keyboard,"m","","openMap();");
moveMap.bindCmd(keyboard,"ctrl m","","closeMap();");
#4
Thanks!
Tony
06/23/2009 (11:38 am)
Hey Nate, did you ever get this working the way you wanted it to? If so, could you post it as a resource?Thanks!
Tony
#5
I did see a simple error for the Ypos fix. Notice the difference in function XPos(%pos) and function YPos(). Missing the value to send. I noticed that when I printed out the values using. messageAll('MsgClientKilled','X= %1 , Y= %2', $posx, $posy);
I also noticed mine is not refreshing. Only when I push the 'm' key again will it refresh. Working on it. I see what you mean about the map not actually moving in the Y position.
-------------------------------------------------------
few added things to make refresh work:
in function openMap()
$mapMode = true;
in function closeMap()
$mapMode = false;
in function refresh()
{
if($MapMode) <-- add
{
%camera = serverconnection.getcontrolobject();
%pos = %camera.getPosition();
XPos(%pos);
YPos(%pos);
messageAll('MsgClientKilled','X= %1 , Y= %2', $finposx, $finposy2);
mapPic.position = ""@$finposx@" "@$finposy2@"";
schedule(200, 0, openGui);
schedule(500, 0, refresh); <-- add
onchatmessage("Map loaded successfully!");
}
}
---------------------------------------------------------------
Using:
%PicPos = mapPic.position;
messageAll('MsgClientKilled','pic pos %1 ', %PicPos);
I saw that the value for mapPic.position does not move on the map with the change on the Y.
I noticed that $finposy and $finposy2 are the same value. Looks like they auto remove spaces.
messageAll('MsgClientKilled','picPos= %1, and %2, $finposy, $finposy2);
Playing around with it in game, I saw the Y position change, but only when the xpos value was at -200.
12/17/2010 (12:59 pm)
Thanks, been looking for something like this.I did see a simple error for the Ypos fix. Notice the difference in function XPos(%pos) and function YPos(). Missing the value to send. I noticed that when I printed out the values using. messageAll('MsgClientKilled','X= %1 , Y= %2', $posx, $posy);
I also noticed mine is not refreshing. Only when I push the 'm' key again will it refresh. Working on it. I see what you mean about the map not actually moving in the Y position.
-------------------------------------------------------
few added things to make refresh work:
in function openMap()
$mapMode = true;
in function closeMap()
$mapMode = false;
in function refresh()
{
if($MapMode) <-- add
{
%camera = serverconnection.getcontrolobject();
%pos = %camera.getPosition();
XPos(%pos);
YPos(%pos);
messageAll('MsgClientKilled','X= %1 , Y= %2', $finposx, $finposy2);
mapPic.position = ""@$finposx@" "@$finposy2@"";
schedule(200, 0, openGui);
schedule(500, 0, refresh); <-- add
onchatmessage("Map loaded successfully!");
}
}
---------------------------------------------------------------
Using:
%PicPos = mapPic.position;
messageAll('MsgClientKilled','pic pos %1 ', %PicPos);
I saw that the value for mapPic.position does not move on the map with the change on the Y.
I noticed that $finposy and $finposy2 are the same value. Looks like they auto remove spaces.
messageAll('MsgClientKilled','picPos= %1, and %2, $finposy, $finposy2);
Playing around with it in game, I saw the Y position change, but only when the xpos value was at -200.
Torque 3D Owner Edward
Speaking of which did you ever finish that portal gun? Id love to see a script only portal gun.