Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,403 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Scripted Events - Newbie Question #154942
09/17/07 22:59
09/17/07 22:59
Joined: Apr 2007
Posts: 67
suriname0 Offline OP
Junior Member
suriname0  Offline 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
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

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 Offline OP
Junior Member
suriname0  Offline 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: suriname0] #154945
09/19/07 05:31
09/19/07 05:31
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
You need a material for that :
Code:

material colorMat
{
ambient_red = 255;
ambient_green = 0;
ambient_blue = 0;

emissive_red = 255;
emissive_green = 0;
emissive_blue = 0;
}

action Soldier_action
{
my.material = colorMat;
}



Re: Scripted Events - Newbie Question [Re: vlau] #154946
09/20/07 23:05
09/20/07 23:05
Joined: Apr 2007
Posts: 67
suriname0 Offline OP
Junior Member
suriname0  Offline 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
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

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: vlau] #154948
09/22/07 23:19
09/22/07 23:19
Joined: Apr 2007
Posts: 67
suriname0 Offline OP
Junior Member
suriname0  Offline OP
Junior Member

Joined: Apr 2007
Posts: 67
Quote:

And here is the answer found in the mighty manual->mouse_pointer:





Wierd. I'm looking at it right now, and I don't have that line in there. I think I have the 6.4 manual. Do you know of any way I could get a newer one?

Thanks for your help, though, I'll make a mouse_map.


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] #154949
09/23/07 05:31
09/23/07 05:31
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

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 Offline OP
Junior Member
suriname0  Offline 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.

Gamestudio download | chip programmers | 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