![]() |
Triggeraction Difficulties
I have been playing around with a script, but I am having problems. I try to drag the NPC using this script but it only triggers if I mouseup on the same spot it origonally was.. which is odd.. and when it triggers.. it triggers every NPC that is joined to the class.. anyone got any ideas whats wrong o.O
PHP Code:
PHP Code:
|
You need to be triggering within the shape of the NPC at the serverside position, you seem to be triggering the new coordinate rather than the existing one.
|
Quote:
|
Quote:
The problem could also be that you're triggering edge-on with the NPC's shape, afaik you need to be within its shape, such as this.x + 0.5, this.y + 0.5. |
Quote:
so when i put the npc using putnpc2, it has an x and a y serverside... when i go to trigger it even tho clientside it changes x and y, i would need to trigger it at the origonal position i placed it? |
Quote:
PHP Code:
|
Doesn't seem to be working, at all now.
PHP Code:
I am guessing I am going to need to "showimg()" where it will be shown while dragging, THEN update the x and y? |
You shouldn't be using triggeraction for this anyway, it's unreliable, especially when you're doing something that involves moving the NPCs. Generally a better way is to setup some way of uniquely identifying your NPCs (easy if they're DB NPCs/putnpcs).
|
Problem might be that you're using 'setshape2' instead of 'setshape'. Setshape2 is for modifying the tiletype's beneath an NPC.
|
Quote:
PHP Code:
Quote:
|
Quote:
PHP Code:
|
Quote:
PHP Code:
|
Quote:
Also should use this.ox and this.oy to store this.x and this.y rather than factoring in the mouse position. It's also worth mentioning that if the image hasn't been downloaded to your client yet, getimgwidth() and getimgheight() would return 0. |
I send those parameters and then it breaks.. im thinking i need to reupdate the cord im triggering at maybe?
also, thanks for letting me know that about getimg...()... does that only apply to clientside or serverside as well? EDIT: (Fixed, and working, now to clean it up) PHP Code:
|
Quote:
Quote:
I just noticed this too: Quote:
|
Yeah, if it's true, it does stuff and makes it not true. That way it wont let me do it again. Nothing wrong with that. However in the first post, I did "if ( this.candrag = true ) {" by mistake. I need to go ahead and clean the script up now that I have learned some new things about triggeractions, setshape, and image sizes.
Thanks for the help. Much appreciated. |
I was referring to a slight typo of 'fasle'.
|
Opps. Yeah I noticed that earlier, and fixed it. Broke the script and pasted the one from the forums I had posted previous but I guess I failed to fix it. Thanks for pointing that out.
|
Quote:
|
Quote:
|
Quote:
PHP Code:
Now you no longer have to worry about shapes or overlapping or any of that other junk. |
Quote:
And rather then a new thread for a 2 second fix, I have the above code also setting a variable after joining: PHP Code:
It seems attr's work but was wondering if theres any other way. |
Quote:
|
Quote:
And actually, there were to be multiple npc's placed in the level. Ounce clicked they would do something. So mouse down it still needs to know which one is to be focused on. So I don't know how you were suggesting graal determin "what I was clicking" based on one of many copies of the same npc in the level. |
Quote:
Quote:
Quote:
|
Quote:
And you still wont elaborate "how does graal know which npc I click" if not by the mousex and y? Does it just guess? I ask for help you flame me when I ask to elaborate and you don't. Wth man. Point being said, the mouse has to click anywhere on the npc.. then the npc judges where at you clicked, so it doesnt mess up where the npc is in relation to the mouse, as being dragged. If I just did a trigger for when the mouse is clicked I don't even begin to comprehend how graal is suspose to know "which" npc was clicked. |
Quote:
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 05:55 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.