Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by AndrewAMD. 08/27/26 15:28
Retrieve optimize() variables order (edited)
by NorbertSz. 08/25/26 13:24
Max Number of Strategies in /Strategy folder
by Martin_HH. 08/17/26 07:54
Pause button for evaluation shell?
by AndrewAMD. 08/13/26 17:16
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/10/26 12:46
phantom() not defined in indicators.c
by jcl. 08/07/26 11:45
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (Quad, AndrewAMD), 7,396 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Student_64151, Koti
19230 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How do I use event_click correctly?? #367559
04/14/11 18:07
04/14/11 18:07
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Hi guys,
I want to make a small strategy game. To recognize if ye click on a model I tried to use event_click, but it doesn't work. Anybody know why??

function mouse_event()
{
while(1)
{
if (event_type == EVENT_CLICK)
{
beep();
ent_remove(me);
return;
}
wait(1);
}
}

action sound_on_click()
{
set(me,ENABLE_CLICK);
my.emask |= ENABLE_CLICK;
my.event=mouse_event;
}

Re: How do I use event_click correctly?? [Re: Wollez] #367560
04/14/11 18:26
04/14/11 18:26
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Welcome to the forums!

1. Don't use loops in events.
2. Don't use ENABLE_CLICK in combination with the set macro. This will do bad things.
3. Check if the action sound_on_click is ever called by placing a beep or a printf("Over here!"); in the first line of the action.


Always learn from history, to be sure you make the same mistakes again...
Re: How do I use event_click correctly?? [Re: Wollez] #367561
04/14/11 18:28
04/14/11 18:28
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Your code should look like this:
Code:
function mouse_event() 
{
	if (event_type == EVENT_CLICK) 
	{
		beep();
		ent_remove(me);
		return;
	}
}

action sound_on_click()
{
	my.emask |= ENABLE_CLICK;
	my.event = mouse_event;
}



Hope that helps. laugh


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: How do I use event_click correctly?? [Re: Wollez] #367562
04/14/11 18:33
04/14/11 18:33
Joined: Jan 2011
Posts: 797
Da wo du nicht bist! Muhahaha!
xxxxxxx Offline
User
xxxxxxx  Offline
User

Joined: Jan 2011
Posts: 797
Da wo du nicht bist! Muhahaha!
Hi,
why do you use this while in your event?
remove the while loop, it doesnt make sence there!
Code:
function mouse_event()
{
	if (event_type == EVENT_CLICK)
	{
		beep();
		ent_remove(me);
		return();
	}
}


how big is the distance btw. the camera and the objekt?(in quants)

and use code tags if you want to show us parts of your code(dont forget to use "inden all" in sed)
[ code ]
[ /code ]
without spaces
xxxxxxx

Last edited by xxxxxxx; 04/14/11 18:34.

Es ist immer wieder erstaunlich, dass Leute die riesen Scripte schreiben die einfachsten sachen nicht können zb. mich mit SIEBEN x zu schreiben! tongue
Re: How do I use event_click correctly?? [Re: Uhrwerk] #367563
04/14/11 18:48
04/14/11 18:48
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
I'm sorry Urhwerk, but I don't know what a "set macro" is.

Re: How do I use event_click correctly?? [Re: xxxxxxx] #367565
04/14/11 18:53
04/14/11 18:53
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Thanks a lot for al those quick answers.
But it still doesn't work. I set mouse_range to 30000, the distance is about 1500 and I took the code of redeemer, so when I click on this model it should beep and disappear, or? What am I doing wrong

Re: How do I use event_click correctly?? [Re: Wollez] #367566
04/14/11 19:09
04/14/11 19:09
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You used the set macro in the line "set(me,ENABLE_CLICK);". set is a macro because it gets replaced by the precompiler. After the precompiler changed your line it should look like "(me->flags |= (ENABLE_CLICK));". That is very dangerous because you set an eflag in the flags.

When you execute Redeemer's code it should work, yes. Please place a "prtinf("Here!");" in the first line of sound_on_click. Does that pop up a message box for you?


Always learn from history, to be sure you make the same mistakes again...
Re: How do I use event_click correctly?? [Re: Uhrwerk] #367653
04/16/11 07:20
04/16/11 07:20
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Why doesn't this work? I've done all you've said, bur it still doesn't work

EDIT: Found sth. if i put a printf in event_click, nothing happens. The event isn't beeing executed. But I've got no idea why.
Please!! Someone help me.eek

Last edited by Wollez; 04/16/11 12:40.
Re: How do I use event_click correctly?? [Re: Wollez] #367675
04/16/11 13:14
04/16/11 13:14
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Did you activate the mouse at all (mouse_mode = 4;) ?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How do I use event_click correctly?? [Re: Superku] #367741
04/17/11 13:12
04/17/11 13:12
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
YYYEEESSSS, thanks!!!!!!
I'm so stupid mad mad mad blush blush cry cry
I had mouse_mode set on 2, of course it doesn't work then.
Sorry everyone for causing this trouble.


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1