FG Spreadshirt Swag
Page 1 of 3 123 Last
  1. #1

    Module using "Session.isHost" gets nil?

    I've a very simple extension that lets the DM, on demand, get the "manual roll" menu popup. However I've noticed that "Session.isHost" within this extension doesn't work on CoreRPG and 5e? I tried this with the Live and Test channels. Both give me "nil"

    Code:
    Runtime Notice: s'manager_action_attack_onDemandManualDice.lua' | s'adnd_roll' | nil | bTRUE
    Here is the specific code section. I do the same "Session.isHost" in my ruleset and it works.

    Code:
    function onInit()
      -- replace default roll with adnd_roll to allow
      -- control-dice click to prompt for manual roll
      Debug.console("manager_action_attack_onDemandManualDice.lua","onInit","Initializing");
      ActionsManager.roll = adnd_roll;
      --
    end
    
    -- replace default roll with adnd_roll to allow
    -- control-dice click to prompt for manual roll
    function adnd_roll(rSource, vTargets, rRoll, bMultiTarget)
    
    	-- Debug.console("manager_action_attack_onDemandManualDice.lua","adnd_roll",rSource,vTargets,rRoll,bMultiTarget);
    
    	if #(rRoll.aDice) > 0 then
    
    		Debug.console("manager_action_attack_onDemandManualDice.lua","adnd_roll",Session.isHost,Input.isControlPressed());
    
    		if not rRoll.bTower and (OptionsManager.isOption("MANUALROLL", "on") or (Session.isHost and Input.isControlPressed())) then
    			local wManualRoll = Interface.openWindow("manualrolls", "");
    			wManualRoll.addRoll(rRoll, rSource, vTargets);
    		else
    			local rThrow = ActionsManager.buildThrow(rSource, vTargets, rRoll, bMultiTarget);
    			Comm.throwDice(rThrow);
    		end
    	else
    		if bMultiTarget then
    			ActionsManager.handleResolution(rRoll, rSource, vTargets);
    		else
    			ActionsManager.handleResolution(rRoll, rSource, { vTargets });
    		end
    	end
    end
    See the same behavior in FGU and FGC. (Yes, I tested w/o BetterMenus also :")

    Last edited by celestian; March 4th, 2021 at 21:44.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  2. #2
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Fast check in my extension to MoreCore for S&W - yup, same result:
    Runtime Notice: s'IS HOST=' | nil

    When I threw it into a roller method for quick test:

    function createRoll(sParams)
    Debug.console("IS HOST=", Session.isHost)
    local rRoll = {}
    ...


    This is with CLASSIC though and a couple months old version too. So if it is new, my input if meaningless

  3. #3
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    To throw further info in the pot -

    I searched on isHost in CORE to see if my version uses it. Found some and where it was I said... hmmm... it really needs to work there.

    Tested by adding this to Core's manager_combat:

    Code:
    function onCharDelete(nodeChar)
    Debug.console("delete IS_HOST=", Session.IsHost)
    	if not Session.IsHost then
    		return;
    	end
    ...
    and it prints in console when I delete a char I added to the CT previously:

    Runtime Notice: s'delete IS_HOST=' | bTRUE


    So... visibility? I'm curious and will look if no answer is posted here by time off from work and eat dinner and can look at this stuff again

  4. #4
    You have a typo, it is a very subtle problem: Session.IsHost, not Session.isHost The i has to be capital

  5. #5
    Quote Originally Posted by Kelrugem View Post
    You have a typo, it is a very subtle problem: Session.IsHost, not Session.isHost The i has to be capital
    The number of times I have made this mistake... 🤦

  6. #6
    Quote Originally Posted by Kelrugem View Post
    You have a typo, it is a very subtle problem: Session.IsHost, not Session.isHost The i has to be capital
    OMG, I must have search/replaced using .IsHost but did .isHost in my extensions ;( .... also, why is it IsHost and not isHost ;(

    Thanks for catching it.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  7. #7
    Quote Originally Posted by celestian View Post
    OMG, I must have search/replaced using .IsHost but did .isHost in my extensions ;( .... also, why is it IsHost and not isHost ;(

    Thanks for catching it.
    isHost was the style when it was a function, but now it's a global variable.

  8. #8
    Quote Originally Posted by bmos View Post
    isHost made sense when it was a function, but now it's a global variable.
    I don't code by trade so perhaps I have a gap in my knowledge here but... Why would naming change in that case. I don't think I've ever noticed that sorta thing in JS/lua/python/perl/c# that I recall but... as I said, I don't "code" for a living.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  9. #9
    Quote Originally Posted by celestian View Post
    I don't code by trade so perhaps I have a gap in my knowledge here but... Why would naming change in that case. I don't think I've ever noticed that sorta thing in JS/lua/python/perl/c# that I recall but... as I said, I don't "code" for a living.
    Typically that sort of thing is supposed to make code more clear.
    Like this.

  10. #10
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    OMG - didn't see that lol - since I by habit use camel-case.

    The casing preferences (speaking from old days - not up with current languages) was usually (ignoring the old Microsoft so-called-Hungarian notation system - an abomination - not to be confused with Moon's Hungarian because 1) it is more sensible than ulongVarName or what have you super specific stuff that actually CHANGED as bits changed and they could not DARE go back and change it since it's compiled and APIs with DLLs etc...but I digress - it always annoyed me when something that is an int was called a long etc....) camel case for C++ variables and methods with Pascal case for Classes and CTORs (and properties in languages with such things) - Pascal case I cannot recall who primarily used it (besides one assumes Pascal but that was 80s, I remember none of that) for members.

    I personally stuck to camel with Pascal only for classes/class-like things and by extension CTORs because they have to match.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in