Hello!
well i want my label to show "walk to X direction" when the walk to button is clicked . i know it has to be somewhere in the forum but i just can't find it, i tried really hard to find it but nothing appears.
please help .
Thanks! :smiley:
You could have something like this in Global.asc
Normal Walk is not blocked..
function repeatedly_execute()
{
LWalk.Text=String.Format("Walk to %d, %d",player.x, player.y);
}
You could use mouse.x,mouse.y and that will change x y to the position of the mouse..
Others may have better ways..
Quote from: santitassara on Thu 25/06/2020 01:22:04
i want my label to show "walk to X direction" when the walk to button is clicked .
Slashers example shows the player coordinates constantly while walking, I think he misunderstood your question.
I think your looking for something like this:
in this example, the gui has a textlabel called L_WTD.
Now, in your Global script edit the existing eMouseLeft part of the
function on_mouse_click(MouseButton button) function.
Make it like this:
function on_mouse_click(MouseButton button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused())
{
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (button == eMouseLeft)
{
if (mouse.Mode==eModeWalkTo)
{
String wtt = String.Format ("walk to %d, %d direction", mouse.x, mouse.y);
WTx = mouse.x;
WTy = mouse.y;
L_WTD.Text = wtt;
}
}
...
}
Optionally, to clear the label text once the player has reached the clicked coordinates, add this line in the rep. execute in your global script
function repeatedly_execute() {
if ((player.x == WTx) && (player.y == WTy)) L_WTDo.Text = "";
...
}
:
Finally, on top of your global script add:
// main global script file
int WTx;
int WTy;
I wonder if "X direction" mean coordinates, actual mathematical direction (vector), words like LEFT, RIGHT,etc or just hotspot name, like "Walk to Table"?
Quote from: Crimson Wizard on Thu 25/06/2020 11:43:30
I wonder if "X direction" mean coordinates, actual mathematical direction (vector), words like LEFT, RIGHT,etc or just hotspot name, like "Walk to Table"?
mmhh... could be indeed. I assumed it was about coordinates. if it isn't about them, my example is also misunderstood ;)
I think X is the object/hotspot name clicked.
thank you all for answering.
when i said "walk to X" i meaned "walk to table" , "walk to livingroom" or "walk to park" like a hotspot or a region also an item .
my mistake not knowing it could be missunderstood .
still don't know how to do it , i'm new at this and it's a bit tricky to me. also i'm doing this on mac so everytime i have to try something it has to be on a virtual machine.
thanks .
I use a Label to capture cursor mode. I call it LMode.
You then need a Label with the text @OVERHOTSPOT@ to get description of hotspot or object.
function repeatedly_execute_always() {
if(mouse.Mode==1){
LMode.Text=String.Format("Look at...");
} if(mouse.Mode==2){
LMode.Text=String.Format("Interact with...");
}if(mouse.Mode==3){
LMode.Text=String.Format("Talk to...");
} if(mouse.Mode==4){
LMode.Text=String.Format("Use %s with...",player.ActiveInventory.Name);
}
}
Line the Labels up so you get like:
Walk to... Table
Interact with... Swing
etc etc
Use slasher's code but insert the name of the active area, like this:
function repeatedly_execute() {
String text = "Verb";
switch (mouse.Mode) {
case eModeWalkto:
text = "Walk to"; break;
case eModeInteract:
text = "Interact with"; break;
case eModeTalkto:
text = "Talk to"; break;
case eModeUseinv:
text = String.Format("Use %s with", player.ActiveInventory.Name);
}
lblAction.Text = String.Format("%s %s", text, Game.GetLocationName(mouse.x, mouse.y));
}