AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

sharing User state between Bots

I’m building a game where i want to use Rivescript for the NPCs (non-player characters).

I was thinking to have separate bots with separate brains for each NPC, to keep things a bit cleaner.

however, is there a way to share any type of User state between them?

eg if you talk to a npcA and get some coins, then go to spend these with npcB - is that something the system envisaged?

I saw that you can pass a “scope” when calling macros, so i could pass my own User object (from outside or RS) but how to easily allow bot scripts to do things like <set userCoins=30> and have that passed between bots?

The other method is to use Topics to control which bot you’re talking to and have nameSpacing effectively on the variables. eg npc1_mood and npc2_mood but thats very messy.



  [ # 1 ]

You can use getUservars/setUservar to sync state between the bots, i.e. after doing reply() use getUservars() and then pass the results of that in to the next bot when you get a reply.

The hacky solution would be to mess with the internal JavaScript references, i.e. set botB._users = botA._users, and then both bots would be referring to the exact same data in memory. That probably wouldn’t break anything.


  login or register to react