Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-21-2011, 11:58 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
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;

__________________
MEEP!

Last edited by callimuc; 11-21-2011 at 11:59 PM.. Reason: typo
Reply With Quote
  #2  
Old 11-22-2011, 12:20 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
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() 
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #3  
Old 11-22-2011, 02:40 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
There are functions for it but iirc they only work on Login servers (not positive about this, though).
__________________

Last edited by cbk1994; 11-22-2011 at 04:14 PM..
Reply With Quote
  #4  
Old 11-22-2011, 05:33 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #5  
Old 11-22-2011, 06:58 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Since he is testing this with a custom movement system, could he create some custom functions and then script the GUI around them?
__________________
Reply With Quote
  #6  
Old 11-22-2011, 10:43 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
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;

__________________
MEEP!
Reply With Quote
  #7  
Old 11-22-2011, 10:58 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #8  
Old 11-22-2011, 11:11 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by DustyPorViva View Post
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
__________________
MEEP!
Reply With Quote
  #9  
Old 11-22-2011, 11:20 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by callimuc View Post
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.
Reply With Quote
  #10  
Old 11-23-2011, 06:07 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
But how would you test it on an iDevice even if you had one?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #11  
Old 11-23-2011, 07:10 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Gunderak View Post
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.
Reply With Quote
  #12  
Old 11-23-2011, 06:52 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Gunderak View Post
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.
__________________
MEEP!
Reply With Quote
  #13  
Old 11-23-2011, 09:46 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Quote:
Originally Posted by callimuc View Post
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.
__________________
Reply With Quote
  #14  
Old 11-23-2011, 11:12 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:19 PM.


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