ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Make a script that executes on a new game but only once ?

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  23:32:58  24 September 2016
profilee-mailreply Message URLTo the Top
xQd
(Novice)
 
On forum: 05/12/2014
 

Message edited by:
xQd
09/24/2016 23:43:57
Messages: 26
Make a script that executes on a new game but only once ?

I would like to know how to create a script that executes only when starting a new game and after that, it will never execute again on that game. I want to do this without removing the script file manually after each new created game...

For example: making a script that gives all stalkers a grenade, and after you save the game and reload, the script will never execute again, so the stalkers won't be getting grenades each time to reload the game...

How could I do this ?

EDIT: I prefer to do this without altering the save file, like making a variable that checks if the script was executed and store it in the save file so the game remembers each time you load. I am wondering if there's already some kind of IF function in the game's scripts that checks whether it's a new save or not.
  04:52:11  25 September 2016
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
 

Message edited by:
TKGP
09/25/2016 4:52:39
Messages: 454
In bind_stalker.actor_binder:net_spawn:

	if not self.loaded then
		-- Do whatever
	end


In bind_stalker.actor_binder:load:

	self.loaded = true


Only time you can net_spawn without load is on new game, so there you go.
  09:54:47  25 September 2016
profilee-mailreply Message URLTo the Top
xQd
(Novice)
 
On forum: 05/12/2014
 

Message edited by:
xQd
09/25/2016 11:59:52
Messages: 26
Thanks a lot, TKGP. You saved me a lot of time .

There is something that is not clear to me, why do I need a "loaded" field for actor_binder class when you already said that actor_binder.net_spawn() executes once per a new game? Isn't it enough if I put my little code in actor_binder:net_spawn() and not bother with actor_binder:load() method ?

EDIT: Ohh, after a few tests I got it. So actor net_spawn() executes each time you load a game, after actor load(), but on new game the load() method doesn't execute, only net_spawn()...

Does that mean that self.loaded is actually stored in the save file? Because the game seems to remember it even though I haven't used the pstor/packet functions to store in the save file...
  01:26:18  29 September 2016
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

---QUOTATION---
Does that mean that self.loaded is actually stored in the save file?
---END QUOTATION---


No
 
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.