• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] Press Spacebar Event

Level 17
Joined
Apr 27, 2008
Messages
2,455
Bribe you have failed, in the current state your AddTriggerCondition function should be named TriggerAddConditionBJ.

I wouldn't say it is worth a library though.
Personaly if i would need to remove a trigger condition i would just use as the first condition a code which handle the triggerconditions removes on next evaluation, without any timer involved because it could theorically fail.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Well, it's lame to say that pjass suck, there was a reason for this.
In the past it descynced with mac users (if i believe what i've read).

It's just not updated, the source is even available, sadly i have just not the knowledge to edit it correctly.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
[…]
pJass is such a n00b.



[…]
pJass sucks :/

Look, i don't really like that kind of comment.
First of all, why not use the native syntax checker. If PJass "sux" you are free to use the native one.

Then there is JassParser by Zoxc, which i multiple linked to already. Afaik he does not check for wrong Filter/Condition usage.

You guys are really funny. Both PJass' and JassParsers sources are available.
Instead of fixing it you bitch around. I checked PJass' source. As far as i can tell, you have to change one (!) function.

And don't get me started about using functions in a way they weren't intended for…
 
It's not my responsibility to update PJass.
That's like Vexorian refusing to fix a bug with TimerUtils and instead asking everyone to fix it themselves by changing a line of code or two.

Also, I don't have the pJass source, and I never knew it was available.

edit
Bah, I couldn't resist.

JASS:
void checkParameters(const struct paramlist *func, const struct paramlist *inp, const int mustretbool)
{
  const struct typeandname *fi = func->head;
  const struct typeandname *pi = inp->head;
  int pnum = 1;
  for (;;) {
    if (fi == NULL && pi == NULL)
      return;
    if (fi == NULL && pi != NULL) {
      yyerrorex(3, "Too many arguments passed to function");
      return;
    }
    if (fi != NULL && pi == NULL) {
      yyerrorex(3, "Not enough arguments passed to function");
      return;
    }
    canconvert(pi->ty, fi->ty, 0);
    if (mustretbool && pi->ty == gCodeReturnsNoBoolean) {
    	yyerrorex(3, "Functions passed to Filter or Condition must return a boolean");
    	return;
    }
    pi = pi->next;
    fi = fi->next;
  }
}

->

JASS:
void checkParameters(const struct paramlist *func, const struct paramlist *inp, const int mustretbool)
{
  const struct typeandname *fi = func->head;
  const struct typeandname *pi = inp->head;
  int pnum = 1;
  for (;;) {
    if (fi == NULL && pi == NULL)
      return;
    if (fi == NULL && pi != NULL) {
      yyerrorex(3, "Too many arguments passed to function");
      return;
    }
    if (fi != NULL && pi == NULL) {
      yyerrorex(3, "Not enough arguments passed to function");
      return;
    }
    canconvert(pi->ty, fi->ty, 0);
    /*if (mustretbool && pi->ty == gCodeReturnsNoBoolean) {
    	yyerrorex(3, "Functions passed to Filter or Condition must return a boolean");
    	return;
    }*/
    pi = pi->next;
    fi = fi->next;
  }
}
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
As far as i can tell, you have to change one (!) function.

Good luck getting users to download yet another thing to make your script work instead of putting the workaround in your script directly.

And don't get me started about using functions in a way they weren't intended for…

Don't get me started on how JASS/vJass has already always been full of hacks...
 
JASS:
    globals
        private integer Local_I //= GetPlayerId(GetLocalPlayer())
        private string Local_S //= I2S(Local_I)
        private real array Space_X
        private real array Space_Y
        private real Sync_X
        private real Sync_Y
        private boolean Not_Sync = true
        private gamecache Cache
        private timer Space_Timer = CreateTimer()
        private player Space_Player
        private trigger Space_Actions = CreateTrigger()
    endglobals

Space_Player, Sync_X and Sync_Y should be initialized to null, 0 and 0 respectively.

Also, if it's possible, could we have the timer period configurable?
(To give beginners the ability to easily modify the system without having to go through all the code and messing something up.)

This is actually very well written. (I don't care if you repeated I2S(i) twice in the loop.)
 
Level 18
Joined
Oct 20, 2007
Messages
353
Space_Player, Sync_X and Sync_Y should be initialized to null, 0 and 0 respectively.

Also, if it's possible, could we have the timer period configurable?
(To give beginners the ability to easily modify the system without having to go through all the code and messing something up.)

This is actually very well written. (I don't care if you repeated I2S(i) twice in the loop.)

Done!
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The timer period is still not configurable, you just need to use a constant real in the top of your global block.

Also why the return null in the AddSpaceBarAction, it seems completely useless, it even makes this function not inline friendly.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hey there,

I recently started using this snippet, however it's not working great for my purposes. I was wondering if I just have to deal with that or if there's a way around it. Because I'm making a 2dimensional interface menu that's being controlled with the arrow keys. When I select a button in it I have to press the space bar.
However... Since I have to lock my camera (or move it to the position on the map once every ~0.03 sec) it doesn't work anymore.
Locking the camera completely made tracking the space button impossible while moving camera every 0.03sec triggered the action like once every 20 presses.

So once again. Should I just forget using the spacebar with this purpose? Or is there something I could change to make it work for me?
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
Hey there,

I recently started using this snippet, however it's not working great for my purposes. I was wondering if I just have to deal with that or if there's a way around it. Because I'm making a 2dimensional interface menu that's being controlled with the arrow keys. When I select a button in it I have to press the space bar.
However... Since I have to lock my camera (or move it to the position on the map once every ~0.03 sec) it doesn't work anymore.
Locking the camera completely made tracking the space button impossible while moving camera every 0.03sec triggered the action like once every 20 presses.

So once again. Should I just forget using the spacebar with this purpose? Or is there something I could change to make it work for me?
That's because camera positions only get updated once every 0.0x seconds (don't know the exact interval, but I think its somewhere around 0.1) in multiplayer (In singleplayer, it should happen more often).
 
Level 18
Joined
Oct 20, 2007
Messages
353
Hey there,

I recently started using this snippet, however it's not working great for my purposes. I was wondering if I just have to deal with that or if there's a way around it. Because I'm making a 2dimensional interface menu that's being controlled with the arrow keys. When I select a button in it I have to press the space bar.
However... Since I have to lock my camera (or move it to the position on the map once every ~0.03 sec) it doesn't work anymore.
Locking the camera completely made tracking the space button impossible while moving camera every 0.03sec triggered the action like once every 20 presses.

So once again. Should I just forget using the spacebar with this purpose? Or is there something I could change to make it work for me?

If you are locking camera using appropriate function, this definitely wouldn't work.
However, using periodical camera panning should work, but I think in this case camera code should be put in the snippet code. I haven't tested my snippet very well. I don't have time to do it.
Also multiplayer version shouldn't be used - it doesn't work correctly all the time - so it can cause desync in some cases (I think when pressing spacebar too often or pressed by 2 players in exactly one time)

I have some ideas how to improve multiplayer version and add compatibility for camera locking.
But I repeat: too bad I don't have time.((
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Is there any news on this and multiplayer?
Also on locking the camera in multiplayer?

I'd very much like to use this if I can somehow lock the camera to a specific point and use it in multiplayer.
 
Top