Q1. How do I check if a weapon in my inventory is in a weapon slot?
Q2. How do I determine the type of ammo a weapon in my inventory currently has loaded?
I'm writing a simple script function to Unload All Weapons in player inventory, apart from slotted weapons.
Crude function lacking the above 2 questions of coarse:
Code: Select all
local function unload_all_weapons()
local npc = db.actor
local t = {}
local function itr(npc,item)
if (string.find(item:name(), "wpn_")) then
--if not (item in weapon slot ?) then
local i = item:get_ammo_in_magazine()
if (i > 0) then
printf("%s ammo count: %s", item:name(), i)
--local type_ammo = item: get ammo type?
local type_ammo = "ammo_5.56x45_ap" -- test ammo place holder
if (t[type_ammo] == nil) then
t[type_ammo] = i
else
t[type_ammo] = t[type_ammo] + i
end
item:unload_magazine()
end
--end
end
end
npc:iterate_inventory(itr,npc)
for k,v in pairs(t) do
printf("k: %s = v: %s", k, v)
create_ammo(k,npc:position(),npc:level_vertex_id(),npc:game_vertex_id(),npc:id(), v)
end
end
Sorry for below novice scripter questions.
I'm still finding my way around on how to find info on functions, parameters, use and returns.
eg: most functions I'm finding in lua_help.script.
Then I usually look in the various other scripts that ship with CoC to see the way a function is used.
I still haven't found a wiki or page that I can look up what the actual functions return or their uses or expected paramters.
Apart from standard LUA pages, but they don't really help with functions that are written specifically for stalker.
Learning curve is steap since I have no prior LUA script experience..lol
The only scripting languages I've used are AutoIt and Papyrus.
In most cases I can usually piece things together a bit of reading and experimenting.