|
C# and Java Developer starting Lite-C programming.
#293987
10/15/09 12:08
10/15/09 12:08
|
Joined: Oct 2009
Posts: 21 Redneck country USA
Crazykins
OP
Newbie
|
OP
Newbie
Joined: Oct 2009
Posts: 21
Redneck country USA
|
Lite-C is coming pretty fast for me. But it seems I am at a stand still. I did look at all of the tutorials, manual, and the AUM for this information. What I am trying to do is to have a mouse click on a model 1. Trigger the mouse clicked event. 2. Find out which house was clicked. 3. Load the appropriate level. Here is my code thus far:
BMAP* cursor = "cursor.tga";
var frame_speed = 0;
STRING* mystring = "You clicked the mouse!";
function main()
{
video_mode = 9;
video_screen = 1;
level_load ("level1.wmb");
mouse_mode += 1;
mouse_map = cursor;
while (1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
wait (1);
}
}
function house_event()
{
if (event_type == EVENT_TOUCH) // the house was touched?
{
my.ambient = 50; // make it look bright
my.lightrange = 50; // and generate light on a radius of 50 quants!
while (frame_speed <= 101)
{
ent_animate(my, "Move", frame_speed, ANM_CYCLE);
frame_speed += 8 * time_step;
wait(1);
}
frame_speed = 0;
if (event_type == EVENT_CLICK)
{
TEXT* myText =
{
pos_x = 300;
pos_y = 250;
string (myString);
flags = SHOW;
}
}
}
else // the house isn't touched anymore
{
if (event_type == EVENT_RELEASE) // the mouse was moved away from it?
{
my.ambient = 0; // then restore its initial ambient value (zero)
my.lightrange = 0; // and stop it from generating light around it
}
}
}
action house_selection() // this action is attached to both houses
{
// make the house models sensitive to mouse touching and releasing
my.emask = ENABLE_TOUCH | ENABLE_RELEASE;
my.emask |= ENABLE_CLICK;
my.event = house_event;
}
The lighting and animation on the mouse over event works perfectly. I am trying to test the mouse click with a message. The message is always up even if there were no mouse hover or click events. Which to me is weird. Why would it even execute before the event. This could be because of my background in C# and Java that I am just not getting why this is happening. The events are setup correctly as you can plainly see from the code. I also tried different flags and tried using toggle keyword but still the message is always up. I also need help finding the correct keyword in Lite-C to get an object (model) from a mouse position. I can find little of this in the manual. I have the express version of 3dgs. Thanks for your help!
Last edited by Crazykins; 10/18/09 08:35.
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: Crazykins]
#293988
10/15/09 12:21
10/15/09 12:21
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
Serious User
|
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
I think you have to use txt_create() to create a TEXT object at runtime.
I think there's some remark in the manual.
Regards, Pegamode.
Last edited by pegamode; 10/15/09 12:22.
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: pegamode]
#294000
10/15/09 13:54
10/15/09 13:54
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! Place the code for :TEXT* myText outside the event and comment out this line // flags = SHOW; Then you can set or reset this flags in another function
Hope this helps! Ottawa Ver 7.86.2 Pro and Lite-C
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: Ottawa]
#294004
10/15/09 14:23
10/15/09 14:23
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
Serious User
|
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Hi! Place the code for :TEXT* myText outside the event and comment out this line // flags = SHOW; Then you can set or reset this flags in another function Yes, I forgot to mention this ... otherwise you would have to use txt_create.
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: pegamode]
#294060
10/15/09 21:47
10/15/09 21:47
|
Joined: Oct 2009
Posts: 21 Redneck country USA
Crazykins
OP
Newbie
|
OP
Newbie
Joined: Oct 2009
Posts: 21
Redneck country USA
|
ok this time I put the myText object under the myString object. And I changed my nested if statement to:
if (event_type == EVENT_CLICK)
{
myText.flags = SHOW;
}
It is still nested in my house_event function. It is still not working. I must be doing something wrong I just can't figure out what it is. I even tried this:
action house_selection() // this action is attached to both houses
{
// make the house models sensitive to mouse touching and releasing
my.emask = ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
my.event = house_event;
}
and re assigning the action in WED. Nothing works. Thanks though for all of your help!
Last edited by Crazykins; 10/18/09 08:36.
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: Crazykins]
#294066
10/15/09 23:29
10/15/09 23:29
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! Your close myText.flags = SHOW; should be myText.flags |= SHOW; Look up the flags in the manual. Look up set() reset() toggle () To help you with this part pick up my contribution : Flags at a glance in the resource section.
Hope this helps! Ottawa Ver 7.86.2 Pro and Lite-C
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: Ottawa]
#294069
10/15/09 23:43
10/15/09 23:43
|
Joined: Oct 2009
Posts: 21 Redneck country USA
Crazykins
OP
Newbie
|
OP
Newbie
Joined: Oct 2009
Posts: 21
Redneck country USA
|
I did finally get it to work! I had to take it out of my if statement nest for it to work. The working code is:
function house_event()
{
if (event_type == EVENT_TOUCH) // the house was touched?
{
my.ambient = 50; // make it look bright
my.lightrange = 50; // and generate light on a radius of 50 quants!
while (frame_speed <= 101)
{
ent_animate(my, "Move", frame_speed, ANM_CYCLE);
frame_speed += 8 * time_step;
wait(1);
}
frame_speed = 0;
}
if (event_type == EVENT_CLICK)
{
myText.flags |= SHOW;
}
else // the house isn't touched anymore
{
if (event_type == EVENT_RELEASE) // the mouse was moved away from it?
{
my.ambient = 0; // then restore its initial ambient value (zero)
my.lightrange = 0; // and stop it from generating light around it
}
}
}
For my function. Now that I have tested it comes the fun part of finding out which model the user clicks on.
Last edited by Crazykins; 10/18/09 08:37.
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: Crazykins]
#294070
10/15/09 23:46
10/15/09 23:46
|
Joined: Oct 2009
Posts: 21 Redneck country USA
Crazykins
OP
Newbie
|
OP
Newbie
Joined: Oct 2009
Posts: 21
Redneck country USA
|
SWEET! Thanks guys for all of your help! Using this code works super well.
if (event_type == EVENT_CLICK)
{
toggle(myText, SHOW);
}
Thanks once again!
Last edited by Crazykins; 10/18/09 08:37.
|
|
|
Re: C# and Java Developer starting Lite-C programming.
[Re: Crazykins]
#294119
10/16/09 13:32
10/16/09 13:32
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! Happy to help Ottawa PS : Here's something to read for posting. In the FAQ read : What UBBCode can I use in my posts?
Last edited by Ottawa; 10/16/09 13:35.
|
|
|
|