Jump to content

Welcome to Gaming On Steroids Forums
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account
Photo

How do I navigate MenuElements

External menu-elements

  • Please log in to reply
10 replies to this topic

#1
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Just a quick doubt: Once I create a submenu in a menu it becomes a table in that menu, right, and it's indexer is what, it's ID?

 

Example:

local myMenu = MenuElement ( { id = "main_menu", name = "Main Menu", type = MENU } )

local comboMenu = myMenu:MenuElement ( { id = "main_menu_combo", name = "Combo", type = MENU, key = 0x20 } )
comboMenu:MenuElement ( { id = "main_menu_combo_smart", name = "Smart Combo", type = PARAM, value = true } )
comboMenu:MenuElement ( { id = "main_menu_combo_dumb", name = "Dumb Combo", type = PARAM, value = false } )

lets say I want to check if DumbCombo is true:

function OnTick ( )
    if combo_menu.main_menu_combo_dumb.Value ( ) then
        --Do dumb stuff
    end
end

Is this correct?


  • 0

#2
Alqohol

Alqohol

    Advanced Member

  • GFX Designer
  • 156 posts

 

 

try:

local myMenu = MenuElement({type = MENU, id = "main_menu", name = "Main Menu"})

myMenu:MenuElement({type = MENU, id = "main_menu_combo", name = "Combo"})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_key", name = "Combo Key", value = 0x20})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_smart", name = "Smart Combo", type = PARAM, value = true})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_smart", name = "Dumb Combo", type = PARAM, value = false})

Callback.Add('Tick', function()
     if myMenu.main_menu_combo.main_menu_combo_key:Value() then
          if myMenu.main_menu_combo.main_menu_combo_dumb:Value() then
               --Do dumb stuff
          end
     end
end)

although i'd work on your naming conventions


  • 0

#3
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

try:

local myMenu = MenuElement({type = MENU, id = "main_menu", name = "Main Menu"})

myMenu:MenuElement({type = MENU, id = "main_menu_combo", name = "Combo"})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_key", name = "Combo Key", value = 0x20})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_smart", name = "Smart Combo", type = PARAM, value = true})
myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_smart", name = "Dumb Combo", type = PARAM, value = false})

Callback.Add('Tick', function()
     if myMenu.main_menu_combo.main_menu_combo_key:Value() then
          if myMenu.main_menu_combo.main_menu_combo_dumb:Value() then
               --Do dumb stuff
          end
     end
end)

although i'd work on your naming conventions

 

The names were just for the purpose of this thread. But then I have to create a separate menu for the key?
 

myMenu.main_menu_combo:MenuElement({id = "main_menu_combo_key", name = "Combo Key", value = 0x20})

I thought key was a parameter any MenyElement could have and then I would test for that menu instance Value ( ) against some IS_KEY_DOWN constant.

 

So, for example, if I have something like: (I'll try to improve the names)
 

local harass_menu = main_menu:MenuElement ( { id = "main_menu_harass", name = "Harass", type = MENU } )

harass_menu:MenuElement ( { id = "main_menu_harass_harass_toggle",
                            name = "Harass Toggle",
                            type = PARAM,
                            value = false,
                            key = 0x41 } ) -- this is wrong, apparently

--bellow is the correct form, if I understood you correctly. But how do I assign a key to perform
--the same functionality as clicking the menu item (assuming clicking the MenuElement will indeed
--toggle it from false to true and vice-versa)
harass_menu:MenuElement ( { id = "main_menu_harass_harass_toggle",
                            name = "Harass Toggle",
                            type = PARAM,
                            value = false } )

In the code above, I make the following assumption: clicking a boolean MenuElement will toggle it.

 

How do I assign a key that will have the same effect as oppening the menu and clicking it?


  • 0

#4
Deftsu

Deftsu

    donthackourgames

  • Ex-Core Dev
  • PipPipPip
  • 4,812 posts
if comboMenu.main_menu_combo_dumb:Value() then
  -- do stuff
end

  • 0

#5
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil
if comboMenu.main_menu_combo_dumb:Value() then
  -- do stuff
end

 

No that's not it. I want to know

 

1) If I click a boolean menu, will I toggle it?

2) How can I assign a keyboard shortcut to that menu, so the person doesn't have to open it in order to toggle it?


  • 0

#6
Deftsu

Deftsu

    donthackourgames

  • Ex-Core Dev
  • PipPipPip
  • 4,812 posts

No that's not it. I want to know
 
1) If I click a boolean menu, will I toggle it?
2) How can I assign a keyboard shortcut to that menu, so the person doesn't have to open it in order to toggle it?


your question is a bit vague but i'll try to answer (from what i understood) :)

1) a boolean is true or false, each click change the value to the opposite (true to false or false to true) when you click
2) uhm do you mean the main menu or yours ?, if so you could click the menu to op it or just press shift
  • 0

#7
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

your question is a bit vague but i'll try to answer (from what i understood) :)

1) a boolean is true or false, each click change the value to the opposite (true to false or false to true) when you click
2) uhm do you mean the main menu or yours ?, if so you could click the menu to op it or just press shift

 

Ok, you answered part one of my question I think.

Now:

 

Imagine I have a MenuElement with a boolean value;

Imagine I want to allow the player to toggle that MenuElement (from true to false and vice-versa) by pressing a key

 

Is there a way to imbue that key in the MenuElement itself or do I have to check like

if Control.IsKeyDown ( key ) then
    toggle_menu_element ( )
end

  • 0

#8
Feretorix

Feretorix

    Administrator

  • Administrators
  • 3,177 posts

I guess you're asking for the same as toggling a boolean with a hotkey, just like for disabling/enabling auto-evade or auto-smite.

 

Did i understand right?


  • 0

#9
Inspired2

Inspired2

    Advanced Member

  • Members
  • 75 posts
local myToggleParam = MenuElement{ id = "main_menu_harass_harass_toggle", name = "Harass Toggle" , key = 0x41, toggle = true }

Callback.Add("Tick", function()
    if myToggleParam:Value() then
        -- do stuff
    end
end)

  • 0

#10
evitaerCi

evitaerCi

    Advanced Member

  • Scripts Developer
  • 176 posts
local myToggleParam = MenuElement{ id = "main_menu_harass_harass_toggle", name = "Harass Toggle" , key = 0x41, toggle = true }

Callback.Add("Tick", function()
    if myToggleParam:Value() then
        -- do stuff
    end
end)

Hi welcome to GoS


  • 0

#11
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

I guess you're asking for the same as toggling a boolean with a hotkey, just like for disabling/enabling auto-evade or auto-smite.

 

Did i understand right?

Yes! That's it. is @ThePokemonGuy answer correct? I didn't see the toggle element documented anywhere regarding the MenuElement table.


  • 0





Also tagged with one or more of these keywords: External, menu-elements

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users