Announcement: Why not try our official idea generator for inspiration when making puzzles?


Caravel Forum : DROD Boards : Architecture : Scripting question - how can I share vars across NPCs?
New Topic New Poll Post Reply
Poster Message
Dying Flutchman
Level: Smiter
Avatar
Rank Points: 406
Registered: 01-27-2017
IP: Logged
icon Scripting question - how can I share vars across NPCs? (+3)  
Hi y'all,

Title sums it up. I'm working on a project involving several NPCs that should react to one another.
In particular, I want to make a token that tells other NPCs to start/stop moving. Now I can make a token that sets a var when I step on it. But the other NPCs are stubborn and don't respond to the changes in the var.

I guess there should (?) be a way to declare a room-global var that can be seen/edited by all NPCs in the room? Or am I missing something important here?

On a related note: I would like NPCs to turn in response to arrow tokens. But I haven't found a way of detecting CW/CCW arrow-token-trigger by the player. Again: am I missing the obvious?

Any help is much appreciated.

____________________________
Autocorrect is not my friend. Apologies for the typos.
07-17-2018 at 02:51 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4592
Registered: 02-20-2007
IP: Logged
icon Re: Scripting question - how can I share vars across NPCs? (+1)  
Variables are global by default, so something else is wrong with your script (maybe an infinite loop?) You should post the room in question so we can have a look at the scripts.

For turning in response to arrow rotators, you could use Wait for item Force arrow to query the direction a particular arrow is pointing.

____________________________
50th Skywatcher
07-17-2018 at 02:57 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Dying Flutchman
Level: Smiter
Avatar
Rank Points: 406
Registered: 01-27-2017
IP: Logged
icon Re: Scripting question - how can I share vars across NPCs? (0)  
I bet it's an infinite loop. As always :) Will have a good look and post again when I can't get it to work.

Will also try the workaround with the arrow querying (is that a verb?) rotator token.

Tnx

____________________________
Autocorrect is not my friend. Apologies for the typos.
07-17-2018 at 04:03 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Dying Flutchman
Level: Smiter
Avatar
Rank Points: 406
Registered: 01-27-2017
IP: Logged

File: testing vars.hold (11.5 KB)
Downloaded 42 times.
License: Public Domain
icon Re: Scripting question - how can I share vars across NPCs? (0)  
Still stuck on this one.

Demo hold attached. The button changes orientation to show on/off and also set the ".MiniMinerState" variable.

The MiniMiner looks at the state and decides to move (or do nothing).

Can't see what I'm messing up here.

Any ideas?

____________________________
Autocorrect is not my friend. Apologies for the typos.

[Last edited by Dying Flutchman at 07-17-2018 10:27 PM]
07-17-2018 at 10:26 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2670
Registered: 07-11-2014
IP: Logged
icon Re: Scripting question - how can I share vars across NPCs? (+3)  
Variables are global by default, unless you put a period in front of the name, then it's local.

From the in-game documentation:
Starting a variable name with a period ('.') configures it as a local variable instead of a global. This means each NPC will have its own version of a variable with this name and there is no value sharing among them.

If you want this to be global, don't put a period at the front of its name.
07-17-2018 at 10:47 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Dying Flutchman
Level: Smiter
Avatar
Rank Points: 406
Registered: 01-27-2017
IP: Logged
icon Re: Scripting question - how can I share vars across NPCs? (+1)  
O noes!

I use the powers to make sure my own variables are nicely clustered together at the tool of the list... Didn't even think of any extra meaning :no

Many thanks to both of you.

____________________________
Autocorrect is not my friend. Apologies for the typos.
07-17-2018 at 11:24 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : Scripting question - how can I share vars across NPCs?
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.