Jump to content

Why doesn't this script code work?


Recommended Posts

Posted (edited)

Hello everyone! I'm trying to make the entrance to the bank building close at night.
In the settings of the location itself, the trigger for entering the building is disabled by default. In the script, I wrote this:

IF
	TimeGT(7)
	TimeLT(20)
	Global("OpenBankDoors","AR0700",0) 
THEN
	RESPONSE #100
		TriggerActivation("TranAN0720",TRUE)
		SetGlobal("OpenBankDoors","AR0700",1) 
END

IF
	TimeGT(20)
	TimeLT(7)
	Global("OpenBankDoors","AR0700",1) 
THEN
	RESPONSE #100
		TriggerActivation("TranAN0720",FALSE)
		SetGlobal("OpenBankDoors","AR0700",0)  // Waukeen's Promenade
END

As a result, opening the entrance works correctly, but after that, the entrance always remains open, i.e. the second block of code does not work. The "OpenBankDoors" variable is always equal to 1. I do not understand why?

Edited by Austin
Posted (edited)

Shouldn't you use an Or in the second block? No number can satisfy 20 < x < 7.

ninjad :)

Edited by lynx
Posted (edited)

Thanks! I added OR(2) but it still didn't help :( The trigger still won't deactivate. There must be some other reason, but I can't figure it out(

Edited by Austin
Posted (edited)

I also tried this option for the sake of experiment:

IF
    TimeOfDay("DAY")
	Global("OpenBankDoors","AR0700",0) 
THEN
	RESPONSE #100
		TriggerActivation("TranAN0720",TRUE)
		SetGlobal("OpenBankDoors","AR0700",1)  
END

IF
   !TimeOfDay("DAY")
	Global("OpenBankDoors","AR0700",1)
THEN
	RESPONSE #100
		TriggerActivation("TranAN0720",FALSE)
		SetGlobal("OpenBankDoors","AR0700",0) 
END

But it doesn't work either :( The Global("OpenBankDoors") variable is always equal to 1 and does not change.

Edited by Austin
Posted

I assume you checked the time of day (i.e. made sure it is night) when you tried whether it's locked again?

The script snippet looks totally fine.

Is it possible those script blocks do not get executed at all (some script block before loops or somesuch)?

Posted (edited)
2 hours ago, Austin said:
TimeOfDay("DAY")

DAY is a symbolic identifier. You have to pass it directly, without surrounding quotes. Otherwise it would be interpreted by the compiler as a string and should at least trigger a compiler warning.

EDIT: Looks like the compiler fixes it automatically. In that case I also don't see any glaring errors. Is the area name in the Global() actions/triggers correct? You could use "MYAREA" as placeholder instead.

Edited by argent77
Posted (edited)
2 hours ago, jastey said:

I assume you checked the time of day (i.e. made sure it is night) when you tried whether it's locked again?

The script snippet looks totally fine.

Is it possible those script blocks do not get executed at all (some script block before loops or somesuch)?

Yes, I checked the time several times. The script sometimes works, sometimes not.

But I noticed that the problem disappears if I comment out this block of the script AR0700.bcs:

IF
	!GlobalTimerNotExpired("TSPickAR0700","AR0700")  // Waukeen's Promenade
	TimeGT(8)
	TimeLT(16)
THEN
	RESPONSE #100
		SetGlobalTimer("TSPickAR0700","AR0700",4320)  // Waukeen's Promenade
		CreateCreature("TSPick3",[1919.2649],SE)
		CreateCreature("TSPick2",[3557.1496],NW)  
		CreateCreature("TSPick1",[1580.2280],SE) 
		CreateCreature("TSPick2",[4444.2720],NW) 
		CreateCreature("TSPick4",[767.3347],SE) 
		Wait(120)
END

It seems that my new script blocks somehow conflict with this block from the original game. But I don't understand why :(

 

13 minutes ago, argent77 said:

DAY is a symbolic identifier. You have to pass it directly, without surrounding quotes. Otherwise it would be interpreted by the compiler as a string and should at least trigger a compiler warning.

The quotes were removed automatically after installing the mod. I also deleted them manually in my files and reinstalled the mod, checked again, but this did not solve the problem :(

Edited by Austin
Posted

That's definitely not a script block from the original game. It's actually a rather nasty bit of coding. The Wait(120) action would stall any further script processing for 120 seconds.

For best compatibility I would place your own script blocks at the top of the area script and add Continue() to each block to allow further script processing (important for event-based conditions).

Posted
4 hours ago, argent77 said:

That's definitely not a script block from the original game. It's actually a rather nasty bit of coding. The Wait(120) action would stall any further script processing for 120 seconds.

For best compatibility I would place your own script blocks at the top of the area script and add Continue() to each block to allow further script processing (important for event-based conditions).

Thank you very much! I will check where this fragment came from. I thought it was from the original game, since it adds normal city NPCs. But maybe it is part of one of the mods.

Posted (edited)

The cause of the problem has been found! :) It turned out to be because of the "Expanded Thief Stronghold" mod is installed! It has a file "ar0700addb01.baf", which adds this unfortunate script block with the "Wait(120)" command. Moreover, this mod adds this to the scripts of all Athkatla locations at once ("ar0400addb01.baf" etc.)!!! This can lead to a variety of bugs, not just the ones discussed above.

I removed the mod and the problem disappeared! Thank you!!!

Edited by Austin

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...