So this will not function in FGU (this is current FGC)?
https://i.imgur.com/TQaDsIe.png
Printable View
So this will not function in FGU (this is current FGC)?
https://i.imgur.com/TQaDsIe.png
It's supposed to be in whole grid units (multiplied by base units). If not, then FGC is not working as intended.
Also, I'm not sure how you got that to appear like that in your version, since it does not do that when I try in CoreRPG, 3.5E or 5E on FGC.
Thanks,
JPG
Only bringing this up because you told me to not make kludges around FGU when FGC works another way.
To be clear this is not untouched ruleset, it's related to the unit/suffix code. I had it already in the AD&D ruleset. I updated the code to function within FGU (with your new API functions) and FGC.
I added this script to the image_record class.
Code:<!-- standard image template -->
<template name="image_record">
<image_record_step>
<bounds>21,63,-27,-29</bounds>
<script file="campaign/scripts/image_record.lua"/>
</image_record_step>
</template>
All I added recently was the round bit to get rid of that large float value.Code:--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--
function onInit()
--
if Interface.getVersion() >= 4 then
if User.isHost() then
local node = getDatabaseNode();
DB.addHandler(DB.getPath(node.getParent(), "muse_unitsize_number"), "onUpdate", onUnitSizeUpdates);
DB.addHandler(DB.getPath(node.getParent(), "muse_suffix_string"), "onUpdate", onUnitSizeUpdates);
DB.addHandler(DB.getPath(node.getParent(), "locked"), "onUpdate", onLockChanged);
onUnitSizeUpdates(node);
onLockChanged(node);
end
end
-- when the map is loaded setup these.
TokenManagerADND.updateCTEntries();
end
function onClose()
if Interface.getVersion() >= 4 then
if User.isHost() then
local node = getDatabaseNode();
DB.removeHandler(DB.getPath(node.getParent(), "muse_unitsize_number"), "onUpdate", onUnitSizeUpdates);
DB.removeHandler(DB.getPath(node.getParent(), "muse_suffix_string"), "onUpdate", onUnitSizeUpdates);
DB.removeHandler(DB.getPath(node.getParent(), "locked"), "onUpdate", onLockChanged);
end
end
end
-- update size/suffix on the map when they are reconfigured.
function onUnitSizeUpdates(node)
node = node.getParent();
--local node = getDatabaseNode().getParent();
setDistanceBaseUnits(tostring(DB.getValue(node,"muse_unitsize_number","5")));
setDistanceSuffix(DB.getValue(node,"muse_suffix_string","ft"));
--getDistanceBaseUnits() = current base units (override if >0; otherwise ruleset value)
--getDistanceSuffix() = current suffix value (override if not nil; otherwise ruleset value)
--Debug.console("image_record.lua","onUnitSizeUpdates","getDistanceBaseUnits()",getDistanceBaseUnits());
--Debug.console("image_record.lua","onUnitSizeUpdates","getDistanceSuffix()",getDistanceSuffix());
end
-- when the map unlocked show the size/suffix fields.
function onLockChanged()
local node = getDatabaseNode().getParent();
--Debug.console("image_record.lua","onLockChanged","node",node);
local bUnLocked = DB.getValue(node, "locked", 0) == 0;
window.header.subwindow.muse_unitsize_label.setVisible(bUnLocked);
window.header.subwindow.muse_unitsize_number.setVisible(bUnLocked);
window.header.subwindow.muse_suffix_label.setVisible(bUnLocked);
window.header.subwindow.muse_suffix_string.setVisible(bUnLocked);
end
-- get the unit scale and measurement
function getUnitControlSetting()
local sValue = '5ft';
if Interface.getVersion() < 4 then
local node = getDatabaseNode().getChild("..");
sValue = DB.getValue(node,"scale","10ft"); -- default to 10ft here but we should never see this.
else
sValue = getDistanceBaseUnit() .. getDistanceSuffix();
end
return sValue;
end
-- is the scale value VALID?
function getUnitControlisValid()
local bValid = false;
if Interface.getVersion() < 4 then
bValid = getUnitControlSetting():find("^[%d%.]+") ~= nil
else
bValid = true;
end
return bValid;
end
-- get the size of each unit
function getUnitControlValue()
local nScaleValue = 0;
if Interface.getVersion() < 4 then
if getUnitControlisValid() then
nScaleValue = tonumber(getUnitControlSetting():match("^([%d%.]+)")) or 0
end
else
nScaleValue = getDistanceBaseUnit() or 5;
end
return nScaleValue;
end
-- get the scale measurement name/string
function getUnitControlLabel()
local sValue = "ft";
if Interface.getVersion() < 4 then
sValue = StringManager.trim(getUnitControlSetting():gsub("^[%d%.]+%s*", ""))
else
sValue = getDistanceSuffix();
end
return sValue;
end
-- measureVector
function measureVector(nVectorX, nVectorY, sGridType, nGridSize, nGridHexWidth, nGridHexHeight)
local nDiag = 1;
if OptionsManager.isOption("HRDD", "variant") then
nDiag = 1.5;
end
local nDistance = 0
if sGridType == "hexrow" or sGridType == "hexcolumn" then
local nCol, nRow = 0, 0
if sGridType == "hexcolumn" then
nCol = nVectorX / (nGridHexWidth*3)
nRow = (nVectorY / (nGridHexHeight*2)) - (nCol * 0.5)
else
nRow = nVectorY / (nGridHexWidth*3)
nCol = (nVectorX / (nGridHexHeight*2)) - (nRow * 0.5)
end
if ((nRow >= 0 and nCol >= 0) or (nRow < 0 and nCol < 0)) then
nDistance = math.abs(nCol) + math.abs(nRow)
else
nDistance = math.max(math.abs(nCol), math.abs(nRow))
end
else -- if sGridType == "square" then
local nDiagonals = 0
local nStraights = 0
local nGridX = math.abs(nVectorX / nGridSize)
local nGridY = math.abs(nVectorY / nGridSize)
if nGridX > nGridY then
nDiagonals = nDiagonals + nGridY
nStraights = nStraights + nGridX - nGridY
else
nDiagonals = nDiagonals + nGridX
nStraights = nStraights + nGridY - nGridX
end
nDistance = nDiagonals * nDiag + nStraights
end
return nDistance
end
-- when measuring a vector distance
function onMeasureVector(token, aVector)
if hasGrid() then
local sGridType = getGridType()
local nGridSize = getGridSize()
local nDistance = 0
if sGridType == "hexrow" or sGridType == "hexcolumn" then
local nGridHexWidth, nGridHexHeight = getGridHexElementDimensions()
for i = 1, #aVector do
local nVector = measureVector(aVector[i].x, aVector[i].y, sGridType, nGridSize, nGridHexWidth, nGridHexHeight)
nDistance = nDistance + nVector
end
else -- if sGridType == "square" then
for i = 1, #aVector do
local nVector = measureVector(aVector[i].x, aVector[i].y, sGridType, nGridSize)
nDistance = nDistance + nVector
end
end
if getUnitControlisValid() then
--return (nDistance * getUnitControlValue()) .. getUnitControlLabel();
return (UtilityManagerADND.round(nDistance * getUnitControlValue())) .. getUnitControlLabel()
else
return ""
end
else
return ""
end
end
-- when measuring a pointer distance
function onMeasurePointer(nLength, sPointerType, nStartX, nStartY, nEndX, nEndY)
if hasGrid() then
local sGridType = getGridType()
local nGridSize = getGridSize()
if sGridType == "hexrow" or sGridType == "hexcolumn" then
local nGridHexWidth, nGridHexHeight = getGridHexElementDimensions()
nDistance = measureVector(nEndX - nStartX, nEndY - nStartY, sGridType, nGridSize, nGridHexWidth, nGridHexHeight)
else -- if sGridType == "square" then
nDistance = measureVector(nEndX - nStartX, nEndY - nStartY, sGridType, nGridSize)
end
if getUnitControlisValid() then
return (UtilityManagerADND.round(nDistance * getUnitControlValue())) .. getUnitControlLabel()
else
return ""
end
else
return ""
end
end
It now looks like this. If I updated the MUSE extension it would do the same for CoreRPG/etc.
https://i.imgur.com/mIm6YuY.png
It's because you are measuring your own vectors that you were seeing the large numbers; and the half measures.
The built-in measuring and the way the original onMeasureVector was supposed to work before we built it into the client is that it was based on grid squares first, then multiplied by base units.
Regards,
JPG
I touched this tonight to see if there had been any changes related to the issue of tweaking the value in FGU.
You'll notice in this image a problem.
https://i.imgur.com/YV4QMgN.png
The left image is the image from the module. The right image is the image I copied locally from the module.
The problem with left version is even when the image is unlocked it doesn't trigger the handler to set the input blocks visible.
The right version does trigger the handler and it's visible.
Looks like the moduledb/* version doesn't have a "locked" value.
In the GURPS ruleset we display a calculated Range Attack modifier at the end of the pointer suffix. It is also displayed on the pointers displayed when viewing targeted tokens.
Attachment 32228
Is there a way to get the get the length of a pointer from the built-in measuring, without having to do measuring of the vectors? If not, it would be great, if at some point, it was. Even better would be some API overrides like.
function onPointerLengthChanged(length, pointertype)
Parameters:
length (number) The length of the pointer in base units.
pointertype (string) The type of the pointer: "arrow", "circle", "cone", "rectangle"
Return value:
(string) The label applied to the pointer.
function onVectorLengthChanged(token, vector)
Parameters:
token (tokeninstance)
vector (table) A table of the lengths of path segments in a vector.
Return value:
(string) The label applied to the vector.
Those events, ideally, should only trigger when the length changes as opposed to the current onMeasurePointer, which happens each screen redraw. Another potential bonus it could allow for each pointer to have different labels.