Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-18-2011, 11:53 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
keydown checks on two keys at once

PHP Code:
if (keydown(0) && keydown(1)) {
            
player.1;
            
player.1;
          } 
This isn't working, but I need to know if there is a way to check if, say you had pressed up, and was holding it, then pressed right, and do something with that combination. This is during a freezeplayer too.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 12-18-2011 at 11:54 PM.. Reason: Additional info
Reply With Quote
  #2  
Old 12-19-2011, 12:06 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by sssssssssss View Post
PHP Code:
if (keydown(0) && keydown(1)) {
            
player.1;
            
player.1;
          } 
This isn't working, but I need to know if there is a way to check if, say you had pressed up, and was holding it, then pressed right, and do something with that combination. This is during a freezeplayer too.
Well, this code is a no-op and will likely be removed by dead code elimination, you probably mean, e.g.,
PHP Code:
player.+= 
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #3  
Old 12-19-2011, 12:07 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Yeah I had that and tried with just a + just for kicks in hopes. I didn't try while instead of if, ill see if that works.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #4  
Old 12-19-2011, 12:24 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
PHP Code:
while (keydown(0)) {
            if (
keydown(1)) {
              
player.+= .1;
              
player.-= .1;
            }
          } 
using this is also getting nowhere. It just stops what it was doing before most of the time, and on the rare occasion that it does work it pushes the player heavily around the gmap. I tried using something like .0001 as well, and the closest thing was .001 but it still pushed me a good 15 tiles. Seems like its doing some kind of opposite direction as well. :/ I'm stuck, probably something stupid and simple as usual too that I'm just not seeing. My logic is out of whack lately.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #5  
Old 12-19-2011, 12:29 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
It stops working because it hits the 'loop limit'. Your code was essentially doing:

PHP Code:
while (true) {
  if (
keydown(1)) stuff();

You would have to use a sleep in the while loop if you want there to be a chance for your keydown condition to change.

You may be right about your logic being out of whack because you probably don't even need to use the conditions that you're specifying. Try this code out:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
disabledefmovement();
  
setTimer(0.05);
}

function 
onTimeout() {
  if (
keydown(0)) player.-= 0.1;
  if (
keydown(1)) player.-= 0.1;
  if (
keydown(2)) player.+= 0.1;
  if (
keydown(3)) player.+= 0.1;
  
setTimer(0.05);

__________________
Quote:
Reply With Quote
  #6  
Old 12-19-2011, 12:37 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Yep that did it. Can't believe I didn't try that. -_-

Happens every time I stop making website and using C. Not going to stop anymore lol.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:06 PM.


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