 |
 |
 |
|
 |
 |
 |
|
 |
 |
Fixing bug in Artifact Detector |
|
1 2 | Next 10 events »| All Messages |
|
|
19:20:43 30 March 2011 |
|
MrSeyker
Senior Resident
On forum: 03/21/2010
Messages: 433
|
Fixing bug in Artifact Detector
I'm trying to rewrite the Artifact Detector mod by Singapur22 to work as intended, but I'm having a problem with this part of code:
function det_super()
for k,v in pairs(db.artefacts) do
local art = level.object_by_id(k)
if art then
if not art:parent() then
local dist = db.actor:position():distance_to_sqr(art:position())
if dist < 1500^2 then
if not v.spot then
local ini = system_ini()
local section = art:section()
local name = ""
if ini and section and ini:section_exist(section) then
if ini:line_exist(section, "inv_name") then
name = ini:r_string(section, "inv_name")
end
end
level.map_add_object_spot(k, "artefact_location", "Artifact: " .. game.translate_string(name))
db.artefacts[k].spot = true
end
else
this.del_spot(k, v)
end
else
this.del_spot(k, v)
end
end
end
end
How can I make this detect offline artifacts?
Here's the original for comparison:
function det_super()
for k,v in pairs(db.artefacts) do
local sobj = alife():object( k )
if sobj then
if game_graph():vertex(sobj.m_game_vertex_id):level_id() == alife():level_id() and sobj.parent_id == 65535 and not sobj.is_day_night then
if not v.spot then
local ini = system_ini()
local section = sobj:section_name()
local name = ""
if ini and section and ini:section_exist(section) then
if ini:line_exist(section, "inv_name") then
name = ini:r_string(section, "inv_name")
end
end
level.map_add_object_spot(k, "artefact_location", "àðòåôàêò: " .. game.translate_string(name))
db.artefacts[k].spot = true
end
else
this.del_spot(k, v)
end
end
end
end
Any ideas?
My S.T.A.L.K.E.R files:
https://www.mediafire.com/folder/galaj1kcbawe9/SHOC
https://www.mediafire.com/folder/1duxlnn6jlm5z/STALKERFiles
|
21:03:45 30 March 2011 |
|
MrSeyker
Senior Resident
On forum: 03/21/2010
Messages: 433
|
---QUOTATION--- as irony would have it, it would seem the original was indeed written for offline objects. ---END QUOTATION---
Yeah, but only that part.
The other two detectors use the same method as my example, but that just bugs the hell out of the whole thing.
Doing some more tests, I'm finding more problems.
If I have the super detector attached when the artifact goes offline, it won't delete the marker when I change detectors as it's already out of the script's reach.
I think the solution would be to turn this process:
function det_indy()
for k,v in pairs(db.artefacts) do
local art = level.object_by_id(k)
local art2 = alife():object(k)
if art then
if not art:parent() then
local dist = db.actor:position():distance_to_sqr(art:position())
if dist <= 40^2 and dist < time_global() - v.tim_beep then
if not snd_obj:playing() then
db.artefacts[k].tim_beep = time_global()
snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end
else
this.del_spot(k, v)
end
else
this.del_spot(k, v)
end
end
end
end
Into the original I posted above.
But I don't know how to get the artifact's position that way.
My S.T.A.L.K.E.R files:
https://www.mediafire.com/folder/galaj1kcbawe9/SHOC
https://www.mediafire.com/folder/1duxlnn6jlm5z/STALKERFiles
|
16:39:42 31 March 2011 |
|
MrSeyker
Senior Resident
On forum: 03/21/2010
 Message edited by: MrSeyker 03/31/2011 16:42:02
Messages: 433
|
Damn, this is so incredibly frustrating.
I kept the codes as they were originally, except for the call to each function:
if item:section() == "det_artefact_indy" then
this.iteration_del_spot()
this.det_indy()
elseif item:section() == "det_artefact_pro" then
this.iteration_del_spot()
this.det_pro()
elseif item:section() == "det_artefact_super" then
this.iteration_del_spot()
this.det_super()
else
this.iteration_del_spot()
end
First I remove previous spots, then I create them again.
But even if the spot gets added to the map, the lables are missing, and the mini-map shows nothing this way.
These are the functions that remove spots, and add them:
function iteration_del_spot()
for k,v in pairs(db.artefacts) do
local art = alife():object(k)
if art then
this.del_spot(k, v)
end
end
end
function add_spot(k, v, string)
if not v.spot then
local s_obj = alife():object(k)
level.map_add_object_spot(s_obj.id, "artefact_location", string)
db.artefacts[k].spot = true
end
end
function del_spot(k, v)
if v.spot then
local s_obj = alife():object(k)
level.map_remove_object_spot(s_obj.id, "artefact_location")
db.artefacts[k].spot = false
end
end
Indy function:
function det_indy()
for k,v in pairs(db.artefacts) do
local art = level.object_by_id(k)
if art then
if not art:parent() then
local dist = db.actor:position():distance_to_sqr(art:position())
if dist <= 40^2 and dist < time_global() - v.tim_beep then
if not snd_obj:playing() then
db.artefacts[k].tim_beep = time_global()
snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end
else
this.del_spot(k, v)
end
else
this.del_spot(k, v)
end
end
end
end
Pro function:
function det_pro()
for k,v in pairs(db.artefacts) do
local art = level.object_by_id(k)
if art then
if not art:parent() then
local dist = db.actor:position():distance_to_sqr(art:position())
if dist < 70^2 then
if not v.spot then
local ini = system_ini()
local section = art:section()
local name = ""
if ini and section and ini:section_exist(section) then
if ini:line_exist(section, "inv_name") then
name = ini:r_string(section, "inv_name")
end
end
this.add_spot(k, v, "Artifact")
end
if v.tim_beep < time_global() and not snd_obj:playing() then
db.artefacts[k].tim_beep = time_global() + 2500
snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end
else
this.del_spot(k, v)
end
else
this.del_spot(k, v)
end
end
end
end
Super function:
function det_super()
for k,v in pairs(db.artefacts) do
local art = alife():object(k)
if art then
if game_graph():vertex(art.m_game_vertex_id):level_id() == alife():level_id() and art.parent_id == 65535 and not art.is_day_night then
if not v.spot then
local ini = system_ini()
local section = art:section_name()
local name = ""
if ini and section and ini:section_exist(section) then
if ini:line_exist(section, "inv_name") then
name = ini:r_string(section, "inv_name")
end
end
this.add_spot(k, v, "Artifact: " .. game.translate_string(name))
end
else
this.del_spot(k, v)
end
end
end
end

My S.T.A.L.K.E.R files:
https://www.mediafire.com/folder/galaj1kcbawe9/SHOC
https://www.mediafire.com/folder/1duxlnn6jlm5z/STALKERFiles
|
16:26:37 1 January 2012 |
|
the_marked_one
Senior Resident
On forum: 11/21/2010
Messages: 647
|
Where can i find a copy of this artifact detector mod? could be just what im looking for |
22:48:08 1 January 2012 |
|
the_marked_one
Senior Resident
On forum: 11/21/2010
Messages: 647
|
Thanks i will have a look and see if i can get it working with my mod |
|
1 2 | Next 10 events »| All Messages |
|
|
|
» » |
|
All short dates are in Month-Day-Year format. |
 |
|
 |
|
|
|
 |
 |
 |