ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Inventory button "Remove All Objects" MOD?

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  16:49:08  24 February 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
Messages: 319
Inventory button "Remove All Objects" MOD?

Hello Stalkers,

I was wondering if anyone ever made a mod that does the opposite of the inventory button "Take all".

You know, just so we don't have to spend long minutes to empty our backpack after a worthy trip in the Zone.
  23:09:53  25 February 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
02/25/2014 23:10:59
Messages: 319
Allright, I managed to get something working. Well, almost.

I need to click on this button to transfer the items to the stash.

I implemented the callback function:


self:AddCallback("btn_TransferItems", ui_events.BUTTON_CLICKED, self.transfer_on_clicked, self)




I put a log into the "transfer_on_clicked" function, but it doesn't enter it

How come it doesn't enter the function when I click on the button?


Below is the code to get someone to clarify this for me, as I simply don't get it:


class "empty_backpack" (CUIScriptWnd)

function empty_backpack:__init(hud) super()


	self.hud = hud
	self:InitControls()
	self:InitCallBacks()
	

end



function empty_backpack:__finalize()

end


function empty_backpack:InitControls()
	
	
	self:Init(235,730,100,28)
	local xml = CScriptXmlInit()
	
	xml:ParseFile("ui_transfer_item.xml")

	btn = xml:Init3tButton("btn_TransferItems", self)
	self:Register(btn, "btn_TransferItems")
	btn:ClipperOn()
	

end


function empty_backpack:InitCallBacks()

	self:AddCallback("btn_TransferItems", ui_events.BUTTON_CLICKED, self.transfer_on_clicked, self)
	
end

  23:27:10  25 February 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
02/25/2014 23:28:37
Messages: 319
Please Note that if I add my button with

level.start_stop_menu(gui_win, true)

instead of
level.add_dialog_to_render(gui_win)


it works, but of course the screen is blocked, and I have to press "Esc" to be able to use the inventory, which is unacceptable


Is there an other function to add a button and make it clickable?
  12:49:31  7 March 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
Messages: 319
up
  10:22:56  11 March 2014
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4303
The take_all_btn on the search screen is directly controlled by xrGame.dll. You might want to look at some mods that add button functionality to that screen, SacriPan, maybe in carbody_new.xml and carbody_new_16.xml.
  17:17:43  12 March 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
03/12/2014 17:18:15
Messages: 319
Thanks Natvac but this doesn't help much (there's a 1st for everything, right?).

Unless you can name a MOD that does that so I can look into it
  22:33:28  13 April 2014
profilee-mailreply Message URLTo the Top
oddFlow
(Novice)
 
On forum: 04/12/2014
Messages: 15
Is there any specific function in game for dropping everything in the backpack? Or to get a list of current items in it, and drop them one by one?
  23:02:08  13 April 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

---QUOTATION---
Or to get a list of current items in it, and drop them one by one?
---END QUOTATION---


You're looking for the client object member function inventory_for_each. It takes a function as an argument and passes a client object reference for each item in the inventory to that function. So if you just want to dump everything on the ground, it would go like this:

db.actor:inventory_for_each(
	function ( object )
		db.actor:drop_item( object )
	end
)

  23:25:00  13 April 2014
profilee-mailreply Message URLTo the Top
oddFlow
(Novice)
 
On forum: 04/12/2014
Messages: 15
Thank you very much, that does the trick

Any way to limit how many items are dropped? In a perfect scenario, I would want to drop just one item and then check again if another needs to be dropped.
  23:33:28  13 April 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

---QUOTATION---
Any way to limit how many items are dropped?
---END QUOTATION---


Sure, just declare a variable external to the function that keeps track of whatever you need it to.

local howMany = 0
db.actor:inventory_for_each(
	function ( object )
		if howMany < 10 then
			db.actor:drop_item( object )
			howMany = howMany + 1
		end
	end
)


Keep in mind that items get passed through the function in a particular order. First are loose items in order of when you picked them up (oldest first), then equipped or on belt items.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2022 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.