ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Script Issue on load save

Posted by/on
Question/AnswerMake Oldest Up Sort by Ascending
  12:23:45  9 July 2015
profilee-mailreply Message URLTo the Top
xRatx
Senior Resident
 

 
On forum: 06/18/2008
Messages: 1592
Thank you TKGP, moving the check to net_spawn and using pstor as you suggested fixed the problem.
  05:08:39  9 July 2015
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
Script binding objects only persist for the current session. If you want something to last for the entire life of the object you need to inject it into the server packet. You can save/load it manually if you know what you're doing but using xr_logic.pstor_store and pstor_retrieve is much easier, if less efficient. Also, I would put your check in net_spawn instead of update as it doesn't need to be run repeatedly.

if not xr_logic.pstor_retrieve( self.object, "doneRandomWeapon", false ) then
	-- Do whatever
	xr_logic.pstor_store( self.object, "doneRandomWeapon", true )
end


Or something to that effect.
  01:53:20  9 July 2015
profilee-mailreply Message URLTo the Top
xRatx
Senior Resident
 

 
On forum: 06/18/2008
 

Message edited by:
xRatx
07/09/2015 12:36:13
Messages: 1592
Script Issue on load save

Hello guys,
I've wrote a randomizer weapon spawner for npc (using xr_motivator to call it) and I've come up with a issue with saves.

Everytime I load a save, the script gets trigger a second time and spawns extra weapons to the NPC.

In xr_motivator I've changed :

function motivator_binder:__init (obj) super(obj)
	self.loaded = false
	self.last_update = 0
	----memusage.collect_info(self.object, "__init")

    self.first_update = false
	self.treasure_processed = false
	-- Weapon Randomizer Starts
	self.check = 0
	-- Weapon Randomizer Ends
end


and in I've added this lines function motivator_binder:update(delta)


	-- Weapon Randomizer Starts
	if self.check < 1 then
		weapon_randomizer.main_randomizer(self.object,self.check)
		self.check = self.check + 1 
	end
	-- Weapon Randomizer Ends


The self.check limits the script to running only once per npc - level load as Lijenstina wrote in this thread : https://www.gsc-game.com/index.php?t=community&s=forums&s_game_type=xr&thm_page=13&thm_id=18756&sec_id=16&page=10

Anyways, is there any extra-check I should do in order to prevent this "bug" ?
 
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-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.