Custom user menu

About advanced scenes, and the Thyme scripting language used in Algodoo.

Custom user menu

Postby Kilinich » Tue Jan 25, 2011 2:03 pm

Finally... mouse clickable user custom menu phunlet available.
TAB is default activation key, but sure you can reassign it.

Filesize: 41.11 kB
Comments: 2
download


How to use:

0) Load phunlet
It use collision group G so place it right (or change collideSet if you need to)

1) Create your menu as list variable:
[Title_string, Width_int, ItemCount_int, [item1_string, item2_string...], [item1_action, item2_action...]]

2) Call scene.my.menuOpen(menu, pos) in yellow laser onLaserHit event

That's all!

If you want make sub menu, you must do exactly the same - declare sub-menu variable and fill it with items, then call this menu from "parent" menu item action. To set correct pos for submenu you can use scene.my.subMenuPos(selected_item) function.

Code: Select all
Scene.my.menuDefault := ["Menu", 7, 2, ["Change color...", "Exit menu"], [{scene.my.menuOpen(scene.my.colorMenu, scene.my.subMenuPos(1))}, {scene.my.menuClose}]];

Scene.my.colorMenu := ["Set menu colors", 10, 5, ["White", "Dark gray", "Orange", "Ocean", "Night city"], [{
    Scene.my.menuColor = Scene.my.menuTheme(0);
    scene.my.menuClose
}, {
    Scene.my.menuColor = Scene.my.menuTheme(1);
    scene.my.menuClose
}, {
    Scene.my.menuColor = Scene.my.menuTheme(2);
    scene.my.menuClose
}, {
    Scene.my.menuColor = Scene.my.menuTheme(3);
    scene.my.menuClose
}, {
    Scene.my.menuColor = Scene.my.menuTheme(4);
    scene.my.menuClose
}]];
Last edited by Kilinich on Tue Jan 25, 2011 2:31 pm, edited 3 times in total.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Custom user menu

Postby Kilinich » Tue Jan 25, 2011 2:09 pm

So... the question is - do you want check-boxes and radio-buttons? :mrgreen:
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Custom user menu

Postby Kilinich » Fri Jan 28, 2011 10:31 am

I've test "dynamic" menu variable and it works fine, for example if you need some of menu items must be inactive depends on variable - no problem:

Code: Select all
scene.my.var := 2;
scene.my.active := (txt, isActive) => {isActive ? txt : "<markup><s>"+txt+"</s></markup>"};
scene.my.liveMenu := {["Dynamic menu example", 12, 1, [scene.my.active("var is big", scene.my.var > 3)], [{scene.my.menuClose}]]};
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Custom user menu

Postby TC42 » Fri Jan 28, 2011 11:26 pm

Radio-buttons all the way! :D This is awesome!! Thanks for sharing!
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Custom user menu

Postby ags131 » Sat Jan 29, 2011 2:28 am

One of the best uses of thyme i've ever seen! Good job!
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Custom user menu

Postby TC42 » Sun Feb 20, 2011 9:22 pm

I saved it as a phunlet, and it won't work.
What I did was:
Open the phunlet, fix it to the background
Copy and paste the menu-code (code in the first post) into the console and press enter
press the tab key to test the phunlet; nothing happened.

What am I doing wrong?
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Custom user menu

Postby Kilinich » Sun Feb 20, 2011 9:46 pm

TC42 wrote:I saved it as a phunlet, and it won't work.
What am I doing wrong?


Did you run the simulator? ;)
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Custom user menu

Postby TC42 » Sun Feb 20, 2011 10:07 pm

Yes, the sim was running when I tried to use it.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Custom user menu

Postby Kilinich » Sun Feb 20, 2011 10:19 pm

Reset config.
Check console for errors.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Custom user menu

Postby TC42 » Sun Feb 20, 2011 10:27 pm

I reset my config (using the in-game reset)
Console said this when I loaded up the phunlet
Code: Select all
Loading Algodoo/scenes/phunlets/UserMenu.phz...
-- Warning: Failed to evaluate: scene.my.mainLaser, Cannot find identifier "mainLaser" in "my"
-- Warning: Caught Exception: Not an integer, source\script\Attributes.hpp:169: void script::TAttrib<int>::CalcValueFromObject(void)
-- Warning: maxRays was bound to bad type. Restoring to last known value.
-- Warning: Failed to evaluate: scene.my.menuLaser, Cannot find identifier "menuLaser" in "my"
Imported phunlet Algodoo/scenes/phunlets/UserMenu.phz


When I pressed the tab key, the console didn't say anything, but the yellow laser did fire.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Custom user menu

Postby Kilinich » Mon Feb 21, 2011 8:33 am

TC42 wrote:I reset my config (using the in-game reset)
Console said this when I loaded up the phunlet
Code: Select all
Loading Algodoo/scenes/phunlets/UserMenu.phz...
-- Warning: Failed to evaluate: scene.my.mainLaser, Cannot find identifier "mainLaser" in "my"
-- Warning: Caught Exception: Not an integer, source\script\Attributes.hpp:169: void script::TAttrib<int>::CalcValueFromObject(void)
-- Warning: maxRays was bound to bad type. Restoring to last known value.
-- Warning: Failed to evaluate: scene.my.menuLaser, Cannot find identifier "menuLaser" in "my"
Imported phunlet Algodoo/scenes/phunlets/UserMenu.phz


When I pressed the tab key, the console didn't say anything, but the yellow laser did fire.


Damn, who told you to SAVE it as phunlet from algodoo - it just erase scene.my section.
Save it to phunlet folder from browser!
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Custom user menu

Postby TC42 » Mon Feb 21, 2011 4:04 pm

Ohhhhh. That would explain it. Thanks!! :thumbup:
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests