Aum 35 context

Posted By: SurudoiRyu

Aum 35 context - 01/12/08 08:51

Hi there,
How can i change the Aum 35 Context code to make it so that when i click an entity/model/player/object it gives me a menu ? not just click anywhere.
And every thing has its own menu.

(example: Tree gives me an option to examine, take leaves, cut tree. Player gives me the options Settings, Make Blade, etc.)

And that when i don't have the things to for example make blade the text just turns grey and is not selectable.

Thanks allready. Hope you can help me.
Posted By: Gandalf

Re: Aum 35 context - 01/13/08 09:39

Look for a base:

function show_menu (id_objet)
{
.........
if (id_objet ==1){pan1.visible =1;}
if (id_objet ==2){pan2.visible =1;}
if (id_objet ==3){pan3.visible =1;}
.......
}

function objet_event()
{
if (event_type == EVENT_CLICK)
{
if (my.skill1 ==1){show_menu(1);}
if (my.skill1 ==2){show_menu(2);}
.......
}
}

function menu_on_click()
{
my.ENABLE_CLICK = ON; // A6
my.emask |= ENABLE_CLICK; // A7
my.event = mouse_event;
}

action objet ()
{
menu_on_click();
....
....
}
Posted By: SurudoiRyu

Re: Aum 35 context - 01/14/08 17:19

It doesn't work what is wrong ?


Menu.wdl
Code:
  
bmap menu_pcx = <playermenu.pcx>;
//bmap b1_Examine_pcx = <b1_examine.pcx>;
//bmap b2_Examine_pcx = <b2_examine.pcx>;
bmap b1_MakeBlade_pcx = <b1_makeblade.pcx>;
bmap b2_MakeBlade_pcx = <b2_makeblade.pcx>;
//bmap b1_PickUp_pcx = <b1_pickup.pcx>;
//bmap b2_PickUp_pcx = <b2_pickup.pcx>;
bmap b1_Options_pcx = <b1_options.pcx>;
bmap b2_Options_pcx = <b2_options.pcx>;


function player_menu_choice(button_number);
function show_menu_player();
function hide_menu();

////////////////////////////////////////////////////////////////////////


panel pan_Player_WithBlade
{
bmap = menu_pcx;
pos_x = 0;
pos_y = 0;
layer = 10;
button = 2, 2, b1_MakeBlade_pcx, b2_MakeBlade_pcx, b1_MakeBlade_pcx, player_menu_choice, null, null;
button = 2, 22, b1_Options_pcx, b2_Options_pcx, b1_Options_pcx, player_menu_choice, null, null;
//button = 2, 42, b1_1024_pcx, b2_1024_pcx, b1_1024_pcx, player_menu_choice, null, null;
flags = overlay, refresh;
}
panel pan_Player_WithoutBlade
{
bmap = menu_pcx;
pos_x = 0;
pos_y = 0;
layer = 10;
//button = 2, 2, b1_MakeBlade_pcx, b2_MakeBlade_pcx, b1_MakeBlade_pcx, player_menu_choice, null, null;
button = 2, 22, b1_Options_pcx, b2_Options_pcx, b1_Options_pcx, player_menu_choice, null, null;
//button = 2, 42, b1_1024_pcx, b2_1024_pcx, b1_1024_pcx, player_menu_choice, null, null;
flags = overlay, refresh;
}




function player_menu_choice(button_number)
{
if (button_number == 1) //Make Blade
{
incTxt("You made a Blade.");
}
// if (button_number == 2) // Options
// {
// incTxt("Options.");
// }
//if (button_number == 3) //
//{
//
//}
}

function show_menu_player()
{
if (event_type == EVENT_CLICK)
{
if(mouse_right)
{

if (my.Blades == 0)
{
pan_Player_WithoutBlade.pos_x = pointer.x;
pan_Player_WithoutBlade.pos_y = pointer.y;
pan_Player_WithoutBlade.visible = on;
}
else
{
pan_Player_WithBlade.pos_x = pointer.x;
pan_Player_WithBlade.pos_y = pointer.y;
pan_Player_WithBlade.visible = on;
}
}
else
{
hide_menu();
}
}
}

function hide_menu()
{
pan_Player_WithBlade.visible = off;
pan_Player_WithoutBlade.visible = off;
wait (1);
}



Player.wdl
Code:
  
//skill1: Health 100
//skill2: WalkingSpeed 10
//skill3: TurningSpeed 8
//skill4: JumpHeight 10
//skill5: AttackSpeed 10
//skill10: Blades 0


//defines
define Health, skill1;
define WSpeed, skill2;
define TSpeed, skill3;
define JumpHeight, skill4;
define AttackSpeed, skill5;
define Blades, skill10;

//Vars
var move_vec[3] = 0,0,0;
var idle_percent = 0;
var walk_percent = 0;

//Debug Tekst
BMAP bmp_type1 = "Gras.jpg"; // Grass Grond
BMAP bmp_type1C = "GrasC.jpg"; // Grass Grond Ingedrukt
BMAP bmp_type2 = "Zand.jpg"; // Zand Grond
BMAP bmp_type2C = "ZandC.jpg"; // Zand Grond Ingedrukt
BMAP bmp_type3 = "Water.jpg"; // Water Grond
BMAP bmp_type4 = "Metaal.jpg"; // Metaal Grond
BMAP bmp_type4C = "MetaalC.jpg"; // Metaal Grond Ingedrukt
//string str_debug = "debuglijn";
//Modder Grond

//Lettertype
font fnt_century12 = <Centur12.pcx>,16,20; // Century12 font

//Grond Panels
PANEL pnl_Grond1
{
layer = 15;

BUTTON=0,0,bmp_type1C,bmp_type1,bmp_type1,Take_Gras,NULL,NULL;
}

PANEL pnl_Grond2
{
layer = 15;

BUTTON=0,0,bmp_type2C,bmp_type2,bmp_type2,Take_Zand,NULL,NULL;
}

PANEL pnl_metaal
{
layer = 15;

BUTTON=111,0,bmp_type4C,bmp_type4,bmp_type4,Take_Metaal,NULL,NULL;
}

///Einde Debug Scripts

function check_keys()
{
move_vec[0] = (key_w - key_s)*MY.WSpeed *time;
if(key_a)
{
my.pan += my.TSpeed*time_step;
}
if(key_d)
{
my.pan -= my.TSpeed*time_step;
}

If (move_vec[0] == 0 && move_vec[1] == 0)
{
idle_percent = (idle_percent +5*time)%100;
ent_animate(me,"idle",idle_percent,ANM_CYCLE);
}
else
{
walk_percent = (walk_percent + sign(move_vec[0])*5*time)%100;
ent_animate(player,"walk",walk_percent,ANM_CYCLE);
}

c_move(me,vector(0,0,0),nullvector, IGNORE_YOU | IGNORE_PASSABLE | IGNORE_PUSH | IGNORE_MODELS | ACTIVATE_TRIGGER | GLIDE);
ent_move(move_vec,NULLVECTOR);
}



function Check_Ground()
{
if(me)
{
pnl_Grond1.visible = off;
pnl_Grond2.visible = off;
pnl_metaal.visible = off;
c_trace(my.x, vector(my.x, my.y, my.z -5000), IGNORE_ME | USE_BOX | ACTIVATE_SONAR);
if(str_stri(tex_name, "grass") != 0)
{
pnl_Grond1.visible = on;
}

if(str_stri(tex_name, "sand") != 0)
{
pnl_Grond2.visible = on;
}
}
}




action Speler_Beweging()
{
player = my;
camera.genius = my;

c_setminmax(me);

my.ENABLE_CLICK = ON;
my.event = show_menu_player();

while(1)
{
if(my.Health > 0)
{
check_keys();
check_ground();
}
wait(1);
}
}


I included both scripts in main.wdl

hope u can help me :)


Posted By: George

Re: Aum 35 context - 01/14/08 20:01

The first problem I'm seeing is this:
"my.event = show_menu_player();"
should be
"my.event = show_menu_player;"
Posted By: SurudoiRyu

Re: Aum 35 context - 01/14/08 20:57

Allready got it up and running ^^
If someone is curius pm me and ill post it here.

Greetzzz, and thnx.
Posted By: Nems

Re: Aum 35 context - 01/15/08 03:46

Yeah, it would be good to see a screenie of it working please.
Posted By: SurudoiRyu

Re: Aum 35 context - 01/15/08 14:37

This screenshot when i clicked right mouse on the player.



This screenshot when i activated it.



This screenshot when i clicked somewhere else right mouse.



If you not believe it try it yourself
Downloaded the file here
Posted By: Nems

Re: Aum 35 context - 01/15/08 19:24

Thanks and good work
Posted By: SurudoiRyu

Re: Aum 35 context - 01/15/08 21:39

No problem ^-^ it is now easy to insert more i got 2 seperate menu's now
one for item pickup and one for the player it scans now on id's
only one thing isn't wprking maybe someone can explain me why it isn't

Code:

ENTITY* tmpItm;

function ground_pickup_event
{
if (event_type == EVENT_SCAN)
{
tmpItm = my;
player.MuisKlik = my.id;
}
}

ACTION Grass_Action
{
my.id = 2;
my.enable_scan = on;
my.event = ground_pickup_event;
}

function pickup_menu_choice(button_number)
{
if (button_number == 1) //Pick Up
{
if(tmpItm)
{
ent_remove(tmpItm);
incTxt("You picked up some grass.");
}
wait(1);
}
if (button_number == 2) // Options
{
incTxt("This grass is drying in the sun.");
}
}




It doesn't remove the object.
Also it won't display the the text
so i think the tmpItm is empty but i define it ? :S
© 2024 lite-C Forums