Initial menu system by claude

This commit is contained in:
2026-04-14 02:05:15 -04:00
parent 07b90ced1a
commit 49331773bf
10 changed files with 149 additions and 14 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Widgets/WB_Menu.uasset LFS Normal file

Binary file not shown.

Binary file not shown.

55
instructions.txt Normal file
View File

@@ -0,0 +1,55 @@
Currently, my demo game includes a hotkey system. You will use the
existing hotkey system as inspiration to build a menu system.
In my lua code, I can create a class such as "sphere." Then
I can create an instance of that class and make it appear in
the world.
I can also define a lua function "sphere.lookhotkeys" which adds
hotkeys to objects of class sphere. When I aim the crosshairs
at a sphere, a widget WB_Hotkeys appears, and it shows me the
hotkeys for spheres.
I can then press one of those hotkeys. The WB_Hotkeys widget
handles the key event, displaying visual feedback, and it
also invokes a lua function which eventually leads to the
proper hotkey action being taken in lua.
I want you to study this mechanism, learning exactly how this
process works. Then, I want you to implement a menu system
that operates on exactly the same principles.
Currently, my demo game contains a sphere and a cube which
both have hotkeys. I want you to reprogram the cube
so that it has a menu instead of hotkeys.
The menu system will require me to write a lua function
such as cube.lookmenu, which generates the contents of the
menu. When I point the crosshairs at a cube, the menu
widget WB_Menu will appear in minimized form. In minimized
form, the WB_Menu widget will just look like a little
circle or something. This is just enough of a clue to
the user that a menu is there to be activated.
When the user clicks the left mouse button, WB_Menu will
switch to active form: it will display the menu and put
the mouse pointer on the first menu item. I can then
drag the mouse and select a menu item, or I can drag off
the menu to choose nothing. When I release the mouse
button, if the mouse is over a menu item, there's some
visual feedback, and the appropriate lua closure is
invoked. Then, the menu goes back to minimized state.
You must implement all of this using a combination of lua
and blueprint-language. No C++. You can use the UE
Wingman plugin to edit blueprints.
Along the way, it is possible that the UE Wingman plugin may
fail - it's still in beta. If so, please pause, notify me,
and you and I will work together to get things up and
running again.

View File

@@ -33,10 +33,10 @@ function moveto(x, y)
tangible.animate{tan=actor, anim={action="moveto", xyz={x, y, z}, facing=math.auto}}
end
function cube.lookhotkeys(add)
add("Z", "Cube Hi", function () dprint("Doing Cube Hi") end)
add("X", "Cube Bye", function () dprint("Doing Cube Bye") end)
add("C", "Cube Yo", function () dprint("Doing Cube Yo") end)
function cube.lookmenu(add)
add("Cube Hi", function () dprint("Doing Cube Hi") end)
add("Cube Bye", function () dprint("Doing Cube Bye") end)
add("Cube Yo", function () dprint("Doing Cube Yo") end)
end
function sphere.lookhotkeys(add)
@@ -60,6 +60,12 @@ function engio.getlookat()
return "hotkeys"
end
-- if the class has a function 'lookmenu', then the correct
-- look-at widget is 'menu'.
if class.lookmenu ~= nil then
return "menu"
end
-- otherwise, if the class has a function 'getlookat', use that.
if class.getlookat ~= nil then
return class.getlookat()

68
luprex/lua/menu.lua Normal file
View File

@@ -0,0 +1,68 @@
----------------------------------------------------------------
--
-- To add a menu to an object (such as a Brick Oven), you will
-- be adding a function 'lookmenu' to the appropriate class,
-- like this:
--
-- function brickoven.lookmenu(add)
-- add("Light Oven", function () ... end)
-- add("Add Fuel", function () ... end)
-- end
--
-- This function will get called twice: once in a 'probe' when
-- Unreal wants to know what menu items exist, and a second time
-- in an 'invoke' to find the right closure. The 'add' function
-- which is passed in can therefore be one of two functions.
--
-- In probe mode, the goal is to build up an array that looks
-- like this:
--
-- {"Light Oven", "Add Fuel"}
--
-- So therefore, in probe mode, the 'add' function is a closure
-- that adds the label to the array.
--
-- In invoke mode, the goal is to find the right closure. So
-- therefore, in invoke mode, the 'add' function is a closure
-- that compares the label to the menu item which was already
-- selected. If there's a match, it records the closure.
--
----------------------------------------------------------------
makeclass('engio')
function engio.getmenu()
local class = tangible.getclass(place)
-- if the tangible doesn't have a 'lookmenu' function, do nothing
if class == nil or class.lookmenu == nil then
return {}
end
local items = {}
local add = function(label, closure)
table.insert(items, label)
end
class.lookmenu(add)
return items
end
function engio.pressmenu(label)
local class = tangible.getclass(place)
-- if the tangible doesn't have a 'lookmenu' function, do nothing
if class == nil or class.lookmenu == nil then
return
end
local result = nil
local add = function(lbl, closure)
if (lbl == label) then
result = closure
end
end
class.lookmenu(add)
if result ~= nil then
result()
end
end