18:16:44 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
OK
I'll try to set my ST right first, then I'll try to spawn my NPC and see if it does respawn or not.
Thanks |
21:12:53 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
---QUOTATION--- The excellent packet_utils allows you to set custom_data from script (among many other things). For example,
local data = packet_utils.get_object_data( sObj ) --where sObj is a server object reference to your NPC
data.custom_data = "[smart_terrains]\nesc_lager = true"
packet_utils.set_object_data( sObj, data )
---END QUOTATION---
Doesn't work for me:
FATAL ERROR
[error]Expression : fatal error
[error]Function : CScriptEngine::lua_error
[error]File : E:\stalker\sources\trunk\xr_3da\xrGame\script_engine.cpp
[error]Line : 73
[error]Description : <no expression>
[error]Arguments : LUA error: ....e.r. - soc\gamedata\scripts\sacripan_testing.script:241: attempt to index local 'data' (a nil value)
This is how I psawn my NPC (works OK) and then add the ST to its logic:
local npc_id = nil
--[[------------------------------------------------
Function to spawn a NPC
--]]------------------------------------------------
function spawn_test_npc()
local pos = vector():set(-58.2559, -3.9862, -68.4168)
local level_id = 219612
local game_id = 74
local npc = alife():create("esc_st_test_npc", pos, level_id, game_id)
npc_id = npc.id
end
--[[------------------------------------------------
Function bind the ST to a NPC
--]]------------------------------------------------
function bind_npc_to_ST_test()
if (npc_id ~= nil) then
local npc = level.object_by_id(npc_id)
local data = packet_utils.get_object_data( npc )
data.custom_data = "[smart_terrains]\nesc_st_test = true"
packet_utils.set_object_data( npc, data )
end
end
I have "packet_utils" 2.0 and run on 1.6 patch. I tried on a 1.4 install but got the same error.
Also, concerning my Smart Terrain, I did have a typo, preventing other ST to be OK. It's fine now. The only problem is, seconds after I enable my own ST, the game freezes... |
22:25:54 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
UPDATE on the error message generated after the freeze.
FATAL ERROR
[error]Expression : fatal error
[error]Function : CScriptEngine::lua_error
[error]File : E:\stalker\sources\trunk\xr_3da\xrGame\script_engine.cpp
[error]Line : 73
[error]Description : <no expression>
[error]Arguments : LUA error: ...l.k.e.r. - soc\gamedata\scripts\smart_terrain.script:836: attempt to index a function value
Here is the script file:
function se_smart_terrain:create_gulag()
self.duration_end = game.CTime() -- LINE 836...
-- self.duration_end:setHMSms( 0, 0, 0, math.random( self.gparams.duration_min * h2ms, self.gparams.duration_max * h2ms ) )
self.duration_end:setHMSms( math.random( self.gparams.duration_min, self.gparams.duration_max ), 0, 0, 0 )
self.duration_end:add( game.get_game_time() )
self.check_time = CTime_0
self.gulag:initialize()
self.gulag_working = true
end
|
02:43:58 18 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
 Message edited by: SacriPan 04/18/2014 12:16:21
Messages: 319
|
Ok, so after a lot of trial and errors, I finally got my ST working (Dez ST debug tool says it is, it's active and yellow)
But of course, I got a "new" CTD as soon as I approached the NPC:
[error]Expression : fatal error
[error]Function : CScriptEngine::lua_error
[error]File : E:\stalker\sources\trunk\xr_3da\xrGame\script_engine.cpp
[error]Line : 73
[error]Description : <no expression>
[error]Arguments : LUA error: ....t.a.l.k.e.r. - soc\gamedata\scripts\xr_logic.script:371: attempt to index field '?' (a nil value)
That is the line (vanilla file)
_G[filename].set_scheme(npc, ini, scheme, section, db.storage[npc_id]["gulag_name"])
Also, for now, I spawned my NPC via all.spawn and assigned him its ST there too. |
15:28:32 18 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
 Message edited by: SacriPan 04/18/2014 16:58:00
Messages: 319
|
I put some displays in the log and I found out that "filename" is not set, and that is why the error occurs.
I don't get what I'm doing wrong. I just followed the tutorial.
I have 1 Smart Terrain, 1 job, 1 state (I tried with 2 states), 1 NPC, but the game just can't take it...
Any advice?
EDIT:
If anyone has special powers to make ST work properly, I'll take them too |
17:51:42 18 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
Well I'm new to packet_utils. I used TKGP advices and code example.
As far as I understand about logic, I didn't need to set the NPC logic because I set the smart terrain, the Smart terrain providing to my NPC its own logic (via a job).
That how I understand it at least
In all.spawn there can be a [logic] section and a [smart_terrain] section for a NPC.
But logic section points to a custom logic file for the NPC, which I believe is only used if he's not tied to a Smart Terrain.
I'm not really sure about that though |
21:10:59 18 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
 Message edited by: SacriPan 04/18/2014 21:17:37
Messages: 319
|
Yes, I spawn him at the same coordinates than the ST, so I don't have to wait an hour for him to go to work |
|