space component short name

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

space component short name

Post by Phipsz »

I was wondering if it is possible to get the shortname of a space component via ai/md. In lua, you could use <GetComponentData(spaceid, "mapshortname")> to get it, but I would like to have this information in an md script. is there a way I do not see?
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans »

Haven't stumbled upon any references in the ai and md scripts, nor in scriptproperties. Seems like something that's generated in the UI code. Have you or Yorrick found a more-or-less reliable way to retrieve stuff that's in lua into the xml scripts?
Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz »

Only thing I have found so far would be to create a menu whose onShow function would consist only of filling variables with values and then to pass these as parameters to a new section. It's a workaround, but sadly this is a bit limited, as it e.g. will not quite work if a menu is already open. I have not tried the <raise_lua_event> bit, but as I understand them, they only work if a menu is already shown to alter data shown.
User avatar
Marvin Martian
Posts: 3614
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian »

the shortname isn't generated, simply defined
shortvariation="{20007,xxxx}"

it seems we need beside of .name and sometimes .knownname now .shortname

same for factions, i also not seen anything at scriptproperties to get shortname="{20203,xxxx}"
Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz »

yes, I have found the readtext values as well, but It would be quite ungeneric to just list them all myself (or not really possible for zones), especially since they are defined as "properties/map/@shortvariation" in the clusters/sectors macro definitions, or the "properties/map/@index" for zones respectively (I think). It would be great if we could have more of the options from GetComponentData in md/ai as well. Although, for the short term I would be happy with just the shortvariations retrievable from md/ai :)

edit: I think it could also be nice to have lua as some kind of "library" in md so we can just call it to use the lua-specific functions and return data to the md script.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

Phipsz wrote:yes, I have found the readtext values as well, but It would be quite ungeneric to just list them all myself (or not really possible for zones), especially since they are defined as "properties/map/@shortvariation" in the clusters/sectors macro definitions, or the "properties/map/@index" for zones respectively (I think). It would be great if we could have more of the options from GetComponentData in md/ai as well. Although, for the short term I would be happy with just the shortvariations retrievable from md/ai :)
@shortvariation can also apply to Zones and would be preffered over @index if set - in vanilla this feature is unused though..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz »

can @shortvariation be accessed from md though? scriptproperties says nothing about that sadly...
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

Phipsz wrote:can @shortvariation be accessed from md though? scriptproperties says nothing about that sadly...
Scriptproperties.html also applies to md-scropts, in fact there are a few exclusive for md - and gettimg this value would make most sense as property, not as command.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Phipsz
Posts: 335
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz »

UniTrader wrote:
Phipsz wrote:can @shortvariation be accessed from md though? scriptproperties says nothing about that sadly...
Scriptproperties.html also applies to md-scropts, in fact there are a few exclusive for md - and gettimg this value would make most sense as property, not as command.
I know scriptproperties applies to md/ai and not ui. what I meant was: scriptproperties gives no information about if the shortvariation can be accessed. say, I have a variable "$cluster" holding a clusterid. can I access the shortvariation of the cluster with any property? I tried $cluster.shortname, $cluster.shortvariation, $cluster.macro.shortname, $cluster.macro.shortvariation, $cluster.macro.property.*, $cluster.macro.map.*, $cluster.map.* and $cluster.property.* with none of them resolving.


EDIT: OK, I got it working now with RegisterEvent in lua and raise_lua_event. the code for the "menu" is actually really simple:

Code: Select all

local blackboardEntity = nil

local function get_map_shortname(space)
  return GetComponentData(space, 'mapshortname')
end

local function event_handler(_, space)
  local names = GetNPCBlackboard(blackboardEntity, "$phipsz_map_short_names") or {}
  names[ConvertStringToLuaID(space)] = get_map_shortname(space)
  SetNPCBlackboard(blackboardEntity, "$phipsz_map_short_names", names)
  return
end

local function entity_setter(_, entity)
  blackboardEntity = entity
  return
end

local function init()
	RegisterEvent("phipszGetMapShortname", event_handler)
	RegisterEvent("phipszSetRenameEntity", entity_setter)
	
	return
end

init()

return
in md, I first call <raise_lua_event name="'phipszSetRenameEntity'" param="$entity"/> and afterwards <raise_lua_event name="'phipszGetMapShortname'" param="$space"/>
next, I use signal_cue_instantly with param="$space" so I can get access to the shortname that has been stored in the table of the entity blackboard. thanks for all your help here :thumb_up: even if I could make what I wanted I still would favour the shortname as an attribute of any space type :)

Return to “X Rebirth - Scripts and Modding”