Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Controlling something using GUI buttons (https://forums.graalonline.com/forums/showthread.php?t=134265077)

callimuc 11-21-2011 11:58 PM

Controlling something using GUI buttons
 
Since the iPhone versions are using the GUI buttons for the moving of the player, I was wondering how you could actually move the player by pressing it. Like is there a way to make the client think, that the player pressed a key (keydown()) even when the player just pressed a GUI? And how can it be made if the mouse slides over to the other GUI, that it won´t need to get reclicked?

The only way I was thinking of making it was this:

PHP Code:

//#CLIENTSIDE
function onCreated() {

  const 
PLAYER_SPEED 0.2;
  const 
PLAYER_NORMAL "block.png";
  const 
PLAYER_PRESSED "lightblock.png";

  new 
GuiBitmapButtonCtrl("PadMovement_0") {
    
64;
    
screenheight 128;
    
width height 32;
    
text "  Up";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }

  new 
GuiBitmapButtonCtrl("PadMovement_1") {
    
32;
    
screenheight 96;
    
width height 32;
    
text " Left";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }

  new 
GuiBitmapButtonCtrl("PadMovement_2") {
    
64;
    
screenheight 64;
    
width height 32;
    
text "Down";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }

  new 
GuiBitmapButtonCtrl("PadMovement_3") {
    
96;
    
screenheight 96;
    
width height 32;
    
text "Right";
    
normalbitmap mouseoverbitmap PLAYER_NORMAL;
    
pressedbitmap PLAYER_PRESSED;
  }
}

function 
PadMovement_0.onAction() {
  
player.dir 0;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;
}

function 
PadMovement_1.onAction() {
  
player.dir 1;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;
}

function 
PadMovement_2.onAction() {
  
player.dir 2;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;
}

function 
PadMovement_3.onAction() {
  
player.dir 3;
  
player.+= vecx(player.dir) * PLAYER_SPEED;
  
player.+= vecy(player.dir) * PLAYER_SPEED;



iBeatz 11-22-2011 12:20 AM

You don't necessarily have to use a button object, you can use a bitmap just the same.
Try out the following events. I think this is what the iPhone servers use for their controls:

PHP Code:

onMouseDown()
onMouseDragged() 


cbk1994 11-22-2011 02:40 PM

There are functions for it but iirc they only work on Login servers (not positive about this, though).

Admins 11-22-2011 05:33 PM

Login-server scripts can emulate key presses for using the classic movement system. We will probably sometime switch to a scripted movement system like on Era though. On Era iPhone it's moving the player durectly, using onwall() for collision checks.

About the "moving finger to another control": the movement keys are not buttons, it's a normal GuiControl which is containing a few GuiShowImgCtrl and depending on the position inside the control (onMouseDragged) the zoom of the GuiShowImgCtrls changed.

Emera 11-22-2011 06:58 PM

Since he is testing this with a custom movement system, could he create some custom functions and then script the GUI around them?

callimuc 11-22-2011 10:43 PM

Hmm messed around on the movement, changed some stuff and came to this problem (it actually worked before I was changing some stuff).

PHP Code:

function onSetMultiTouchPadGUIs() {
  new 
GuiControl("PadMovement_0") {
    
useownprofile true;
    
width height 32;
    
profile.border 2;
    
64;
    
screenheight 128;
  }

  new 
GuiControl("PadMovement_1") {
    
useownprofile true;
    
width height 32;
    
profile.border 2;
    
32;
    
screenheight 96;
  }

  new 
GuiControl("PadMovement_2") {
    
useownprofile true;
    
width height 32;
    
profile.border 2;
    
64;
    
screenheight 64;
  }

  new 
GuiControl("PadMovement_3") {
    
useownprofile true;
    
width height 32;
    
profile.border 2;
    
96;
    
screenheight 96;
  }
  
thiso.catchevent(this"onMouseDown""onMouseDragged");
}

function 
onMouseDragged(keymodexy) {
  
player.chat x SPC y;



DustyPorViva 11-22-2011 10:58 PM

I wish I had an iPod because I have an idea for an awesome touchscreen control scheme that would beat the hell out of these ****ty d-pads emulators.

callimuc 11-22-2011 11:11 PM

Quote:

Originally Posted by DustyPorViva (Post 1675071)
I wish I had an iPod because I have an idea for an awesome touchscreen control scheme that would beat the hell out of these ****ty d-pads emulators.

Open another thread to collect money and in turn you will make graphics again :P
Also what kind would it be? I pretty much like this one

DustyPorViva 11-22-2011 11:20 PM

Quote:

Originally Posted by callimuc (Post 1675074)
Open another thread to collect money and in turn you will make graphics again :P
Also what kind would it be? I pretty much like this one

Not even close. :)

Gunderak 11-23-2011 06:07 AM

But how would you test it on an iDevice even if you had one?

DustyPorViva 11-23-2011 07:10 AM

Quote:

Originally Posted by Gunderak (Post 1675135)
But how would you test it on an iDevice even if you had one?

I'm sure I could weasel my way onto a dev server or something.

callimuc 11-23-2011 06:52 PM

Quote:

Originally Posted by Gunderak (Post 1675135)
But how would you test it on an iDevice even if you had one?

Hmm well I think I have seen somewhere in a post, that graal detects the taping with the onMouseDown() and such stuff. But I´m not 100% sure if this is true.

0PiX0 11-23-2011 09:46 PM

Quote:

Originally Posted by callimuc (Post 1675184)
Hmm well I think I have seen somewhere in a post, that graal detects the taping with the onMouseDown() and such stuff. But I´m not 100% sure if this is true.

It's true.

Gunderak 11-23-2011 11:12 PM

Yes but I was talking about how would he get on a non iPhone server..
I would love to know if there is any possible way to.
I mean being able to test scripts on iDevices would be alot of fun.


All times are GMT +2. The time now is 09:02 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.