TheRealBix wrote:Thanks a lot teacher !
My last question (I swear ^^) would be : how to call a cue through a lua shortcut ?
I'm not certain that you can directly trigger an MD cue from within a piece of Lua code. All MD scripts seem to be triggered from the return parameters of the Lua script.
Remember though that you can have MD scripts that trigger on a generic stub and then add a suffix to this stub which the MD cue can interrogate and execute statements conditionally. Probably easier to explain with a bit of code:
Code: Select all
<cue name="SectionHandler_MT_WarpPlayer" instantiate="false" namespace="this">
<conditions>
<check_any>
<event_conversation_next_section sectionprefix="gMT_tools_WarpPlayerShip" />
<event_conversation_returned_to_section sectionprefix="gMT_tools_WarpPlayerShip" />
</check_any>
</conditions>
<actions>
<do_if value="event.param == 'gMT_tools_WarpPlayerShip'">
<open_conversation_menu menu="MapMenu" param="[0, 0, 'sector', player.primaryship.sector, null, null, 'selectzone', ['gMT_tools_WarpPlayerShip_zoneselected']]" />
<add_conversation_view view="closeupdetailmonitor" />
<debug_text text="'MT MOD TOOLS: Next section: ' + event.param + ' ' + event.param2" />
</do_if>
<do_elseif value="event.param == 'gMT_tools_WarpPlayerShip_zoneselected'">
<debug_text text="'MT MOD TOOLS: Next section: ' + event.param + ' ' + event.param2" />
<debug_text text="'MT MOD TOOLS: WE HAVE SUCCESSFULLY CALLED THE NEXT SECTION:'" />
<debug_text text="'MT MOD TOOLS: The zone selected was: ' + event.param2.{3}.name" />
<speak actor="player.entity" priority="0">
<text line="103081" comment="[Ren]: I'm getting us out of here!" />
</speak>
<warp object="player.primaryship" zone="event.param2.{3}" />
</do_elseif>
<reset_cue cue="this" />
</actions>
</cue>
This is an exerpt from a little tool I wrote to allow me to insta-warp anywhere in the galaxy. The menu (Lua) entry looks like:
Code: Select all
{
section = "gMT_tools_WarpPlayerShip",
icon = "engineer_active",
name = "Warp Player to new location",
condition = true,
sectionparam = { 0, 0 },
info = "Experimental - use with caution!"
},
Note here that I am passing the value to be returned into the holomap lua code (took me a good while to figure that one out
)
So the menu entry triggers the script to open up the holomap - the script then resets ready to handle the return param from the holomap. Once a zone is selected the cue returns with 'gMT_tools_WarpPlayerShip_zoneselected' and executes the second conditional branch that actually does the warping. Note here that I could have maybe just as easily signalled another MD script to fire which would probably achieve what you're trying to do.
The final trick I have used which may help is that you can easily trigger a dummy menu from the MD code if you want to do something in Lua that you can't do in XML/MD scripting. As a trivial example here's some code that executes a Lua "schedulereloadui()" command from the menu bar:
Code: Select all
{
section = "gMT_tools_ReloadUI",
icon = "engineer_active",
name = "Reload User Interface",
condition = true,
sectionparam = { 0, 0 },
info = "Experimental - use with caution!"
},
and the associated MD script excerpt:
Code: Select all
<cue name="SectionHandler_MT_ReloadUI" instantiate="false" namespace="this">
<conditions>
<check_any>
<event_conversation_next_section sectionprefix="gMT_tools_ReloadUI" />
<event_conversation_returned_to_section sectionprefix="gMT_tools_ReloadUI" />
</check_any>
</conditions>
<actions>
<speak actor="player.computer" priority="0">
<text line="131" comment="[Betty]: Affirmitive" />
</speak>
<open_conversation_menu menu="gMT_ReloadUI"/>
<!-- Reset our cue for the next time -->
<reset_cue cue="this" />
</actions>
</cue>
And finally the dummy Lua script that executes to reset the UI:
Code: Select all
-- Schedule a reload of the UI
-- Set up the default menu table
local menu = {
name = "gMT_ReloadUI",
}
-- Standard menu initialiser - initialise variables global to this menu here if needed
local function init()
Menus = Menus or {}
table.insert(Menus, menu)
if Helper then
Helper.registerMenu(menu)
end
return
end
-- Standard Menu cleanup utility - place all variables no longer needed in here and assign the value nil to them
menu.cleanup = function ()
return
end
-- Simply exit the menu and schedule a reload of the UI
menu.onShowMenu = function ()
Helper.closeMenuAndCancel(menu)
menu.cleanup()
ScheduleReloadUI()
return
end
init()
return
Hope this helps - I'm not near the game just now and been so busy at work that I did this stuff quite a while ago so it's a bit rusty inside my old brain!
Cheers
Wysi