minetest.explode_textlist_event

From Minetest Developer Wiki
Jump to: navigation, search

Syntax

minetest.explode_textlist_event(string)


Description

  • Returns a table, e.g. {type="CHG", index=1}
  • type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)

Example

Here is a real-world example with a code snippet from L-System Tree Utility 1.0.0, a mod providing a frontend to manage L-system trees:

local event = minetest.explode_textlist_event(fields.treelist)
if(event.type == "CHG") then
	ltool.playerinfos[playername].dbsel = event.index
	local formspec = ltool.formspec_size..ltool.formspec_header(2)..ltool.tab_database(event.index, playername)
	minetest.show_formspec(playername, "ltool:treeform_database", formspec)

Only the first 3 lines are of interest here. fields.treelist is a formspec element of type “textlist”. minetest.explode_text_list_event is used to fetch an event, in this case, the code checks whenever the user has selected another element in the list. The index is then used later to store it for later use. The last 2 lines are used to update the formspec and send it again to the user. In another part of the mod, the saved index is used to correctly pre-select the entry the user has selected previously when user decides to access this part of the frontend again.

Source: [1]


This article is incomplete.


Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox