wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 11-10-2009, 09:51 AM   #1
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default KeyAction

Zoom (requires log in)
Arrow Key Helpers
Version 0.1.0
Introduction
KeyAction is written in vJass and requires the NewGen editor, or Jass Helper in some other configuration. KeyAction requires the latest version of Jass Helper.

KeyAction is a library that provides a simpler, cleaner API for dealing with arrow key related events. Documentation of the API is available in the library's documentation header.
Credits
The KeyAction Library
Requirements:
  • None

To add KeyAction to your map, copy and paste the below library in to a custom-text trigger in your map.
Expand KeyAction:

Change Log

Change Log

  • 0.1:
    • Initial version

Earth-Fury is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 11-10-2009, 10:54 AM   #2
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Yes very nice,... But I guess there is nothing that removes the delay of arrow keys or?

Anyway, I see very much use in this. For an hero arrow selection system, for example.

Still don't get why you use a trigger per arrow and for every arrowstate, instead sharing one and checking the gameevent.

Collapse JASS:
function eventHandler takes nothing returns nothing
    if EVENT_PLAYER_ARROW_DOWN_UP == GetTriggerEventId() then
           //Arrow_up_stuff
    endif
endfunction
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 11-10-2009, 11:16 AM   #3
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default

Quote:
Originally Posted by Anachron
Yes very nice,... But I guess there is nothing that removes the delay of arrow keys or?

Using a program like DelayReducer to reduce Battle.net lag will help on battle.net. There is still, however, an intrinsic delay in arrow keys registering events for some unknown reason.

Quote:
Originally Posted by Anachron
Still don't get why you use a trigger per arrow and for every arrowstate, instead sharing one and checking the gameevent.

Collapse JASS:
function eventHandler takes nothing returns nothing
    if EVENT_PLAYER_ARROW_DOWN_UP == GetTriggerEventId() then
           //Arrow_up_stuff
    endif
endfunction
That would add the cost of an 8 branch logical structure to all arrow key events... But more seriously, who gives a flying fuck considering both methods are nigh exactly the same?
__________________
Useful Links:
My Resources:
Good Resources:
Search
Tutorials
Ability Guide

UnitMaxState
BonusMod

AutoIndex
ARGB
TimerUtils

Earth-Fury is offline   Reply With Quote
Old 11-10-2009, 11:26 AM   #4
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Quote:
That would add the cost of an 8 branch logical structure to all arrow key events... But more seriously, who gives a flying fuck considering both methods are nigh exactly the same?
So what about it? If possible I would like to have the possibility to disable the systems by not adding the event-handler.

But it doesn't matter at all. Its good, and since I have my own bnet I don't have any delay.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 11-10-2009, 01:09 PM   #5
Mr.Malte
User
 
Mr.Malte's Avatar
 
Join Date: Apr 2008
Posts: 286

Submissions (2)

Mr.Malte is on a distinguished road (11)

Default

Hey, nice.
Made this a while ago:

Collapse JASS:
library ArrowkeyController initializer Init
    globals
        // A problem with the arrow keys are, that they always have some delay.
        // Normally it's 0.25 (it's a constant)
        private constant real ARROW_KEY_REACTION_TIME = 0.25
        // The bigger the smoother the 'back camera movement' but the less
        // the accurarry
        private constant real CAMERA_SMOOTHING = 1.00
    endglobals
    
    globals
        private trigger onArrowKey = CreateTrigger()
        private trigger releaseArrowKey = CreateTrigger()
        private boolean array Allowed
        private boolean array IsLocked
        private real array CamX
        private real array CamY
    endglobals
    
    private function unlockCamera takes nothing returns nothing
        local integer ID = GetPlayerId(GetTriggerPlayer())
        local real x
        local real y
        if Allowed[ID] then
            if GetLocalPlayer() == GetTriggerPlayer() then
                call PanCameraToTimed(CamX[ID], CamY[ID], 0.5)
            endif
            set IsLocked[ID] = false
        endif
    endfunction
    
    private function lockCamera takes nothing returns nothing
        local integer ID = GetPlayerId(GetTriggerPlayer())
        local real x
        local real y
        if Allowed[ID] then
            set IsLocked[ID] = true
            if GetLocalPlayer() == GetTriggerPlayer() then
                call PanCameraToTimed(CamX[ID], CamY[ID], ARROW_KEY_REACTION_TIME*CAMERA_SMOOTHING)
            endif
        endif
    endfunction
    
    private function SaveCamCoords takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i == 12
                if IsLocked[i] == false then
                    if GetLocalPlayer() == Player(i) then
                        set CamX[i] = GetCameraTargetPositionX()
                        set CamY[i] = GetCameraTargetPositionY()
                    endif
                endif
            set i = i + 1
        endloop
    endfunction
    
    private function Init takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i == 12
                set Allowed[i] = true
                if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
                    call TriggerRegisterPlayerEvent(onArrowKey, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
                    call TriggerRegisterPlayerEvent(onArrowKey, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
                    call TriggerRegisterPlayerEvent(onArrowKey, Player(i), EVENT_PLAYER_ARROW_RIGHT_DOWN)
                    call TriggerRegisterPlayerEvent(onArrowKey, Player(i), EVENT_PLAYER_ARROW_LEFT_DOWN)
                    
                    call TriggerRegisterPlayerEvent(releaseArrowKey, Player(i), EVENT_PLAYER_ARROW_UP_UP)
                    call TriggerRegisterPlayerEvent(releaseArrowKey, Player(i), EVENT_PLAYER_ARROW_DOWN_UP)
                    call TriggerRegisterPlayerEvent(releaseArrowKey, Player(i), EVENT_PLAYER_ARROW_RIGHT_UP)
                    call TriggerRegisterPlayerEvent(releaseArrowKey, Player(i), EVENT_PLAYER_ARROW_LEFT_UP)
                endif
            set i = i + 1
        endloop
        call TriggerAddAction(onArrowKey,function lockCamera)
        call TriggerAddAction(releaseArrowKey,function unlockCamera)
        call TimerStart(CreateTimer(),ARROW_KEY_REACTION_TIME,true,function SaveCamCoords)
    endfunction
    
    public function Allow takes boolean flag returns nothing
        local integer i = 0
        if flag == true then
            call DisableTrigger(onArrowKey)
            call DisableTrigger(releaseArrowKey)
        else
            loop
                exitwhen i == 12
                call PanCameraToTimed(CamX[i], CamY[i], 0.5)
                set i = i + 1
            endloop
            call EnableTrigger(onArrowKey)
            call EnableTrigger(releaseArrowKey)
        endif
    endfunction
    
    public function AllowFor takes player p, boolean flag returns nothing
        set Allowed[GetPlayerId(p)] = flag
    endfunction
endlibrary

You should add sth. like that to your library. Making movement via arrow keys not possible.
But I'm not sure if that fits into a library like that.

Niceldy done.
Mr.Malte is offline   Reply With Quote
Old 11-10-2009, 05:34 PM   #6
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Mr.Malte
You should add sth. like that to your library. Making movement via arrow keys not possible. But I'm not sure if that fits into a library like that.

That's the kind of thing that should require a library like this. It would shorten and simplify the code.
grim001 is offline   Reply With Quote
Old 11-10-2009, 06:23 PM   #7
Tot
6
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

of topic:

how did you create this?

Quote:
Originally Posted by EF
Zoom (requires log in)

It's really cool
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 04-16-2010, 03:56 PM   #8
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,726

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Remind me why I would ever use this over Anitarf's ArrowKeys library in the database, again?
__________________
Home Page
DoE v1.14c Download
AotZ v2.03d Download
OD v0.10x Download

Coming soon eventually...

Personal To-Do List:
ICARUS
Aot3

WC3C Chat
Chat IP: 66.103.20.109
Earthbound 2 in English
vJass Manual

"DAMAGE_TYPE_POISON motherfucker!" ~Anitarf
Rising_Dusk is offline   Reply With Quote
Old 04-19-2010, 05:43 PM   #9
Earth-Fury
Two Blue
 
Earth-Fury's Avatar
 
Join Date: Mar 2003
Posts: 2,179

Submissions (7)

Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)Earth-Fury is just really nice (343)

Send a message via MSN to Earth-Fury
Default

Quote:
Originally Posted by Rising_Dusk
Remind me why I would ever use this over Anitarf's ArrowKeys library in the database, again?

I like my API better.

Also the ability to register multiple callbacks directly to the library. (Limited utility, but useful on rare occasions.)

I don't feel like putting work in to improving this much any time soon, so do as you see fit. Let it rot, approve it, graveyard it. (I can always resubmit it in the future)
__________________
Useful Links:
My Resources:
Good Resources:
Search
Tutorials
Ability Guide

UnitMaxState
BonusMod

AutoIndex
ARGB
TimerUtils

Earth-Fury is offline   Reply With Quote
Old 12-07-2010, 02:41 PM   #10
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,053

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I guess I've spent enough time trying to figure out what to do with this. It is certainly coded with more rigour than ArrowKeys and should probably replace it. However, I don't see anything here that would easily replicate the "quickpress" functionality of ArrowKeys, which is a bit ugly but a very functional hack. On top of that, I suppose some people might prefer a more lightweight library so I guess the two of them can coexist in the resource section, even if that means the number of libraries handling arrow keys will approach the number of people who actually have a use for them.

Approved.
__________________
Anitarf is offline   Reply With Quote
Old 09-26-2011, 11:57 AM   #11
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,053

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I found a couple of bugs in the OnKeyAction module.

Expand Original code:

Expand Fixed code:

Edit: there can also be trouble if struct instances are destroyed in the OnKeyAction callback. Not sure what would be the best way to avoid issues here.
__________________

Last edited by Anitarf : 09-26-2011 at 12:14 PM.
Anitarf is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


All times are GMT. The time now is 09:14 PM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services