ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Saving Coords To Console Issue

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  14:35:06  11 February 2019
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1071
Saving Coords To Console Issue




Hello guys, i have a stupid issue in my function. The idea is to create a ecologist npc, triggered by a stalker under script control (on a smart terrain).

So my functional npc is moving on a custom path and his logic is something like this:

on_info5 = {=ts(3.8} %=npc_save_walk_and_look_data%

The function {=ts(3.8)} is a custom xr_condition that allows me to reset and repeat when the time value is reached (in this case 3.8 seconds).
This was made this way to prevent an overwhelming timer spam, this is not a problem... it works fine.
So as you can see, after 3.8 seconds a xr_effects function is executed. Function name is 'npc_save_walk_and_look_data'

And the function is:


-- Function starts Here

function npc_save_walk_and_look_data(actor, npc)

 if npc then

        local distance = 5 -- this is the distance from npc himself -- in front of the npc

		local position = npc:position()
		local direction = npc:direction()

	local noobposition = npc:position()

	local nmpos = vector():set( noobposition.x + (distance * direction.x * (1)), noobposition.y + (distance * direction.y * (1)), noobposition.z + (distance * direction.z * (1)))

             for i = 1, 1 do

    local reality = alife():create(faction_ecolog[math.random(1,4)], nmpos, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
--------------------------------------------------------------------

-- The ecologist stalkers created are spawning exactlly where i want (in front of my custom npc, separated by 5 metters)
-- Everything is good, BUT...

-- now i need to save 2 things to console:
-- 1st thing -- Current Position Of Npc under script control himself + lvid and gvid (this is not a big deal because, the custom npc is already under my control... i know where he goes)
-- 2st thing -- Current Position Of Created Ecologist + lvid and gvid -- this will match the coordenates of the created ecologist (this is the issue)

--	get_console():execute(1st thing)
--	get_console():execute(2st thing)

--------------------------------------------------------------------

             end

 end
end

-- Function Ends Here


Ok, guys this is hard for me ... but for some of you guys this is a walk in the park

Thanks in advance



  09:42:41  1 March 2019
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4259

---QUOTATION---
The function {=ts(3.8)} is a custom xr_condition that allows me to reset and repeat when the time value is reached (in this case 3.8 seconds).
This was made this way to prevent an overwhelming timer spam, this is not a problem... it works fine.
---END QUOTATION---


I suggest format your code so that it doesn't stretch the forum default width. You don't need to quote and post code with extra-wide comments, and you can break code lines at logical places. Lua doesn't care about formatting, but if you want help, you should try to make your posts more human-readable.

What I understand from what you posted is that every 3.8 seconds your npc_save_walk_and_look_data() function is called, and it attempts to spawn another NPC each time. You need to put some sort of limit, like a static counter in the timer test so that it returns false after some sane maximum spawn count.

As for your question, you already have the "npc" object passed into your function. You also have the ecologist object, although you have it defined as a local called "reality". Just as you used the "npc" object to get his position (again, you have two local variables assigned to the same thing!), you can also use the "npc" object to get his level vertex id and his game vertex id. Same goes for the "reality" ecologist, although you might need to make that variable a member of a global array (or just create a couple of ecologists and have a couple of global vars for them) so that you can keep track of your spawns and so that you can let the spawn have time to be fully realized in the game.

In different words, the game needs to breathe after the alife():create() before you can use the object it returns.

Find the functions you need in scripts\lua_help.script. This file is not a real script but it will have the functions available in the engine. Look for "C++ class game_object" for functions used by objects in the game. You'll see level_vertex_id() and game_vertex_id() there. They'll give you the values you asked for: npc:level_vertex_id(), for example.

---QUOTATION---
Ok, guys this is hard for me ... but for some of you guys this is a walk in the park
---END QUOTATION---


When each of us started programming or modding or embarking on doing something new, it was often also hard for us. You need to do your own homework: learn how to program, learn Lua, and study how the configuration files and the all.spawn data are used in the game.
 
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-2019 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.