Jump to content
Zita

Need a script for contentbrowerhack

Recommended Posts

I was wondering if one of you scripter's might be able to come up with a way to help or write some thing to access a list of the contentbrowserhack.

 

As we all know Dev's will be giving some love to the Map Editor, but that is a bit of a way of atm. So I tried to use the new Multi bind commands with the mousewheelup to see if it could scroll though a list in the bind, but it always executes the whole bind, I asked newborn if there was a way to execute each command singlerly with just one push of a key but the answer is no.

 

Bonuspunk said maybe I could use a script, now I have had a look and since I have not done any programing for around 10 yrs, I'm stuck. He showed me a script for changing crosshairs so looks like what I'm after could be done.

 

So was wondering if one of you, might be able to come up with a way so access a list either from a file or from inside the script so that with mousewheelup it would move one command at a time through the list, once at the end of the list is reached to return to the begining and loop through.

 

Here is most of the commands that would be needed already in a file https://www.dropbox.com/s/nws2yvbqko3c1vv/brush.cfg?dl=0

 

The idea of the script is for people that find sending things through the contentbrowserhack hard or impossable to use just beable to scroll through a list and then paste it stright into the console.

 

anyway hope people think this might be of use, so any feed back would be useful.

Share this post


Link to post
Share on other sites

I have not looked at any of the menu code yet, but would a separate menu with drop-down lists or simply a list of buttons be the way to go? That way they could be given short names and be lay-outed in a nice way? In any case I think hard-coding the list of paths would be the easiest way to go. Just wondering...

 

It's been a long time since I looked into linked lists via binds... IIRC I did that for Quake 2 ages ago... even for Q3A I had some:

set r5 "cg_thirdpersonrange 5;set farther vstr r10;set closer vstr r500"
set r10 "cg_thirdpersonrange 10;set farther vstr r20;set closer vstr r5"
set r20 "cg_thirdpersonrange 20;set farther vstr r30;set closer vstr r10"
...
//bind <key> "vstr closer"   //Closer/Farther away from model
//bind <key> "vstr farther"

but Reflex seems to be missing the set and vstr console commands that would be needed.

Share this post


Link to post
Share on other sites

so, essentially you want mousewheel up/down to set next/prev material from the list you provided?

Bonuspunkt basicly yes, as you scroll through it auto set the material into the console. It's easy to do single ones with the bind ( I think a lot of mapper's do it that way).

 

I have not looked at any of the menu code yet, but would a separate menu with drop-down lists or simply a list of buttons be the way to go? That way they could be given short names and be lay-outed in a nice way? In any case I think hard-coding the list of paths would be the easiest way to go. Just wondering...

 

It's been a long time since I looked into linked lists via binds... IIRC I did that for Quake 2 ages ago... even for Q3A I had some:

set r5 "cg_thirdpersonrange 5;set farther vstr r10;set closer vstr r500"
set r10 "cg_thirdpersonrange 10;set farther vstr r20;set closer vstr r5"
set r20 "cg_thirdpersonrange 20;set farther vstr r30;set closer vstr r10"
...
//bind <key> "vstr closer"   //Closer/Farther away from model
//bind <key> "vstr farther"

but Reflex seems to be missing the set and vstr console commands that would be needed.

That's why I was looking into the new UI scripts to see if it could be done, and hard coding it would be the better way to go, and I already have a file with the file structure set up, It was used for people who could not use the browserhack and they could just copy and paste into console.

Share this post


Link to post
Share on other sites

I think I downloaded you brush.cfg file last year and was using that to help more quickly access entries.

 

Another thing that might help, if implementable, would be to have a 3rd key to toggle between various modes, e.g. lights, textures with grid, textures without, etc..... to reduce the amount of scrolling via mouse wheel.

 

I hope to take a look at the menu lua code... and check if anything can be done there. So far I have only seen HUD-related widget code.

Share this post


Link to post
Share on other sites

<SNIP>

 

(Edited to show later paste on page 2 of working simple scroll list of content)

 

This should make you happier, tossed this all into a scrollable menu, SOME of the content doesn't set to me_activematerial, Because it doesn't belong there anyway. if someone want's to break down that array into correct categories i.e

i'll look into breaking it down into tab's or something and atleast get it setting stuff to the correct CVars.

 

http://pastebin.com/W3jHcsZw

 

it should default bind f9 to show/hide it, and is on the main menu on far right.

use the ingame Cvars to position/scale where ever you want it.

 

ui_set_widget_offset x y

ui_set_widget_scale #

ui_set_widget_anchor x y

Share this post


Link to post
Share on other sites

if you want to build a menu for it, look up the uimenusServerBrowserMenu

and use this

local menuIsPatched = false

__PatchMenu =
{
    canHide = false,

    draw = function()
        if menuIsPatched then return end

        local draw = MenuBar.draw;
        MenuBar.draw = function()
            draw(MenuBar);

            if MenuBar.visibility <= 0 then return end
            if uiMenuBarButton("WIDGETS", 300, -540, 200, 100, 255) then
                setMenuStack("WidgetMenu"); -- MaterialMenu ?
            end
        end

        menuIsPatched = true
    end
};
registerWidget("__PatchMenu");

to add it to the top menu bar

Share this post


Link to post
Share on other sites

if you want to build a menu for it, look up the uimenusServerBrowserMenu

and use this

<SNIP>

to add it to the top menu bar

 

I haven't tried, but can't you just set the menu stack at during load instead of using a draw loop?

Share this post


Link to post
Share on other sites

aliasedfrog,

been testing the code... had to fix a few things, but even then I doubt it could work even in theory, here my present version:

require "base/internal/ui/reflexcore"

-- Add to game.cfg a binding for keyToToggle = "h", e.g.
-- bind me h me_getmaterial internal/dev/red

local keyToToggle = "h"

local contentlist =
{
    "structural/dev/dev_pinkdark",    -- valid! paths...
    "structural/dev/dev_purple",
    "structural/dev/dev_purpledark",
    "structural/dev/dev_red",
    "structural/dev/dev_reddark",
    -- add more entries here
}

contentHack =
{
};
registerWidget("contentHack");

local pos = 0;

function contentHack:draw()
    local player = getPlayer()

    if player.state == PLAYER_STATE_EDITOR then
        if string.find(consoleGetVariable("bind me " .. keyToToggle), contentlist[pos]) ~= 0 then
--      if string.find(consoleGetVariable("me_activematerial"), contentlist[pos]) ~= 0 then
            consolePerformCommand("bind me " .. keyToToggle .. " me_activematerial " .. contentlist[pos + 1]);
            pos = pos + 1;
        end

        nvgFontSize(50);
        nvgFontFace(FONT_HUD);
        nvgTextAlign(NVG_ALIGN_CENTER, NVG_ALIGN_MIDDLE);
        nvgFillColor(Color(255,255,255));
        nvgText(0,50, contentlist[pos]);
     end
end

For one I doubt the local pos, is remembered from widget call to the next. I recently read up certain cases where it is (Function Closure IIRC... and some other strange special cases). Ah... e.g. upvalue counter. I was wrong again, not quite sure why the pos counter works.

 

Next e.g. consoleGetVariable("me_getmaterial") checks the state of console command values... the "bind me h" suggests you are looking up the actual game.cfg file or something. In any case it does not return a string that the find command wants.

 

No idea how the looping is supposed to work... I am guessing the code should check what me_getmaterial is presently set to, check the contentlist until it finds the material, and then set a new binding to "h" so that on the h press the "next" material is set. I.e. the code would continuously loop through the material contentlist.

 

And the command that needs binding is:

bind me h me_activematerial structural/dev/dev_grey64

Should I have understood the idea... I might be able to fix change the code, with some more experimenting. Have not... apparently the consoleGetVariable() does not work... always returns nil.

 

contentlist, did not contain valid test examples... also messed up the widget.

 

 

I think I found the problem:

local a = consoleGetVariable("me_activematerial"); -- fails -> nil
local a = consoleGetVariable("bind");              -- also fails
local a = consoleGetVariable("bind me h");         -- also fails

always return nil because the console commands have NOT been made accessible. "r_resolution" or "cl_crosshair" work and return proper values.

Share this post


Link to post
Share on other sites

if you have problems with triggering next/prev try following hack

local crosshair
local setNextMaterial
local setPrevMaterial

_G.Widget = {
  draw = function()

    local currentCrosshair = consoleGetVariable('cl_crosshair')

    if crosshair == nil then
        crosshair = currentCrosshair
    end
    if currentCrosshair == 888 then
        setNextMaterial = true
    end
    if currentCrosshair == 889 then
        setPrevMaterial = true
    end
    
    if (setNextMaterial) then
      -- set next material
    end
    if (setPrevMaterial) then
      -- set prev matial
    end
    
    if setNextMaterial or setPrevMaterial then
      setNextMaterial = false
      setPrevMaterial = false
      -- reset crosshair
      consolePerformCommand('cl_crosshair ' .. crosshair)
    end

  end
}

triggers when you set your crosshair so

bind mousewheelup cl_crosshair 888
bind mousewheeldown cl_crosshair 889

hth

Share this post


Link to post
Share on other sites

 

 

For one I doubt the local pos, is remembered from widget call to the next. I recently read up certain cases where it is (Function Closure IIRC... and some other strange special cases). Ah... e.g. upvalue counter. I was wrong again, not quite sure why the pos counter works.

 

local pos = 0;

 

in that snippet is local to the lua file, pretty much same as a global value, but only accessible from that .lua file. so it retains between draw calls.

 

 

 

I think I found the problem:

local a = consoleGetVariable("me_activematerial");

always returns nil because the console command has NOT been opened up. "r_resolution" or "cl_crosshair" work and return proper values.

 

 

it's likely returning 'nil' because it's never been set to something to start with, so it's nil by default since nothing has been set as a activematerial, trying manually setting & see if that's get it started, if so you could just set it at load to something random.

 

 

I'll take a quick gander at it when I get home. but I can't think of a reason why it can't work =)

Share this post


Link to post
Share on other sites

 

it's likely returning 'nil' because it's never been set to something to start with, so it's nil by default since nothing has been set as a activematerial, trying manually setting & see if that's get it started, if so you could just set it at load to something random.

 

 

Did manually set it... that was the first thing I tested. Note that I also tried bind me h and that yields info on the console, but not in the script.

 

Bonuspunkt,

taking a look at your code... thanks.

Share this post


Link to post
Share on other sites

wow you guys are awesome, I have no idea what most of the code is but havea basic idea of what your trying to do. I def came to the correct place for help.

 

Thanks guys at giveing this a stab at :)

Share this post


Link to post
Share on other sites

OK, thanks again Bonuspunkt got it to work:

 

Save as contentHack.lua in e.g.  base/internal/ui/widget_custom/

-- Reflexbaseinternaluiwidgets_customcontentHack.lua
--                                        ---------------
require "base/internal/ui/reflexcore"

local contentlist =
{
    "structural/dev/dev_pinkdark",    -- valid! paths...
    "structural/dev/dev_purple",
    "structural/dev/dev_purpledark",
    "structural/dev/dev_red",
    "structural/dev/dev_reddark",
    -- add more entries here
}

local crosshair = consoleGetVariable("cl_crosshair")    -- remember original crosshair
local setNextMaterial
local setPrevMaterial
local pos = 0    -- 0 is the correct initial value, and
                 -- pos value is remembered between widget calls

contentHack =
{
    draw = function()

        local player = getPlayer()
        if player.state == PLAYER_STATE_EDITOR then    -- only do this in editor mode

            local n = table.getn(contentlist);
            local currentCrosshair = consoleGetVariable("cl_crosshair")

            if currentCrosshair == 888 then
                setNextMaterial = true
                pos = pos + 1
                if pos > n then pos = 1 end -- looping array
            end
            if currentCrosshair == 889 then
                setPrevMaterial = true
                pos = pos - 1
                if pos < 1 then pos = n end
            end

            if (setNextMaterial) then    -- set prev material
                consolePerformCommand("me_activematerial " .. contentlist[pos])
            end
            if (setPrevMaterial) then    -- set prev material
                consolePerformCommand("me_activematerial " .. contentlist[pos])
            end

            if setNextMaterial or setPrevMaterial then
                setNextMaterial = false
                setPrevMaterial = false
                -- reset crosshair to original value
                consolePerformCommand("cl_crosshair " .. crosshair)
            end

        end -- end state
    end     -- end function
};

registerWidget("contentHack");

Activate the widget via:

ui_show_widget contentHack

Use the binds in the game.cfg, to switch though the list of materials:

bind me mousewheelup cl_crosshair 888
bind me mousewheeldown cl_crosshair 889

Works nicely, but does get called every frame. The list of materials is not yet complete... I'll do that in a moment.

 

 

Bonuspunkt,

am I correct in understanding that I could put the two

 consolePerformCommand("me_activematerial " .. contentlist[pos])

calls under

if setNextMaterial or setPrevMaterial then

and remove the

            if (setNextMaterial) then    -- set prev material
            if (setPrevMaterial) then    -- set prev material

blocks entirely?

 

I also think that adding a quick out

            local currentCrosshair = consoleGetVariable("cl_crosshair")
            if currentCrosshair < 888 or currentCrosshair > 889 then return end;           

should speed up code execution, since it ignores the rest of the function code.

Share this post


Link to post
Share on other sites

Some more code tweaking, since I am still learning lua specifics:

            local n = table.getn(contentlist);
            local currentCrosshair = consoleGetVariable("cl_crosshair")

            if currentCrosshair == 888 then
                pos = pos + 1
                if pos > n then pos = 1 end -- looping array
            elseif currentCrosshair == 889 then
                pos = pos - 1
                if pos < 1 then pos = n end
            else
              return -- just the normal crosshair number, so skip any changes
            end

            -- Set new material, only executed if a prev/next "call" was made
            consolePerformCommand("me_activematerial " .. contentlist[pos])

            -- reset crosshair to original value
            consolePerformCommand("cl_crosshair " .. crosshair)

This should do the same, not requiring any of the setNextMaterial and setPrevMaterial code. Using the if then elseif else end should also speed up the code slightly. One could probably also put the iteration code into a function that might run even quicker... maybe.

 

Read 1/3 of the lua Reference Manual... still getting to grips with the code though.

Share this post


Link to post
Share on other sites

Update: for a complete contentlist = {} replace it in the above code:

local contentlist =
{
    --Lights
    "structural/industrial/lights/light_flood/light_flood",
    "structural/industrial/lights/light_fluro/light_fluro_twin_64_w",
    "structural/industrial/lights/light_rnd/light_rnd",
    "structural/industrial/lights/light_spot_sml/light_spot_sml",
    "structural/industrial/lights/light_step_sml/light_step_sml",
    "structural/industrial/lights/light_wall/light_wall",
    "structural/industrial/lights/light_wall/light_wall2",
    "structural/industrial/lights/light_wall_rect/light_wall_rect",
    "structural/industrial/lights/light_wall_sml/light_wall_sml",
    
    --Decals
    "structural/decals/decal_dev_logo_reflex",
    
    --LIQUIDS
    --Lava
    "environment/liquids/lava/lava_burn",
    "environment/liquids/lava/lava_enter",
    "environment/liquids/lava/lava_exit",
    "environment/liquids/lava/lava_step",
    "environment/liquids/lava/lava_submerged",
    "environment/liquids/lava/lava_wade",
    
    --Slime
    "environment/liquids/slime/slime",
    
    --Water
    "environment/liquids/water/water_burn",
    "environment/liquids/water/water_enter",
    "environment/liquids/water/water_exit",
    "environment/liquids/water/water_step",
    "environment/liquids/water/water_submerged",
    "environment/liquids/water/water_wade",
    
    --Teleporter
    "internal/world/teleporter/teleporter_frame_L",
    "internal/world/teleporter/teleporter_frame_R",
    "internal/world/teleporter/teleporter_portal",
    
    --MATERIALS
    --NoLight
    "internal/editor/textures/editor_nolight",
    
    --Materials with grids
    "structural/dev/dev_aqua",
    "structural/dev/dev_aquaddark",
    "structural/dev/dev_black",
    "structural/dev/dev_blue",
    "structural/dev/dev_bluedark",
    "structural/dev/dev_bluelight",
    "structural/dev/dev_green",
    "structural/dev/dev_greendark",
    "structural/dev/dev_greenlight",
    "structural/dev/dev_grey128",
    "structural/dev/dev_grey192",
    "structural/dev/dev_grey64",
    "structural/dev/dev_lime",
    "structural/dev/dev_magenta",
    "structural/dev/dev_magentadark",
    "structural/dev/dev_orange",
    "structural/dev/dev_orangedark",
    "structural/dev/dev_pink",
    "structural/dev/dev_pinkdark",
    "structural/dev/dev_purple",
    "structural/dev/dev_purpledark",
    "structural/dev/dev_red",
    "structural/dev/dev_reddark",
    "structural/dev/dev_white",
    "structural/dev/dev_yellow",
    "structural/dev/dev_yellowdark",
    
    --Materials without grids
    "structural/dev/dev_nogrid_aqua",
    "structural/dev/dev_nogrid_aquadark",
    "structural/dev/dev_nogrid_black",
    "structural/dev/dev_nogrid_bluedark",
    "structural/dev/dev_nogrid_bluelight",
    "structural/dev/dev_nogrid_green",
    "structural/dev/dev_nogrid_greendark",
    "structural/dev/dev_nogrid_greenlight",
    "structural/dev/dev_nogrid_grey128",
    "structural/dev/dev_nogrid_grey192",
    "structural/dev/dev_nogrid_grey64",
    "structural/dev/dev_nogrid_lime",
    "structural/dev/dev_nogrid_limedark",
    "structural/dev/dev_nogrid_magenta",
    "structural/dev/dev_nogrid_magentadark",
    "structural/dev/dev_nogrid_orange",
    "structural/dev/dev_nogrid_orangedark",
    "structural/dev/dev_nogrid_pink",
    "structural/dev/dev_nogrid_pinkdark",
    "structural/dev/dev_nogrid_purple",
    "structural/dev/dev_nogrid_purpledark",
    "structural/dev/dev_nogrid_red",
    "structural/dev/dev_nogrid_reddark",
    "structural/dev/dev_nogrid_white",
    "structural/dev/dev_nogrid_yellow",
    "structural/dev/dev_nogrid_yellowdark",
    
    --Materials Trims
    "structural/dev/dev_bluelight_trim",
    "structural/dev/dev_blue_trim",
    "structural/dev/dev_greenlight_trim",
    "structural/dev/dev_green_trim",
    "structural/dev/dev_grey192_trim",
    "structural/dev/dev_orange_trim",
    "structural/dev/dev_purple_trim",
    "structural/dev/dev_red_trim",
    "structural/dev/dev_yellow_trim",
}

This does require quite a bit of scrolling but you should eventually get there :)

 

That was a practical fun bit of coding.

Share this post


Link to post
Share on other sites

since you do the same thing, yes. you could remove one variable ( -> setMaterial)

 

i'd move n outside of the draw loop and on a side note, you can do

n = #contentlist

i also would try to reduce nesting by inverting the condition and returning

ex.

if player.state ~= PLAYER_STATE_EDITOR then return end

and so on

 

in language with 0 indexed arrays i usually do just a set of the pos and arrange it with modulo

x = x (+/-) 1 + array.length % array.length

but then lua starts with 1 which gives me a headache when accessing it :)

 

also you might set

contentHack =
{
  canHide = false,
  canPosition = false,

hiding can only trigger an error, if you set cl_crosshair to 888 before displaying the widget it gets stuck in a look

and since we don't paint any ui position is irrelevant

Edited by Bonuspunkt

Share this post


Link to post
Share on other sites

ok i copied the code and put it into a copy of another .lua file I del all in there and copied your text in with the new code.

Saved as contentHack.lua in C:Program Files (x86)SteamSteamAppscommonReflexbaseinternaluiwidgets

 

Put the command ui_show_widget contentHack in my game.cfg and also the bind me mousewheelup cl_crosshair 888
bind me mousewheeldown cl_crosshair 889 in the game.cfg

 

Gone in game went to edit mode and nothing happened. You say Activate the widget via: ui_show_widget contentHack (is that not done by putting it in the game.cfg with the rest of the widgit stuff?

 

And get 4 errors saying the same thing "environment/liquids/lava/lava_burn" I'm taking that as maybe the mat name has changed or the path could be dif I look in the contentbrowser hack for the correct path.

 

So what am I doing wrong?

Share this post


Link to post
Share on other sites

Gone in game went to edit mode and nothing happened. You say Activate the widget via: ui_show_widget contentHack (is that not done by putting it in the game.cfg with the rest of the widgit stuff?

 

And get 4 errors saying the same thing "environment/liquids/lava/lava_burn" I'm taking that as maybe the mat name has changed or the path could be dif I look in the contentbrowser hack for the correct path.

 

"ui_show_widget contentHack" can be done in either... after you enter it in the console, it would also be saved in the game.cfg after exiting Reflex. But you can as you say add that line directly in the game.cfg.

 

I did not notice errors...

 

Just rechecking and have problems getting the script to run, had to manually "cl_crosshair 0" to fix an existing "cl_crosshair 888"... and suddenly the active materials are scrolled through on the console... hmmm... no idea what the heck is going on. Will get back to you later...

 

Update: On first glance

local crosshair = consoleGetVariable("cl_crosshair")    -- remember original crosshair

does not properly remember the very first crosshair number... before any of the scrolling happens. And I am not sure why it worked at all. I may need to hack this to

local crosshair = 0

Thus turning off the crosshair in edit mode, IMO, that should be the case anyway. I have bindings that turn on the proper crosshair for game mode:

bind game mouse3 toggleeditor; cl_show_hud 0; cl_crosshair 0      // Switch to edit mode, turn off crosshair
bind me mouse3 cl_playerstate 1; cl_show_hud 1; cl_crosshair 4    // Back to game mode, set proper crosshair

Share this post


Link to post
Share on other sites

Ok checked the contentbrowserhack and the path and mat name is all correct.and its all correct in the code so really no idea.

 

I'm just amazed how quickly you both got this far. But thanks for doing this Aeon and Bonuspunkt, just goes to show how good the community really is

Share this post


Link to post
Share on other sites
n = #contentlist

 

On a side note that is a bad habit to get in, it does not all way's return the correct amount of key/value in the table.

see example =)

require "base/internal/ui/reflexcore";

blah = {
    draw = function()
      -- if your table has gaps in the index it doesnt know how to count! lol
        local test = {};
	test[1] = 1;
	test[3] = 1;
	consolePrint(#test) --returns as 1... MOST of the time. lol
	
	local aTest = {};
	aTest[1] = 1;
	aTest[2] = 2;
	consolePrint(#aTest) -- returns 2
    end
}
registerWidget("blah");

Share this post


Link to post
Share on other sites

OK... I seem to need to actually save the .lua file to have Reflex properly work with it... there seems to be some initialisation issue I am not seeing... here the present more compact code...

-- Reflexbaseinternaluiwidgets_customcontentHack.lua
--                                        ---------------
require "base/internal/ui/reflexcore"

local contentlist =
{
    --Lights
    "structural/industrial/lights/light_flood/light_flood",
    "structural/industrial/lights/light_fluro/light_fluro_twin_64_w",
    "structural/industrial/lights/light_rnd/light_rnd",
    "structural/industrial/lights/light_spot_sml/light_spot_sml",
    "structural/industrial/lights/light_step_sml/light_step_sml",
    "structural/industrial/lights/light_wall/light_wall",
    "structural/industrial/lights/light_wall/light_wall2",
    "structural/industrial/lights/light_wall_rect/light_wall_rect",
    "structural/industrial/lights/light_wall_sml/light_wall_sml",

    --Decals
    "structural/decals/decal_dev_logo_reflex",

    --LIQUIDS
    --Lava
    "environment/liquids/lava/lava_burn",
    "environment/liquids/lava/lava_enter",
    "environment/liquids/lava/lava_exit",
    "environment/liquids/lava/lava_step",
    "environment/liquids/lava/lava_submerged",
    "environment/liquids/lava/lava_wade",

    --Slime
    "environment/liquids/slime/slime",

    --Water
    "environment/liquids/water/water_burn",
    "environment/liquids/water/water_enter",
    "environment/liquids/water/water_exit",
    "environment/liquids/water/water_step",
    "environment/liquids/water/water_submerged",
    "environment/liquids/water/water_wade",

    --Teleporter
    "internal/world/teleporter/teleporter_frame_L",
    "internal/world/teleporter/teleporter_frame_R",
    "internal/world/teleporter/teleporter_portal",

    --MATERIALS
    --NoLight
    "internal/editor/textures/editor_nolight",

    --Materials with grids
    "structural/dev/dev_aqua",
    "structural/dev/dev_aquaddark",
    "structural/dev/dev_black",
    "structural/dev/dev_blue",
    "structural/dev/dev_bluedark",
    "structural/dev/dev_bluelight",
    "structural/dev/dev_green",
    "structural/dev/dev_greendark",
    "structural/dev/dev_greenlight",
    "structural/dev/dev_grey128",
    "structural/dev/dev_grey192",
    "structural/dev/dev_grey64",
    "structural/dev/dev_lime",
    "structural/dev/dev_magenta",
    "structural/dev/dev_magentadark",
    "structural/dev/dev_orange",
    "structural/dev/dev_orangedark",
    "structural/dev/dev_pink",
    "structural/dev/dev_pinkdark",
    "structural/dev/dev_purple",
    "structural/dev/dev_purpledark",
    "structural/dev/dev_red",
    "structural/dev/dev_reddark",
    "structural/dev/dev_white",
    "structural/dev/dev_yellow",
    "structural/dev/dev_yellowdark",

    --Materials without grids
    "structural/dev/dev_nogrid_aqua",
    "structural/dev/dev_nogrid_aquadark",
    "structural/dev/dev_nogrid_black",
    "structural/dev/dev_nogrid_bluedark",
    "structural/dev/dev_nogrid_bluelight",
    "structural/dev/dev_nogrid_green",
    "structural/dev/dev_nogrid_greendark",
    "structural/dev/dev_nogrid_greenlight",
    "structural/dev/dev_nogrid_grey128",
    "structural/dev/dev_nogrid_grey192",
    "structural/dev/dev_nogrid_grey64",
    "structural/dev/dev_nogrid_lime",
    "structural/dev/dev_nogrid_limedark",
    "structural/dev/dev_nogrid_magenta",
    "structural/dev/dev_nogrid_magentadark",
    "structural/dev/dev_nogrid_orange",
    "structural/dev/dev_nogrid_orangedark",
    "structural/dev/dev_nogrid_pink",
    "structural/dev/dev_nogrid_pinkdark",
    "structural/dev/dev_nogrid_purple",
    "structural/dev/dev_nogrid_purpledark",
    "structural/dev/dev_nogrid_red",
    "structural/dev/dev_nogrid_reddark",
    "structural/dev/dev_nogrid_white",
    "structural/dev/dev_nogrid_yellow",
    "structural/dev/dev_nogrid_yellowdark",

    --Materials Trims
    "structural/dev/dev_bluelight_trim",
    "structural/dev/dev_blue_trim",
    "structural/dev/dev_greenlight_trim",
    "structural/dev/dev_green_trim",
    "structural/dev/dev_grey192_trim",
    "structural/dev/dev_orange_trim",
    "structural/dev/dev_purple_trim",
    "structural/dev/dev_red_trim",
    "structural/dev/dev_yellow_trim",
}

local crosshair = 0        -- crosshair turned off in edit mode
local pos = 0    -- 0 is the correct initial value, and
                 -- pos value is remembered between widget calls

contentHack =
{
    canHide = false,
    canPosition = false,

    draw = function()

        local player = getPlayer()
        if player.state ~= PLAYER_STATE_EDITOR then return end -- only do this in editor mode

        local n = #contentlist;
        local currentCrosshair = consoleGetVariable("cl_crosshair")

        if currentCrosshair == 888 then
            setNextMaterial = true
            pos = pos + 1
            if pos > n then pos = 1 end -- looping array
        elseif currentCrosshair == 889 then
            setPrevMaterial = true
            pos = pos - 1
            if pos < 1 then pos = n end
        else
            return
        end

        consolePerformCommand("me_activematerial " .. contentlist[pos])

        -- reset crosshair (i.e. turn it off again)
        consolePerformCommand("cl_crosshair " .. crosshair)

    end     -- end function
};

registerWidget("contentHack");

Once I resave the code with Reflex running, the keys work... seems the initially empty "me_activematerial" is also in some way an issue. No idea why.

 

 

Update: Something keeps to deleting the line:

ui_show_widget contentHack

in the game.cfg. Apparently a error that makes Reflex remove the line after exiting Reflex.

 

Adding the below:

    -- Early out if HUD should not be shown.
    if not shouldShowHUD() then return end;

avoids an access error to local player = getPlayer(); so that should help slightly. But when quitting ui_show_widget contentHack still is removed.

 

All this should be so simple... but it is not for some reason :(.

 

Noted that 0.33.3 has crept up... would it not be ironic it a proper Steam update fixes everything.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×