Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Adventure Mode : Rumor System UI improvement script  (Read 7071 times)

1337G4mer

  • Bay Watcher
    • View Profile
Adventure Mode : Rumor System UI improvement script
« on: January 03, 2016, 02:46:52 am »

Hi,

I wrote a small utility that helps me with the annoying menu of current rumor system. Hope Toady fixes that soon, until then I will use this.

Issue: In the current system after a relatively small adventuring your talk menu for "Bring up specific incident or rumor" gets filled up with lots of information. I had like 200+ pages of kea, kestrel , dingoes etc. Finding a specific kill of a megabeast, colossus, titan was annoying.

Requirements: dfhack , dfusion plugin

tested in version 0.42.03

Code commented for usage, refer below.

Next Todo:
If possible automate running of this every time we choose the rumor menu. I will look into that, or someone can redirect me on how to.
This just does the basic feature I needed it to do, maybe you can play around to improve it further. Share your changes too.

Code: [Select]
-- Improve "Bring up specific incident or rumor" menu in Adventure mode
--@ module = true
--[[=begin

rumors
============
Improve "Bring up specific incident or rumor" menu in Adventure mode

=end]]

--========================
-- Author : 1337G4mer on bay12 and reddit
-- Version : 0.2
-- Description : A small utility based on dfhack to improve the rumor UI in adventure mode.
--
-- Usage: Save this code as rumors.lua file in your /hack/scripts/ folder
-- In game when you want to boast about your kill to someone. Start conversation and choose
-- the menu "Bring up specific incident or rumor"
-- type rumors in dfhack window and hit enter. Or do the below keybind and use that directly from DF window.
-- Optional One time setup : run below command at dfhack command prompt once to setup easy keybind for this
-- keybinding add Ctrl-A@dungeonmode/ConversationSpeak rumors
--
-- Prior Configuration: (you can skip this if you want)
-- Set the three boolean values below and play around with the script as to how you like
-- improveReadability = will move everything in one line
-- addKeywordSlew = will add a keyword for filtering using slew, making it easy to find your kills and not your companion's
-- shortenString = will further shorten the line to = slew "XYZ" ( "n time" ago in " Region")
--=======================
function rumorUpdate()
improveReadability = true
addKeywordSlew = true
shortenString = true

for i, choice in ipairs(df.global.ui_advmode.conversation.choices) do
if choice.choice.type == 118 then
titleLength = #choice.title
if improveReadability then
if titleLength == 3 then
inputTitleStr = choice.title[0].value..' '..choice.title[1].value..choice.title[2].value
choice.title[0].value = inputTitleStr
choice.title[1].value = ''
choice.title[2].value = ''
else
inputTitleStr = choice.title[0].value..' '..choice.title[1].value
choice.title[0].value = inputTitleStr
choice.title[1].value = ''
end
end
if shortenString then
summaryStr = string.gsub(inputTitleStr, "Summarize the conflict in which","")
occurStr = string.gsub(summaryStr, "This occurred +","")
if titleLength == 3 then
choice.title[0].value = occurStr
choice.title[1].value = ''
choice.title[2].value = ''
else
choice.title[0].value = occurStr
choice.title[1].value = ''
end
end
if addKeywordSlew then
if string.find(choice.title[0].value, "slew") then
choice.keywords[1].value=("slew")
end
end
end
end
end

rumorUpdate()

I was able to do this because of this awesome community. I have been a lurker for a few years, just created account today to share this. Hope you like it. Go easy as this is my first post  :D

Screenshot :
Spoiler (click to show/hide)
Edit: Typo and screenshot
Edit: Updated with v 0.2 removed dfusion , Thanks Max and lethosor


« Last Edit: January 04, 2016, 12:13:01 am by 1337G4mer »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #1 on: January 03, 2016, 05:06:15 am »

Outstanding start! It should be in the utilities/3rd party tools subforum, and I think automating it would be possible using similar tricks to what Putnam did with his Sparking! mod.

I would just use a keybind for it, though this was way more handy in 40.24, fame spreads much better in 42.04 happily.

Still very cool, I will poke around at it some.

You can also just put it in your df/hack/scripts folder, I'd name it something like rumors.lua myself.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #2 on: January 03, 2016, 05:19:55 am »

Yup, I'll fiddle with it some more and see if I can have it load up automatically if I don't get beaten to it but it works just fine saved as df/hack/scripts/rumors.lua though I did need to add an argument (i.e. rumors addKeywordSlew works, rumors by itself didn't) but I'll fix that when I'm more awake tomorrow.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #3 on: January 03, 2016, 04:57:50 pm »

Yeah, dfusion is mostly obsolete (one or two things haven't been ported to the main DFHack lua system). You can just save that file to "hack/scripts/[scriptname].lua", then run "[scriptname]" in the normal DFHack console.

You might want to get rid of "This occurred " (note the space) instead of "This occurred" with gsub() to avoid the extra spaces showing up before the opening parentheses. ("This occurred +" would be even better if it's possible for multiple spaces to show up after "occurred" sometimes.)
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #4 on: January 03, 2016, 07:03:02 pm »

Still a very neat little idea huh, in hindsight I'm surprised I never tried that since I've messed with convo options after I saw Rumrusher do the invoke trick.
Logged

1337G4mer

  • Bay Watcher
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #5 on: January 04, 2016, 12:05:29 am »

Thanks, Glad you guys liked it.

PS: Updated OP with new version including changes.
Logged

Feniks

  • Bay Watcher
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #6 on: January 24, 2016, 07:41:56 pm »

It's looking great I play a lot of adventure moxe recently and it would help me a big ti.e.
Logged

Urist Sonuvagimli

  • Bay Watcher
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #7 on: March 01, 2017, 06:57:42 pm »

Why the hell is this hidden so deep? It is a must-have for adventure mode! Requesting inclusion into the official DFhack distributive.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #8 on: March 01, 2017, 07:43:47 pm »

I've added it to the DFHack issue tracker, and I'll try to get to it soon™.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

lethosor

  • Bay Watcher
    • View Profile
Re: Adventure Mode : Rumor System UI improvement script
« Reply #9 on: March 18, 2017, 04:35:32 pm »

This should be in the next release as "adv-rumors", with a few improvements (such as getting rid of the blank lines between choices, and not getting rid of existing keywords to add "slew").
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.