New update to the module! The update is the awareness now includes a generalized description of the terrain!
--[[--{
[1] = "I observe that, I am walking on basalt.",
[2] = "What I see is the environment has a meager amount of ground, a meager amount of cracked lava, a sparse amount of limestone, clusters of sand, a ton of rock, and heaps of basalt.",
[3] = "I am observing I believe, we are in an area called Island of Morgan, the center is near at the current elevation as me to the east.",
[4] = "What I see is a Crystal not far to the east.",
[5] = "I can see that, piece of small rock embedded with a Dragonstone is to the east.",
[6] = " We are in a place called Island of Morgan. There is a Crystal near eastward.",
[7] = "What I notice is I am walking on basalt, the environment has a meager amount of ground, a meager amount of cracked lava, a sparse amount of limestone, clusters of sand, a ton of rock, and heaps of basalt , I believe, we are in an area called Island of Morgan, the center is near at the current elevation as me eastward, a Crystal near eastward, piece of small rock embedded with a Dragonstone is eastward. ",
[8] = "We are in a place called Island of Morgan, the center is close at the current elevation as me to the east",
[9] = "If my eyes don't deceive me, I am walking on basalt, the environment has a meager amount of ground, a meager amount of cracked lava, a sparse amount of limestone, clusters of sand, a ton of rock, and heaps of basalt, we are in a place called Island of Morgan, the center is close at the current elevation as me to the east, and a Crystal close to the east. "--]]--
With this function it counts all of the materials then judges them based off a judgement matrix representing thresholds for the generalization.
function aware.judge.terrain(root,radius)
local function detecter(material)
local materel={}
--print(material)
local nummats=0
for i,v in material do
if material[i] then
if i~="Size" then
--if material[i][1] then
for t,o in material[i] do
for c,p in material[i][t] do
--if --material[i][t][c]~=Enum.Material.Water and
if material[i][t][c]~=Enum.Material.Air then --count all of the terrain
local matstring = string.split(tostring(material[i][t][c]),'Enum.Material.')[2]
if matsolutions[matstring]~=nil then
matstring= matsolutions[matstring]
end
if materel[matstring]==nil then
nummats+=1
materel[matstring]=1
else
materel[matstring]+=1
--table.sort(materel,function(a,b)return a>b end)--sort greatest to
end
--return true
end
end
end
end
end
end
--least
print(materel)
--create an array with the keys
local keys = {}
for k in pairs(materel) do
table.insert(keys, k)
end
--sort the array using a custom comparison function
table.sort(keys, function(a, b) return materel[a] < materel[b] end)
--print the sorted table
--table.sort(materel,function(a,b)return a>b end)--sort greatest to
--table.sort(materel,function(a,b)return a>b end)--sort greatest to least
local judgeamntstrings = {
{"a handful of", "a few", "a smattering of", "a sprinkling of"},
{"a little bit of", "a trace of", "a touch of", "a dash of"},
{"a sparse amount of", "a scant amount of", "a meager amount of", "a minimal amount of"},
{"bunches of", "clusters of", "groups of", "packs of"},
{"a lot of", "heaps of", "a ton of", "loads of"},
{"a multitude of", "a plethora of", "hordes of", "heaps of"},
{"a huge quantity of", "a massive amount of", "a colossal amount of", "a prodigious amount of"},
{"a staggering number of", "an astonishing number of", "a phenomenal number of", "a mind-blowing number of"}
}
local judgementstring=""
local index=0
--{1, 2, 3, 4, 5, 6, 8}
local judgmatrix={1,radius,radius*5,radius*10,radius*20,radius*30,radius*40,radius*50}
--for i, k in ipairs(keys) do
-- print(k,)
--end
for i,k in keys do
index=index+1
if index==nummats then
judgementstring..="and "
end
judgementstring..=aware.judge.amnt( materel[k],judgeamntstrings,judgmatrix).." "..k:lower()
if index~= nummats then
judgementstring..=", "
end
end
return judgementstring
end
local region = Region3.new(root.Position-Vector3.new(radius,radius,radius),root.Position+Vector3.new(radius,radius,radius))
local material = terrain:ReadVoxels(region, 4)
-- detecter(material)
--phraselib.opener[aware.mathrandom(1,#phraselib.opener)]
return detecter(material)
end
function aware.get.terrain(root,radius,str)
local phrases = {
"The environment has",
"The terrain consists of",
"The surroundings is characterized by",
"The landscape features",
"The ecosystem hosts",
}
if radius~=true then
if str~=nil then
--rewrite the table in the first person context
return phrases[math.random(1,#phrases)].." "..str..". "
end
return phrases[math.random(1,#phrases)].." "..aware.judge.terrain(root,radius)..". "
elseif radius==true then
return phrases[math.random(1,#phrases)]:lower().." "..str..""
end
end
In addition, this module also observes the water in particular
function aware.judge.water(root)
-- Loop through the directions and cast rays
local origin=root.CFrame:ToWorldSpace(CFrame.new(0,5,0)).Position--go above the part to get a better angle
for i, dir in ipairs(waterdirections) do
local result = workspace:Raycast(origin, dir, params)
-- Check if the ray hit anything
if result then
-- Check if the hit part is water terrain
if result.Instance:IsA("Terrain") and result.Material == Enum.Material.Water then
local magn=(origin-result.Position).Magnitude
local dist, dir = aware.judge.distance(root,magn, origin, result.Position, range)
return phraselib.waterdescription[math.random(#phraselib.waterdescription)] .. dist .. " to the " .. dir.."",magn
end
end
end
return "",nil
end
Finally all of the phrases has been cleaned up into a libraries that are descendant modules of the awareness module. This should increase the readability of the module.
Some final notes are that this module is designed with the specific object catagories in mind to add extra general flair. But I have created a new way to describe certain objects
local function describeDungeons()--describes the closest 3 furnitures that are not the closest one.
local FurnitureText = ""
if numDungeons > 1 and closestDungeon and Dungeonarray then
--table.sort(Furnarray,function(a,b) return a.Ma)
--local length=3
local iterations=0
local maxiterations=math.min(#Dungeonarray,3)
for i,closeFurniture in Dungeonarray do
if closeFurniture.maininstance~=closestDungeon then
iterations+=1
-- table.insert(arealist,{maininstance=list[h],instance=c,size=g,distance=calc})
if iterations>=2 then FurnitureText=FurnitureText..", " end
local dist, dir = aware.judge.distance(root,closeFurniture.distance, pos, getroot2(closeFurniture.maininstance).Position, 200)
FurnitureText = FurnitureText..aware.judge.object(closeFurniture.maininstance) .. " " .. dist .. "" .. dir
if iterations>=maxiterations then break end
end
end
-- end
end
return FurnitureText
end
This describes the closest 2 other objects instead of generalizing the amount of other objects.
In addition this module can now be used with the chatmodule I published, to query the environment.
It also is now compatible with Determinant AIs chatGPT plugin.