Jump to content

OnCreation clarification


drake127

Recommended Posts

In my opinion, at OnCreation area variables don't yet exist. I already mentioned something like this a while ago.

I've read that thread however behavior of that bug is pretty straightforward. I can test it little further if you think it is necessary.

Link to comment

I created this script and placed it in _blank_ ar0602.bcs:

IF
OnCreation()
THEN
RESPONSE #100
	DisplayString(Player1,5003) // Power Word Sleep
	Continue()
END

IF
OnCreation()
Global("AreaTest","AR0602",0)
THEN
RESPONSE #100
	DisplayString(Player1,7778) // Power Word Silence
	SetGlobal("AreaTest","AR0602",1)
	Continue()
END

IF
OnCreation()
Global("LocalTest","LOCALS",0)
THEN
RESPONSE #100
	DisplayString(Player1,7783) // Power Word Blind
	SetGlobal("LocalTest","LOCALS",1)
	Continue()
END

IF
OnCreation()
Global("GlobalTest","GLOBAL",0)
THEN
RESPONSE #100
	DisplayString(Player1,22142) // Power Word, Kill
	SetGlobal("GlobalTest","GLOBAL",1)
	// ##### Notice missing Continue()! #####
END

IF
OnCreation()
THEN
RESPONSE #100
	DisplayString(Player1,22143) // Power Word, Stun
END

Upon creating the game Sleep, Silence, Kill words shown up.

Upon saving and loading game only Sleep, Stun word shown up.

After leaving and reentering area only Sleep, Stun word shown up.

 

"LOCALS" scope does not work with areas properly (I've never seen "LOCALS" used in area scripts so why to bother?). OnCreation evaluates true every first and only first script loop (this is both necessary and sufficient condition).

Link to comment
In my opinion, at OnCreation area variables don't yet exist. I already mentioned something like this a while ago.
I may be misunderstanding you, but I don't think this is correct. You can check a variable in an OnCreation() block; it should do the right thing (i.e., not repeat).

 

Most of the behavior should be common sense. OnCreation() returns true when the resource is loaded (since this is when the script first fires). The only thing I don't know is if resting restarts parsing (I don't think it does, but I don't know).

 

LOCALS can only be used with creatures. If you use it with any other object type, it will always return false.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...