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".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.
UI modding - support thread
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
Thanks for the informationstefanEgo 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/ ... rted+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):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-103Code: Select all
component.{$ID}
I have modified my script a bit to incorporate a ConvertStringToLuaID(eventparam) which seems to get it into the right format
Code: Select all
-- 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()
[=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
Mod pseudo code
Code: Select all
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: Select all
<start_conversation actor="$Architect" conversation="st_struct_rebuild"/>
<raise_lua_event name="'cArch_deployatstation'" param="$playerstation"/>
[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
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
Regards
jth
@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?
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
Uniquely identifying a production module within a station
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
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
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: Select all
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
[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
Didn't spot those parameters yesterdaystefanEgo wrote:@jth: Take a look at GetComponentData() with the properties "sequence" and "stage". That might be what you are looking for.
It is certainly a bit shorter and simpler than my effort. Have added something to take care of [a,0]
Code: Select all
local sequence, stage = GetComponentData(component, "sequence", "stage")
if sequence == "" then
sequence = "a"
end
DebugError("BuildStage [" .. sequence .. "," .. stage .. "]")
jth
How do I remove a specific entry from a BlackBoard table in lua
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
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
Re: How do I remove a specific entry from a BlackBoard table in lua
it should bejth 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
Code: Select all
table.remove($manager.$ProdData, index)
Code: Select all
$manager.$ProdData[module] = nil
Re: How do I remove a specific entry from a BlackBoard table in lua
Thanks will give it a tryPhipsz wrote:it should beor, if the table is key-basedCode: Select all
table.remove($manager.$ProdData, index)
with index(integer) and module of course being variables containing the respective contentCode: Select all
$manager.$ProdData[module] = nil
jth
Extending the menu-production screen
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
and changed
to
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
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
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: Select all
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)
Code: Select all
-- create tableview
menu.infotable, menu.selecttable = Helper.displayTwoTableView(menu, infodesc, selectdesc, false)
Code: Select all
-- create tableview
menu.infotable, menu.selecttable, menu.slider = Helper.displayTwoTableSliderView(menu, infodesc, selectdesc, sliderdesc, true)
[=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
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
@jth:
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.
Code: Select all
Helper.createSlider(sliderinfo, scale1info, scale2info, 1, Helper.sliderOffsetx, 443)
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
Thanks for that explanation.stefanEgo wrote:@jth: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.Code: Select all
Helper.createSlider(sliderinfo, scale1info, scale2info, 1, Helper.sliderOffsetx, 443)
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.
That got me a slider at the bottom of the page
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
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
Slider documentation
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
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
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 ?
I found most of the following in menu_build_upgrades_slider.lua and have tweaked it a bit
Code: Select all
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
}
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: Select all
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"] = "%"
}
and my code produces 0% - 100%. So that answers my scaling question
left, right, inverted ?
@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:
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: Select all
["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
Thanks for the documentation on scale1info
How do I get around the problem ?
Is there a way to get the slider to sit at the end of the table and scroll down with it ?
jth
EDIT 03/02/2016
I have pretty much got a plan B production limiting configuration menu working that is based upon menu_encyclopediaproductionmethod with a slider tacked on the bottom and a lot of stuff borrowed from menu_production.
Its triggered from my modified menu_production menu
Its just difficult to keep it all on one screen with no scrolling
That explains what is happening, thanksstefanEgo wrote:@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".
How do I get around the problem ?
Is there a way to get the slider to sit at the end of the table and scroll down with it ?
jth
EDIT 03/02/2016
I have pretty much got a plan B production limiting configuration menu working that is based upon menu_encyclopediaproductionmethod with a slider tacked on the bottom and a lot of stuff borrowed from menu_production.
Its triggered from my modified menu_production menu
Its just difficult to keep it all on one screen with no scrolling
Last edited by jth on Wed, 3. Feb 16, 13:58, edited 1 time in total.
Wiping a BlackBoard entry
I would like to completely delete a BlackBoard variable in lua as it causing me grief in md script plus its cluttering up the manager object un-necessarily
<do_if value="@$Manager.$TestVar"> remains true even if $TestVar is empty
but there is no RemoveNPCBlackboard or DeleteNPCBlackboard command
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
I then tried
SetNPCBlackboard(menu.manager, "$TestVar", "")
which gives
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
[General] ======================================
[=ERROR=] Read back nil 0
[General] ======================================
which means that it blanked it but it still exists and has zero entries
how do I do it ?
jth
EDIT
I have manged to recreate a work around in md script that detects missing or empty list
<do_if value="$Manager.$TestVar? and $Manager.$TestVar != '' ">
which keeps me going but my save games could do with an answer on completely deleting variables from the BlackBoard please
EDIT2
The lua code is having the same problem as the md code where its interpreting an empty table variable from the BlackBoard as an empty string so had to code round that too. Yuck
<do_if value="@$Manager.$TestVar"> remains true even if $TestVar is empty
but there is no RemoveNPCBlackboard or DeleteNPCBlackboard command
Code: Select all
local testtable = {}
table.insert(testtable, "dummydata")
SetNPCBlackboard(menu.manager, "$TestVar", testtable)
local readbacktable = GetNPCBlackboard(menu.manager, "$TestVar")
DebugError("Read back " .. tostring(readbacktable[1]) .. " " .. #readbacktable)
SetNPCBlackboard(menu.manager, "$TestVar", nil)
readbacktable = GetNPCBlackboard(menu.manager, "$TestVar")
DebugError("Read back " .. tostring(readbacktable[1]) .. " " .. #readbacktable)
[=ERROR=] Read back dummydata 1
[General] ======================================
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
I then tried
SetNPCBlackboard(menu.manager, "$TestVar", "")
which gives
[General] ======================================
[=ERROR=] Read back dummydata 1
[General] ======================================
[General] ======================================
[=ERROR=] Read back nil 0
[General] ======================================
which means that it blanked it but it still exists and has zero entries
how do I do it ?
jth
EDIT
I have manged to recreate a work around in md script that detects missing or empty list
<do_if value="$Manager.$TestVar? and $Manager.$TestVar != '' ">
which keeps me going but my save games could do with an answer on completely deleting variables from the BlackBoard please
EDIT2
The lua code is having the same problem as the md code where its interpreting an empty table variable from the BlackBoard as an empty string so had to code round that too. Yuck
stefanEgo wrote:@jth: 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: Select all
["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
Code: Select all
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"] = false,
["suffix"] = "%"
Turns out that my code works but not how I thought it did
The scale2info gets me a number to the immediate right of the slider that goes from 0 to 100% and displays the slider position nicely on the GUI as a percentage. I don't use the value2 that it produces.
I am actually using value1 which isn't scaled to feed into my code as that lets me control the rounding.
The following may be an enhancement request
The displayed scale2info value shows up as a single number with no decimal point. Is there any way to format its output ?
Being able to show two (or more) digits after a decimal point with no lagging zeros would be ideal for me.
Example
foodstuffs. smallest primary resource is meat and each batch uses 40. That means that I configure the slider to have 40 possible positions (you can't use part of a ware). I then scale that up by 2.5 to get 100% shown in the center by scaleinfo2. value1 goes from 0 to 40. If I move the slider up one so that value1 is 1 then the scale2info center says 3% when it should say 2.5%
EDIT 08/02/2016
The formatting that I would like is the equivalent of string.format("%g", string.format("%1.2f", scale2info_value))
Hope this makes sense
jth
How do I grey out or disable an existing button on the fly ?
I have an OK button created with
I would like to enable and disable it depending on some other logic
I can't find a Helper.disableButton although there is a Helper.updateButtonText
Do I have to Helper.Remove it and then put it back in with
or is there a better way ?
Regards
jth
Code: Select all
Helper.createButton(Helper.createButtonText(ReadText(1001, 14), "center", Helper.standardFont, Helper.standardFontSize, 255, 255, 255, 100), nil, false, true)
I can't find a Helper.disableButton although there is a Helper.updateButtonText
Do I have to Helper.Remove it and then put it back in with
Code: Select all
Helper.createButton(Helper.createButtonText(ReadText(1001, 14), "center", Helper.standardFont, Helper.standardFontSize, 255, 255, 255, 100), nil, false, false)
Regards
jth
RoundTotalTradePrice documentation
This call appears in a lot of 4.00 lua scripts
I also seem to have a lot of my scripts having numbers in them that are 100 times too large in 4.00
I have a feeling that it lines up with everything being priced in centicredits
RoundTotalTradePrice is not in the Lua function overview or the helper.lua files
I assume that it rounds down numbers to the nearest Credit
Whats the syntax ?
What build number/release did it first appear in ?
Regards
jth
I also seem to have a lot of my scripts having numbers in them that are 100 times too large in 4.00
I have a feeling that it lines up with everything being priced in centicredits
RoundTotalTradePrice is not in the Lua function overview or the helper.lua files
I assume that it rounds down numbers to the nearest Credit
Whats the syntax ?
What build number/release did it first appear in ?
Regards
jth