ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Clear Sky Forum » Mod discussion
Check if actor wears a suit

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  15:13:12  28 September 2015
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Check if actor wears a suit

Hey guys i need help with my script.
I need to check if actor wears a suit from a table or not.
I use this fuction:


---QUOTATION---


function item_in_table(t, item)
for k,v in pairs(t) do
if v == item then
return true
end
end
return false
end



local suittypes = {
scientific_outfit,
dolg_scientific_outfit,
stalker_seva_outfit,
svoboda_seva_outfit,
cs_seva_outfit,
killer_seva_outfit,
army_seva_outfit,
monolith_seva_outfit,
protection_seva_outfit
}



function actor_is_not_protected()
local actor = db.actor
local suit = actor:item_in_slot(6)
local sini = system_ini()
local suit_section = suit:section()
if suit ~= nil and item_in_table(suittypes, suit_section) == true then
news_manager.send_tip(db.actor, "%c[default]".."Grey:".."%c[255,255,128,128] I be protected.".."".."\n", nil, "st_actor_name", 15000)
elseif suit ~= nil and item_in_table(suittypes, suit_section) == false then
news_manager.send_tip(db.actor, "%c[default]".."Grey:".."%c[255,255,128,128] I be not protected.".."".."\n", nil, "st_actor_name", 15000)
elseif suit == nil then
news_manager.send_tip(db.actor, "%c[default]".."Grey:".."%c[255,255,128,128] I be not protected.".."".."\n", nil, "st_actor_name", 15000)
end
end
---END QUOTATION---



But the message that the actor is protected comes with every suit and if i wear no suit the game crashes.

Maybe someone can help me, and tell we the correct way to check if a suit from table is worn or not.
  17:58:08  28 September 2015
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
Use pre tags, not quote, it allows tabs.

local suittypes = {
	scientific_outfit = true,
	dolg_scientific_outfit = true,
	stalker_seva_outfit = true,
	svoboda_seva_outfit = true,
	cs_seva_outfit = true,
	killer_seva_outfit = true,
	army_seva_outfit = true,
	monolith_seva_outfit = true,
	protection_seva_outfit = true,
	}

function actor_is_not_protected()
	local suit = db.actor:item_in_slot( 6 )
	if suit and suittypes[ suit:section() ] then
		news_manager.send_tip(db.actor, "%c[default]".."Grey:".."%c[255,255,128,128] I be protected.".."".."\n", nil, "st_actor_name", 15000)
	else
		news_manager.send_tip(db.actor, "%c[default]".."Grey:".."%c[255,255,128,128] I be not protected.".."".."\n", nil, "st_actor_name", 15000)
	end
end

  18:32:16  28 September 2015
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Thanks
But the problem is the same with your code.
The message says alway the actor is not protected.
But i wear the correct suit, so the message should say that the actor is protected....
  19:16:10  28 September 2015
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
Must be a typo in your suit name or table then, because I've tested it and it works fine for me.
  19:24:56  28 September 2015
profilee-mailreply Message URLTo the Top
The Xenus
(Senior)
 
On forum: 03/09/2011
Messages: 144
Sorry my bad....
Thanks for your help, the code works fine
 
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.: Clear Sky Forum » Mod discussion
 

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


 

Copyright © 1995-2021 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.