I'm thinking it should be possible, probably using metatables, to expand the item_1 and item_2 commands and include item_3 and even item_4, for when more items are needed. But I'm wondering, does modifying the metatable of existing functions expand them or overwrite them? For example, would the code below work? If not, I could create a custom function similar to each of the built-in ones for each of the item slot functions.
local game_metatable = sol.main.get_metatable("game")
function game_metatable:get_item_assigned(slot)
if slot == 2 then
return game:get_value("slot_2_item")
elseif slot == 3 then
return game:get_value("slot_3_item")
end
end
I'm also not 100% sure how the button mapping part would work. Is game:get/set_command_keyboard_binding() expandable or configurable?
Just brainstorming and wanted others' thoughts...
It overwrites the built-in function. But you can still access the old one if you want, for example like this:
local game_metatable = sol.main.get_metatable("game")
local engine_get_item_assigned = game_metatable.get_item_assigned
function game_metatable:get_item_assigned(slot)
if slot <= 2 then
return engine_get_item_assigned(game, slot)
elseif slot == 3 then
return game:get_value("slot_3_item")
end
end
game:get/set_command_keyboard_binding() is not configurable. You need to store the additional commands yourself. It is not too hard, I did it in Zelda Roth SE where there are several additional commands and these commands are also configurable.
That's exactly what I needed to know - thanks!