EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
UI modding - support thread
Post new topic Reply to topic Goto page Previous  1, 2, 3 ... 11, 12, 13, 14  Next
View previous topic :: View next topic
Author Message
KlausM
EGOSOFT
EGOSOFT



Joined: 06 Nov 2002
Posts: 554 on topic

Thank you for registering your game
PostPosted: Tue, 5. Jan 16, 16:59    Post subject: Reply with quote Print

bm01 wrote:
My v361 folder is a copy of my base folder (with minor changes), but without contents.xml and ui.xml. I haven't tried to add ui.xml to v361/ because I don't think that's what we're supposed to do, but maybe I'm wrong.


The ui.xml has to be in the v361 folder as well, that should fix your problem. The catalog tool detects that the ui.xml is present in the root folder but missing in v361, so it adds the 0-byte file, which marks it as "deleted".

Back to top
View user's profile Send private message
bm01





Joined: 22 Jul 2009
Posts: 417 on topic

Thank you for registering your game
PostPosted: Wed, 6. Jan 16, 13:22    Post subject: Reply with quote Print

It worked. I should have tested that before posting, sorry!


_________________
Automated Emergency Jump - X Rebirth
Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Tue, 19. Jan 16, 15:13    Post subject: Reply with quote Print

stefanEgo wrote:
@jth: Glad you found out the details about how to use the interface between Lua and MD already. We are aware that the provided interface is quite limited and would like to improve that at some point. Unfortunately, this is not as simple as it might sound. I've added a feature request for you to extend the interface to also allow passing on tables as a parameter which I believe should cover your requirements, no? http://www.egosoft.com:8282/jira/browse/XRUIMOD-102
For the time being serializing the parameters, as you already pointed out, is one way to work around this limitation.

@jth: Regarding the script error you get: What's going on behind the scene here is related to how components (or rather componentIDs) are handled in the UI and MD. See the section about FFI IDs and Lua IDs here: http://www.egosoft.com:8292/confluence/display/XRWIKI/Getting+started+guide
In your case you pass the eventparam to Helper.closeMenuForSubSection. That parameter is then converted (recursively for tables) to a plain integer (see helper.lua Helper.closeMenuForSubSection() and Helper.convertComponentIDs()). Hence when passed back to MD you lost the data type infomration that the ID is actually a component. Therefore in MD you have to tell that the provided "integer" is actually a component and create a componentID again as in (pseudo code):
Code:

component.{$ID}

Again, this limitation is something we'd like to remove at some point to simplify UI modding further. I've added a corresponding JIRA issue for that one now: http://www.egosoft.com:8282/jira/browse/XRUIMOD-103


Thanks for the information

I have modified my script a bit to incorporate a ConvertStringToLuaID(eventparam) which seems to get it into the right format

Code:
-- Auto answer for structural rebuild conversations
local utf8 = require("utf8")

local menu = {
   name = "STRebuildConversationControl"
}

local function init()
   Menus = Menus or { }
   table.insert(Menus, menu)
   if Helper then
      Helper.registerMenu(menu)
   end
   RegisterEvent("cArch_deployatstation", menu.cArch_deployatstation)
end

function menu.cArch_deployatstation(eventname, eventparam)
   DebugError(eventname .. " - " .. GetComponentData(eventparam, "name") .. " " .. string.format("0x%x", eventparam))
   Helper.closeMenuForSubSection(menu, false, eventname, { 0, 0, ConvertStringToLuaID(eventparam)})
   menu.cleanup()
end

function menu.cleanup()
end

init()


If I run it then I get

[=ERROR=] cArch_deployatstation - Foodstuffs Supply I 0x1c50f
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'

but it does trigger the call into the Architect script

[Scripts] *** Context:md.NPC_Architect.SectionHandler<inst:1d6db>: <event_conversation_next_section> section: 'cArch_deployatstation'
[Scripts] *** Context:md.NPC_Architect.SectionHandler<inst:1d6db>: [0LF,0LF,component.{0x1c50fL}]

and the CV dutifully deploys to the station

.... however if I then re-run the whole mod again on the same station then it does something very strange Sad

Mod pseudo code
Code:
Build a new station on the same spot
Clone the station structure
Calculate the difference in cost betwen the new and old stations

Ask if you want to procede

If Yes
Move the NPC's over
Rename the new station
Delete the old station
Recreate the Architect on the original CV
Deploy to station  -- this is where the lua comes in


Code:
              <start_conversation actor="$Architect" conversation="st_struct_rebuild"/>
              <raise_lua_event name="'cArch_deployatstation'" param="$playerstation"/>


[=ERROR=] cArch_deployatstation - aOld Foodstuffs Supply I 0x33bce
[General] ======================================
[General] ======================================
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'
[=ERROR=] cArch_deployatstation - aOld Foodstuffs Supply I 0x33bce
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'

What it is doing is re-running the second half of the md script. There are some debug_text commands in there and I get two complete sets of debug comments for the second half

I can also actually hear the beep beep of it opening two conversations

Unfortunately the two instances of the second half of the script interfere with each other and the CV fails to "Deploy to station" the second time Sad

I think that it may be something to do with Helper.closeMenuForSubSection which may be going back to the "Ask if you want to procede" and running it again

I have a feeling that there is something in the functions that closeMenuForSubSection calls that is generating the two lines

[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'
[=ERROR=] Invalid call to UnregisterEvent(). Given script function must be a function but is 'nil'

What I really need it to do is a bare bones closeMenuForSubSection and do not return back anywhere

I have had a look at the other possibilities in helper.lua but don't really know what to do

Help Smile

Regards

jth

Back to top
View user's profile Send private message
stefanEgo
EGOSOFT
EGOSOFT



Joined: 11 Apr 2013
Posts: 438 on topic

Thank you for registering your game
PostPosted: Wed, 20. Jan 16, 16:51    Post subject: Reply with quote Print

@jth: From the looks at the presented code, everything seems right. Guessing, the two UnregisterEvent() errors you get are related to the code in helper.lua: clearMenu() (which is triggered by ur call to Helper.closeMenuForSubSection()).

These two UnregisterEvent() calls are unregistering event callbacks which are registered by your call to Helper.registerMenu() so that part seems to be fine at first glimpse.

All I could imagine is that for whatever reason in ur case Helper is nil (you can check that by adding some output there). In this case you would register a callback (cArch_deployatstation) which then triggers the UnregisterEvent-calls without the corresponding events having been registered first and (what would trigger the error) the actual callback functions not having been defined.

What causes that, I cannot determine by the provided code here.

Maybe that info helps you to trace the problem down a bit?

If not, maybe you can provide a sample addon which I could test directly?


_________________
Stefan Hett, UI Engine Architect
Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Thu, 21. Jan 16, 15:09    Post subject: Uniquely identifying a production module within a station Reply with quote Print

I am working on some code to put a throttle on production modules

The heavy lifting needs to be done in lua code

I am intending to replace the menu_production code with a customised version.

menu_production gets passed two parameters, the station and the production module

A lot of stations have more than one production line of the same type.

In a FoodStuffs Supply I need to be able to identify which Valley forge is which. So that I can adjust the throttle later, on the right one.

Obviously I cannot use objectID as they change every time the game is reloaded.

Is it possible to get the build stage of a particular production module or find a couple of parameters that combined together uniquely identify a specfic production module within a station ?

It needs to be valid over save games and survive the player extending the station ....

jth
EDIT 18:40

Put together some code borrowed heavily from menu_buildtree.lua that goes through the station buildtree and finds the buildstage for each production module
Code:
   DebugError("Station is " .. GetComponentData(menu.object, "name"))
   DebugError("Module is " .. GetComponentData(menu.module, "name"))

   DebugError("Module " .. tostring(menu.module))
   menu.buildtree = GetBuildTree(menu.object)
   table.sort(menu.buildtree, function (a, b) return a.name < b.name end)
   for seqidx, seqdata in ipairs(menu.buildtree) do
      if seqdata.sequence == "a" then
         modules = GetBuildStageModules(menu.object, "", 0)
         for _, module in ipairs(modules) do
            if module.library == "moduletypes_production" then
               DebugError("[a,0] " .. module.name .. " " .. tostring(module.component))
            end
         end
      end
      for stageidx, stagedata in ipairs(seqdata) do
         if stagedata.stage <= seqdata.currentstage or menu.task == "building" then
            DebugError("[" .. seqdata.sequence .. "," .. stagedata.stage .. "] " .. stagedata.name .. " " .. tostring(stagedata.primarycomponent))
         end
      end
   end


results

[General] ======================================
[=ERROR=] Station is Foodstuffs Supply I
[General] ======================================
[General] ======================================
[=ERROR=] Module is Liquor Still
[General] ======================================
[General] ======================================
[=ERROR=] Module ID: 16881844
[General] ======================================
[General] ======================================
[=ERROR=] [a,0] Foodstuff Fac ID: 16819627
[General] ======================================
[General] ======================================
[=ERROR=] [a,1] Foodstuff Fac ID: 16878931
[General] ======================================
[General] ======================================
[=ERROR=] [b,1] Valley Forge ID: 16819617
[General] ======================================
[General] ======================================
[=ERROR=] [b,2] Valley Forge ID: 16879060
[General] ======================================
[General] ======================================
[=ERROR=] [c,1] Liquor Still ID: 16881844
[General] ======================================
[General] ======================================
[=ERROR=] [d,1] Argnu Paradise ID: 16879153
[General] ======================================
[General] ======================================
[=ERROR=] [e,1] Spice Tubes ID: 16803969
[General] ======================================
[General] ======================================
[=ERROR=] [f,1] Container Storage ID: 16882068
[General] ======================================

A good days work Smile

Back to top
View user's profile Send private message
stefanEgo
EGOSOFT
EGOSOFT



Joined: 11 Apr 2013
Posts: 438 on topic

Thank you for registering your game
PostPosted: Fri, 22. Jan 16, 13:37    Post subject: Reply with quote Print

@jth: Take a look at GetComponentData() with the properties "sequence" and "stage". That might be what you are looking for.


_________________
Stefan Hett, UI Engine Architect
Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Fri, 22. Jan 16, 19:18    Post subject: Reply with quote Print

stefanEgo wrote:
@jth: Take a look at GetComponentData() with the properties "sequence" and "stage". That might be what you are looking for.


Didn't spot those parameters yesterday Sad

It is certainly a bit shorter and simpler than my effort. Have added something to take care of [a,0]

Code:
   local sequence, stage = GetComponentData(component, "sequence", "stage")
   if sequence == "" then
      sequence = "a"
   end
   DebugError("BuildStage [" .. sequence .. "," .. stage .. "]")


Thanks

jth

Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Tue, 26. Jan 16, 17:39    Post subject: How do I remove a specific entry from a BlackBoard table in lua Reply with quote Print

I am storing a list of production modules on the manager's Blackboard in a lua script

Its using $manager.$ProdData as a table and storing each production module as a sub table

I want to remove one of them

how do I do that in lua ?

Do I read $ProdData into a temp table, delete the specific entry and then save the amended table back onto the BlackBoard ?

or is there a simpler way to do it ?

Thanks

jth

Back to top
View user's profile Send private message
Phipsz





Joined: 23 Apr 2012
Posts: 200 on topic

Thank you for registering your game
PostPosted: Wed, 27. Jan 16, 03:04    Post subject: Re: How do I remove a specific entry from a BlackBoard table in lua Reply with quote Print

jth wrote:
I am storing a list of production modules on the manager's Blackboard in a lua script

Its using $manager.$ProdData as a table and storing each production module as a sub table

I want to remove one of them

how do I do that in lua ?

Do I read $ProdData into a temp table, delete the specific entry and then save the amended table back onto the BlackBoard ?

or is there a simpler way to do it ?

Thanks

jth


it should be
Code:
table.remove($manager.$ProdData, index)

or, if the table is key-based
Code:
$manager.$ProdData[module] = nil

with index(integer) and module of course being variables containing the respective content

Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Wed, 27. Jan 16, 20:02    Post subject: Re: How do I remove a specific entry from a BlackBoard table in lua Reply with quote Print

Phipsz wrote:
it should be
Code:
table.remove($manager.$ProdData, index)

or, if the table is key-based
Code:
$manager.$ProdData[module] = nil

with index(integer) and module of course being variables containing the respective content


Thanks will give it a try

jth

Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Thu, 28. Jan 16, 17:39    Post subject: Extending the menu-production screen Reply with quote Print

I need to add some extra functionality into menu-production to support my station production throttling mod

I was initially thinking of a slider at the bottom

For most production modules a single slider is all that is needed but for the Missile and Turret Forges I need to show all the possible products and be able to select and use a slider on each of them.

This could possibly be done by switching from a TwoTableView to a TwoTableSliderView. I have attempted to bolt bits of menu_build_production_slider in but without much luck

I added in

Code:
   local sliderinfo = {
      ["background"] = "tradesellbuy_blur",
      ["captionLeft"] = "",
      ["captionCenter"] = "",
      ["captionRight"] = "",
      ["min"] = 0,
      ["minSelectable"] = 0,
      ["max"] = 100,
      ["zero"] = 0,
      ["start"] = 50
   }
   local scale1info = {
      ["left"] = nil,
      ["right"] = nil,
      ["center"] = false,
      ["inverted"] = false,
      ["suffix"] = nil
   }
   local scale2info = {
      ["left"] = nil,
      ["right"] = nil,
      ["center"] = false,
      ["factor"] = nil,
      ["inverted"] = true,
      ["suffix"] = nil
   }
   local sliderdesc = Helper.createSlider(sliderinfo, scale1info, scale2info, 1, Helper.sliderOffsetx, 443)


and changed
Code:
   -- create tableview
   menu.infotable, menu.selecttable = Helper.displayTwoTableView(menu, infodesc, selectdesc, false)

to
Code:
   -- create tableview
   menu.infotable, menu.selecttable, menu.slider = Helper.displayTwoTableSliderView(menu, infodesc, selectdesc, sliderdesc, true)


and got the following

[=ERROR=] CWidgetController::SetUpView() - Validation error: 'Script error: 'Invalid tab orders. Tab orders must be unique.'

That has me stumped

My alternative thoughts were to turn it into a ThreeTableView and add some buttons at the bottom but that ran into a different hitch. Is there an easy way to convert from a two tableview to a three ?

I was also considering adding a "production module throttling" section and list of all the available products to the bottom of the infotable but with the "encyclopedia" button redirected to a separate slider menu. That might just cover the missile and turret forges.

I don't really know what is the best way to go and as usual am attempting the olympic sprint before being able to walk Smile

Having hit a brick wall with the first two options I may spend some time investigating the third

Any thoughts, documentation (beyond the listings for helper.lua) ?

jth

Back to top
View user's profile Send private message
stefanEgo
EGOSOFT
EGOSOFT



Joined: 11 Apr 2013
Posts: 438 on topic

Thank you for registering your game
PostPosted: Fri, 29. Jan 16, 13:06    Post subject: Reply with quote Print

@jth:
Code:

Helper.createSlider(sliderinfo, scale1info, scale2info, 1, Helper.sliderOffsetx, 443)


Given the error you get, it's likely you created two elements with the same tab order (aka: 1). Simply change the 1 to something else (presumably 3) and the error should be resolved.

I see that the helper.lua file (in ego_fullscreenHelper) is missing the taborder in the comment. I've corrected that locally and the corrected docu is expected to make it in the next build.

Note that the taborder inside a view specifies the order interactive elements can be tabbed through (by pressing the tab key) and therefore each element must have a unique tab order number.


_________________
Stefan Hett, UI Engine Architect
Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Fri, 29. Jan 16, 15:59    Post subject: Reply with quote Print

stefanEgo wrote:
@jth:
Code:

Helper.createSlider(sliderinfo, scale1info, scale2info, 1, Helper.sliderOffsetx, 443)


Given the error you get, it's likely you created two elements with the same tab order (aka: 1). Simply change the 1 to something else (presumably 3) and the error should be resolved.

I see that the helper.lua file (in ego_fullscreenHelper) is missing the taborder in the comment. I've corrected that locally and the corrected docu is expected to make it in the next build.

Note that the taborder inside a view specifies the order interactive elements can be tabbed through (by pressing the tab key) and therefore each element must have a unique tab order number.

Thanks for that explanation.

That got me a slider at the bottom of the page Smile

However the page doesn't have an up down slider on the right hand side any more and I have a lot of stuff on that page Sad

I have had a bit of a play at getting the up down slider back but it looks to get very complicated very fast. It looks like it turns into a complicated geometry problem

Is there any way to simply get the up down slider back or does the TwoTableSliderView not practically allow an up down slider on the right hand side when you have a left right slider at the bottom ?

As a bit of lateral thinking can I add one or more slider(s) as a table entry(s) to a TwoTableView, make the row taller and say pop it\them in as the second column ?

I am trying to get a grip on what is possible\practical and what would need a lot of work by someone that knows what they are doing

jth

Back to top
View user's profile Send private message
jth



MEDAL

Joined: 04 Jan 2006
Posts: 295 on topic
Location: England
Thank you for registering your game
PostPosted: Mon, 1. Feb 16, 13:37    Post subject: Slider documentation Reply with quote Print

I am experimenting with the slider and making some progress but would like to know what some of the parameters do. I have looked in the helper.lua file

I found most of the following in menu_build_upgrades_slider.lua and have tweaked it a bit

Code:
   local sliderinfo = {
      ["background"] = "tradesellbuy_blur",
      ["captionLeft"] = ReadText(1001, 19) .. " " .. ReadText(1001, 1600) .. " (0)",
      ["captionCenter"] = "Production Brake",
      ["captionRight"] = ReadText(1001, 1601) .. " (" .. menu.maxslider .. ")",
      ["min"] = 0,
      ["minSelectable"] = 0,
      ["max"] = menu.maxslider,
      ["zero"] = 0,
      ["start"] = math.floor(menu.prodbrake * menu.maxslider)
   }
   local scale1info = {
      ["left"] = nil,
      ["right"] = nil,
      ["center"] = true,
      ["inverted"] = false,
      ["suffix"] = nil
   }
   local scale2info = {
      ["left"] = nil,
      ["right"] = nil,
      ["center"] = false,
      ["factor"] = nil,
      ["inverted"] = true,
      ["suffix"] = nil
   }

The sliderinfo seems reasonably self documenting

scale1info and scale2info are less obvious. I made a guess on scalinfo1 and set center to true and a number popped up a the right hand side of the slider which is what I was looking for

Is there any way to scale that number ?

Thanks

jth
EDIT
Had a further play and came up with

Code:
   local scale1info = {
      ["left"] = nil,
      ["right"] = nil,
      ["center"] = false,
      ["inverted"] = false,
      ["suffix"] = nil
   }
   local scale2info = {
      ["left"] = nil,
      ["right"] = nil,
      ["center"] = true,
      ["factor"] = (100 / menu.maxslider) or 100,
      ["inverted"] = true,
      ["suffix"] = "%"
   }


It looks like there are two possible numbers that can appear immediately to the right of the slider bar, scale1info controls the first and scale2info the second. If you use both then the second number automatically gets a set of () around it. The second appears to be the most formattable

and my code produces 0% - 100%. So that answers my scaling question

left, right, inverted ?

Back to top
View user's profile Send private message
stefanEgo
EGOSOFT
EGOSOFT



Joined: 11 Apr 2013
Posts: 438 on topic

Thank you for registering your game
PostPosted: Mon, 1. Feb 16, 14:16    Post subject: Reply with quote Print

@jth: The scrollbar will appear on the table, if the table grows too large. If you ensure that the slider is visible, it will never "go out of view".
Adding multiple sliders on a single view is on our list already. No ETA when this will be possible however atm. In theory you could achieve this, but it would require heavy modifications on the widget system.
Regardling the scale1info/scale2info entries: By design a single slider can represent two distinct scales. So by moving the slider, you practically can change two different values. Documentation for the scale1info is as follows:
Code:

["left"]     = number|nil = nil,   -- value displayed on the left side (representing a slider position of 0 - nil => no display)
["right"]    = number|nil = nil,   -- value displayed on the right side (representing a slider position of 0 - nil => no display)
["center"]   = true|false = true,   -- indicates whether the current scale value is to be displayed on the center of the slider
["minLimit"] = number|nil = nil,   -- the minimal value the scale will display, even if the slider indicates a smaller value (nil => no limit)
["maxLimit"] = number|nil = nil,   -- the maximal value the scale will display, even if the slider indicates a larger value (nil => no limit)
["inverted"] = true|false = false,   -- indicates whether left/right behavior is inverted (i.e. if false, value changes will be subtracted on the left side and added to the right side)
["factor"]   = number     = 1,      -- factor which the slider value is multiplied with to set the values
["floored"]  = true|false = true,   -- indicates whether the displayed scale values are floored (true) or ceiled (false)
["suffix"]   = string     = ""      -- suffix which is being printed after the scale values



_________________
Stefan Hett, UI Engine Architect
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic Goto page Previous  1, 2, 3 ... 11, 12, 13, 14  Next
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Control Panel
Login Data
The time now is Thu, 26. Apr 18, 20:59

All times are GMT + 2 Hours


Board Security

Copyright © EGOSOFT 1989-2018
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.16173 seconds, sql queries = 29