1
2
Jun 19 2013, 12:57 pm
|
|
Thats when it started
|
When you say "not moving" do you mean that the icon isn't moving or that your physical mob does not change position?
|
When you are moving and you shoot, the icon goes to its base unmoving state and shoots. However, if you hold space (macro for shoot) you can not move left or right, and it will continue shooting after the delay. If you let go of space than the ship goes back to moving left or right.
|
It has to do with using a macro on repeat. I need to slow the repeat loop down, but I am not sure to access it in the code as the macro was setup from the skin. I read in the dm refrence something about doing.
macro for keyboard macros but that is not working. |
Or how about do a manual repeat. Use a keyboard library that can register keypresses and just shoot as long as you are holding the key down.
|
Ok I have it almost working, but the problem now is that if the player is moving they can not shoot because the spawn will not finish executing for the shoot verb until it can execute again, which is when they stop moving. Is there a way to make the shoot spawn execute still?
|
Are you using a while loop or something for the movement? Maybe recursion with spawn would be the better choice for your movement.
|
I am just using the base Move, I didn't add in a Keyboard lib as they all seemed laggy.
I just set up a movement state in the icon file as I am not sure how to set a movement icon manually. I tried using flick, but it is a quick type of thing. I can get the icon to go to the movement state (if not using a movement state in the .dmi), but I am not sure how to check if the player stopped moving. I guess it could be: dir == NULL but if I remember correctly I tried that, and was unable to get it to work that way as well. |
If I don't use a movement state in the .dmi file it works as I intend it, but if I make a movement state it no longer works properly.
|
You want to check if they are moving or not? Override Move() to set a variable to true before it executes and to false once it is done.
|
Ignore the part about checking for movement. That was something I was going over as an example to try and solve the problem. Let me reiterate the question, and just ignore previous posts regarding that unless I specify otherwise below:
I have a macro, set through the interface/skin that has the repeat box checked, when the player presses & holds space it will continually call mob/player/verb/Shoot() which is describe before. I also have a .dmi file that has a static icon and than a movement state with 1 frame & 4 directions of which I only use the EAST & WEST box as the player can only move EAST or WEST. Under mob/player I have only the static icon set as the player's icon state as if the player is not moving that is the icon that should be displayed. Byond automatically assigns the movement states when the player moves that direction. The problem I have is if I use the movement state than when the player holds space to shoot they can not move, or if they are moving then they can not shoot. Thus, I have concluded that the error is that the Shoot() verb can not interrupt the Move() proc as the repeated macro goes so quickly as to cause it where the return 0 from the Shoot() verbs shooting check is being called so quickly that the player's Move() proc can not begin to move the player once again. Thus, I need a method to make it where the Shoot() verb can interrupt the Move() proc or be called within the MOve() proc, or I need a way to make it where the Move() proc can interrupt the shoot() verb. |
Yet, this only happens if I use a movement state, if I use just a static icon than it works as intended which is why I am curious as to what proc is used for handling movement states.
|
Try this.
mob/verb/Shoot() I'm not entirely sure if this will work, but it's worth a shot. |
verb I am still having this problem when I try to shoot. I stepped back for a bit and am trying to mess with it again now. I removed the movement state, I put a sleep in, a spawn in, etc... I added in when the player moves EAST or WEST if the player shoots than it will make the move proc sleep for 1 tick. However, still no go. What it is doing is as long as I hold the movement key and the space key (which in the interface I have as a repeat macro for the Shoot verb) the player will only when the arrow key is stopped being pressed. Now if you move left or right and press the space key manually it works just fine. Yet, I do not want this. I want the shoot verb to be automatic where as long as you hold space you will keep shooting without much extra input from the player. |
I think I may have figured it out. Could it be because of the:
spawn(5) Seeing as spawn can not finish until it hits a sleep point, so if you hold the space key it just keeps recalling that shoot is TRUE while you are moving because the spawn never hit a sleep point to reset shooting to FALSE? |
Ok I am still having the same thing now, even with making a direct macro:
verb It is like byond does not recognize if there are two macros doing repeat at the same time. Such as when you press and hold the arrow key to move EAST as long as you hold that key it will do that, but then if you keep holding EAST and then press the space bar (with a repeat macro for the shoot verb) BYOND will only repeat the shoot verb and stop moving. Such as if you are shooting and then move it will recognize the move proc until you let go of the arrow key and then it will go back to the shoot verb. Is this because of the lack of multithreading? |
Not lack of multithreading, just a quirk in how DM handles keyboard input.
What you want to do is define a list of keys mob/list/keys = list("a"=0,"b"=0)//etc Then you want to define procs for keyDown and keyUp, and then in your macros, assign macros for when the key is pressed down and then when the key is released, and similarly set the associated key in the keys list to 1 or 0. Then you can simply loop the list of keys for any keys that are held down and do their action, until they become released. |
1
2