Is there a way to force client to the NPC view selected by the GM?

Developer discussion regarding MapTool 1.4

Moderators: Azhrei, dorpond, trevor

Forum rules
Posting now open to all registered forum users.
Post Reply
N2tZ
Kobold
Posts: 4
Joined: Mon Feb 18, 2019 10:58 am

Is there a way to force client to the NPC view selected by the GM?

Post by N2tZ »

I run a game at my place using my PC to run the GM side of the campaign and one of the players laptop to cast the image to my TV via HDMI.

The players have no access to their client, I control everything from my PC. The thing is, when I select a player token, it shows its vision range on my PC. For example if they are in a dark room and I select a token with no darkvision, my screen only sees a small radius around the token. If I select a token with darkvision, I can see the rest of the room.

But this doesn't translate over to the image on the TV. I can only show individual views when I manually select the tokens on the laptop, which I can't do during the game since the laptop is located on the floor, next to the TV.

Can I somehow force the player side view to match the view of whatever token I have selected?

User avatar
aliasmask
Deity
Posts: 8580
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Is there a way to force client to the NPC view selected by the GM?

Post by aliasmask »

Not within MT because it's on a separate computer. Actually, there may be a way, but it's very cheeky. You would need to send a link to chat which will tell the other client to select your selected token.

User avatar
aliasmask
Deity
Posts: 8580
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Is there a way to force client to the NPC view selected by the GM?

Post by aliasmask »

Code: Select all

@@ @selectMyToken
[H: mySelection = getSelected("json")]
[H: link = macroLink("","[email protected]"+getMacroLocation(),"none",mySelection)]
[R: "&nbsp" + link + "&nbsp"]

!!
@@ @forceSelection
[H: selected = arg(0)]
[H: selectTokens(selected,0,"json")]

!!
These should be put on a lib token and call to selectMyToken() should be put in to campaign window. I would probably assign a hot key as well. You would then select the tokens, hit the hot key and those token are selected on the client computers.

N2tZ
Kobold
Posts: 4
Joined: Mon Feb 18, 2019 10:58 am

Re: Is there a way to force client to the NPC view selected by the GM?

Post by N2tZ »

Thanks for your answer. It sounds really promising.

I'm really new to macros so I'm having some trouble with implementing the code

So I looked into lib tokens.
What I found out is I should first create them by dragging the tokens to any map (I chose my "settings/test" map)
Then rename the tokens to something like Lib:CharacterName
Make the tokens visible to players and set the type to NPC

NOPENOPENOPE Then I tried figuring out how to add macros to the tokens.
From what I understand I had to go to the Campaign properties and add a new Token Type where I could paste the code into the box below, I think?
From copy-pasting the code I got a bunch of errors though /NOPENOPENOPE

Okay, I got closer. I opened up the selection window, selected one of the tokens and added the macro through right-clicking and straight up pasting the code. Then did the same thing in the campaign window but only pasted @selectMyToken

So now in my test map, I have the five Lib:Name tokens for each of my players and I added actual PC tokens, same file, only the name is the PC name without the Lib: in front of it. Changed the type to PC and added vision. I selected one of the tokens, used the hotkey to change the view, the Chat box gave the notification that I selected the token but in my player program, nothing had changed

Did some more digging and found out I should remove the ability to let players edit macros. Did that for each of the lib tokens. Still not working yet.

So far I'm confused about:
What to write in the campaign macro?
Can I have my Lib tokens on one map as NPC's, named Lib:NAME and have them work for other tokens on a different map that have the same name without the "Lib:" part?
Last edited by N2tZ on Fri Feb 22, 2019 3:47 pm, edited 1 time in total.

Phergus
Deity
Posts: 7108
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Is there a way to force client to the NPC view selected by the GM?

Post by Phergus »

You should look at this wiki page on lib:tokens: Library_Token

N2tZ
Kobold
Posts: 4
Joined: Mon Feb 18, 2019 10:58 am

Re: Is there a way to force client to the NPC view selected by the GM?

Post by N2tZ »

So I took a nap and took a new look at the lib tokens wiki page.

I realized I don't need a separate token for all my PC's but only one lib token that has the macros.

Then I re-read aliasmask's code and thought that maybe they provided two codes instead of one. So I made only one lib token, gave it the following macros:
forceSelection

Code: Select all

@@ @forceSelection
[H: selected = arg(0)]
[H: selectTokens(selected,0,"json")]
selectMyToken

Code: Select all

@@ @selectMyToken
[H: mySelection = getSelected("json")]
[H: link = macroLink("","[email protected]"+getMacroLocation(),"none",mySelection)]
[R: "&nbsp" + link + "&nbsp"]
Then I added a macro to the campaign:
Select Token

Code: Select all

[macro ("[email protected]:TokenSel")]
When I tried running that I got an error "Undefined function: macro"
I looked around and pretty much got that there has to be a variable in the last code. Looking at the sample code I tried macro.return but that didn't really work since it asked for a value.
I tried changing it to [macro ("[email protected]:TokenSel"): 1] since that at least gives me no errors

So when I try running the code now this is what I get:
Chat: GMr:@@ @selectMyToken  
It doesn't change the view/selection but when I manually select a token in the player's computer and run the macro on my computer, it deselects the view.

Phergus
Deity
Posts: 7108
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Is there a way to force client to the NPC view selected by the GM?

Post by Phergus »


N2tZ
Kobold
Posts: 4
Joined: Mon Feb 18, 2019 10:58 am

Re: Is there a way to force client to the NPC view selected by the GM?

Post by N2tZ »

Can I ask what these articles will help me with? Just so I know what to look out for or what to keep in mind while reading through them.

Should I make the macros on the library token run on campaign load?

Edit: I also kind of roughly installed the Bag of Tricks set, will this somehow interfere with the oncampaingload stuff?

Sorry for all the questions, I'm just trying to get this thing running with zero knowledge on coding

Edit 2: Okay, I'm watching Into the Spiderverse with my friends and checking up on the wiki site, I might actually get it now. I created the oncampaign load token, so far I understand that I have to create a new macro to the library token that has the following code: "defineFunction(function, macro)", right? My PC crashed before I could test it since it can't handle running two instances of MapTools tho

Phergus
Deity
Posts: 7108
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Is there a way to force client to the NPC view selected by the GM?

Post by Phergus »

First thing. Don't put those @@ or !! lines in your code. That is special formatting for AliasMask's RPEdit macros for pasting in code from NotePad++. The @@ line tells you what he would have named the macro.

Be aware that by jumping into lib:tokens and macrolinks with no other MT macro background you are jumping into the deep end of the pool - with an anchor - and your hands tied behind your back.
N2tZ wrote:
Fri Feb 22, 2019 4:23 pm
Should I make the macros on the library token run on campaign load?
By including a onCampaignLoad macro on your lib:token and then putting in defineFunction calls for each library macro, you make it easier to access those functions.

It's the difference between:

Code: Select all

[r: result = myLibFunction("Bob","Heal")]
and

Code: Select all

[r: var1 = "Bob" ]
[r: var2 = "Heal" ]
[r: passedVars = json.append( "", var1, var2 )] 
[MACRO("[email protected]"): passedVars ]
[r: result = macro.return ] 
Which one is clearer to you?
N2tZ wrote:
Fri Feb 22, 2019 4:23 pm
Edit: I also kind of roughly installed the Bag of Tricks set, will this somehow interfere with the oncampaingload stuff?
No. Each library token can have its own onCampaignLoad macro.
N2tZ wrote:
Fri Feb 22, 2019 4:23 pm
I created the oncampaign load token, so far I understand that I have to create a new macro to the library token that has the following code: "defineFunction(function, macro)", right?
For any macro on your lib:token that you want to call from some other macro, you should add a call to defineFunction() in the onCampaignLoad macro. The wiki page for Wiki: defineFunction() includes an example of how to do it.
N2tZ wrote:
Fri Feb 22, 2019 4:23 pm
My PC crashed before I could test it since it can't handle running two instances of MapTools tho
Any PC made in the last decade can run multiple instances of MapTool without problem.

Lord_Ashes
Kobold
Posts: 15
Joined: Tue Jun 18, 2019 7:43 pm

Re: Is there a way to force client to the NPC view selected by the GM?

Post by Lord_Ashes »

Maybe I am missing your intention but could you not run a GM session and client session on your computer? Have your GM session on one monitor and configure the HDMI TV as a second monitor where you have your client session. If your players only see the HDMI TV then this should work. You get the benefit of a full GM screen but your players only see the client screen.

When you connect both a GM session and a client session (i.e. two instances of MapTool), MapTool will recognize that you are running both sessions on the same PC and display a warning about a loop-back connection (or something similar). However, accepting the warning seems to work fine. I use this method to do testing of my campaign maps and macros (instead of just using the View As Player option).

Post Reply

Return to “MapTool 1.4”