2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Scripted Events - Newbie Question
#154942
09/17/07 22:59
09/17/07 22:59
|
Joined: Apr 2007
Posts: 67
suriname0
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2007
Posts: 67
|
This code does not work for one reason or another; the Event is not triggering as it should. Code:
function Soldier_event() { if (EVENT_TYPE == EVENT_CLICK) { beep(); } if (EVENT_TYPE == EVENT_touch) { beep(); } }
action Soldier() { var anim_percent = 0; my.enable_click = on; my.enable_touch=on; my.event=Soldier_event; while(1) { ent_animate(me, "walk", anim_percent, ANM_CYCLE); c_move(me, vector(0.03,0,0), nullvector, IGNORE_PUSH); anim_percent += 2.2 * Time; wait(1); } }
function main() { //video_switch (0,0,1); wait(1); sky_color.red=1; sky_color.green=1; sky_color.blue=1; mouse_range = 3000; mouse_mode = 1; level_load(RTSPlayThing1_wmb); wait(3); So.... why doesn't it work? You'd think the event would trigger some sort of Beep, and the Action works just fine. (Person perpetually walks towards cliff.) I'm quite new to Events, so if someone could tell me what I am doing wrong, that would be appreciated. btw, A6.6 commercial
If I am posting, it probably means I am asking a question. Or faking my knowledge by agreeing with somebody else.
|
|
|
Re: Scripted Events - Newbie Question
[Re: suriname0]
#154943
09/18/07 05:53
09/18/07 05:53
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
You need to activate the engine mouse pointer, add the following lines in function main after level_load: Code:
level_load(RTSPlayThing1_wmb); wait(3);
mouse_mode = 1; mouse_range = 20000 // play with 20000
while(1) { mouse_pos.x = mouse_cursor.x; mouse_pos.y = mouse_cursor.y; wait(1); }
|
|
|
Re: Scripted Events - Newbie Question
[Re: vlau]
#154944
09/19/07 01:03
09/19/07 01:03
|
Joined: Apr 2007
Posts: 67
suriname0
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2007
Posts: 67
|
Thanks. As I expected, I feel stupid now.
While we are on the subject of stupid Newbie scripting errors, how do I get the model with Soldier_action() to turn red? (Without using ent_morph.) I tried to say my.red=1; or my.red=255; but it doesn't do what I want. (There isn't even a visible change!)
If I am posting, it probably means I am asking a question. Or faking my knowledge by agreeing with somebody else.
|
|
|
Re: Scripted Events - Newbie Question
[Re: vlau]
#154946
09/20/07 23:05
09/20/07 23:05
|
Joined: Apr 2007
Posts: 67
suriname0
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2007
Posts: 67
|
Huh, I didn't know I had to use a Material. Thanks again. But, I ended up doing this anyways: Code:
if (mouse_left == 1) //mouse button is depressed { if (mouse_ent == me) { my.selected=1; } else { my.selected=0; } if (my.selected == 1) { my.material=Selected_mat; } else { my.material=Normal_mat; } }
It works fine, but I am worried about massive slow-downs whenever a player clicks. Also, it is a little hard to select the unit. It appears to not be using the bounding box. Can I get it to use the bounding box instead? And, while I am asking newbie questions: Why is the mouse not appearing when I go to full screen mode (w/ VideoSwitch)? it just isn't visible, I can still select the unit.
If I am posting, it probably means I am asking a question. Or faking my knowledge by agreeing with somebody else.
|
|
|
Re: Scripted Events - Newbie Question
[Re: suriname0]
#154947
09/21/07 19:39
09/21/07 19:39
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
I think it won't slow down your game too much unless there are thousand of entities infront of the camera. mouse_ent detect the mesh body not the bounding box, I think the mouse_range is the problem. Quote:
Why is the mouse not appearing when I go to full screen mode
And here is the answer found in the mighty manual->mouse_pointer:
Quote:
In fullscreen mode the system cursors are not visible; only a mouse_map can be used for the fullscreen cursor.
BTW, why not write your previous code like this :
Code:
if (mouse_left && mouse_ent == my) { my.material = Selected_mat; } else { my.material = Normal_mat; }
|
|
|
Re: Scripted Events - Newbie Question
[Re: suriname0]
#154949
09/23/07 05:31
09/23/07 05:31
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Just download and update to version 6.6 from the download page then you'll have that line in your manual
|
|
|
Re: Scripted Events - Newbie Question
[Re: vlau]
#154950
09/23/07 14:36
09/23/07 14:36
|
Joined: Apr 2007
Posts: 67
suriname0
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2007
Posts: 67
|
Really? I already updated to 6.6. Maybe I short-cutted the wrong manual. (I have one 3dgs on two different drives.)
...
Yep. I did. Fixed it now, thanks.
If I am posting, it probably means I am asking a question. Or faking my knowledge by agreeing with somebody else.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|