Difference between revisions of "Talk:Angeldust"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
m (Temporary Links)
(Search for a Creature in all Biome flat text data files: new section)
Line 10: Line 10:
 
*[[Angeldust - Message to Firefly 2020021701]]
 
*[[Angeldust - Message to Firefly 2020021701]]
 
*[[Angeldust: Create a New Player Account on Mobile]]
 
*[[Angeldust: Create a New Player Account on Mobile]]
 +
 +
== Search for a Creature in all Biome flat text data files ==
 +
 +
<nowiki>#!/bin/bash</nowiki>
 +
<nowiki>#December 2019 Derek W</nowiki>
 +
<nowiki>#assign path variables</nowiki>
 +
<nowiki>#The path to your biome data files and your operating system temp directory</nowiki>
 +
<nowiki>strBiomeDataFiles="/home/username/Documents/Angeldust/biomes"</nowiki>
 +
<nowiki>strOSTmpDir="/tmp"</nowiki>
 +
<nowiki></nowiki>
 +
<nowiki>echo "whereis: Biome database search tool v0.10"</nowiki>
 +
<nowiki>declare -i intBiome=0</nowiki>
 +
<nowiki></nowiki>
 +
<nowiki>if [ -z $1 ] ; then</nowiki>
 +
<nowiki>  echo "whereis: too few arguments"</nowiki>
 +
<nowiki>  echo "whereis creature name"</nowiki>
 +
<nowiki>  echo " "</nowiki>
 +
<nowiki>  echo "One or two argunments accepted, such as \"whereis Ocelot \" or  \"whereis Cave Bear \"."</nowiki>
 +
<nowiki>  echo " "</nowiki>
 +
<nowiki>  echo "arguments are not case sensitive. "</nowiki>
 +
<nowiki>  exit 0</nowiki>
 +
<nowiki></nowiki>
 +
<nowiki>else</nowiki>
 +
<nowiki>  if [ -z $3 ] ; then </nowiki>
 +
<nowiki>    if [ -z $2 ] ; then </nowiki>
 +
<nowiki>      grep -i $1 ${strBiomeDataFiles}/* > ${strOSTmpDir}/angeldust.biomes.tmp</nowiki>
 +
<nowiki>    else</nowiki>
 +
<nowiki>      grep -i "$1 $2" ${strBiomeDataFiles}/* > ${strOSTmpDir}/angeldust.biomes.tmp</nowiki>
 +
<nowiki>    fi</nowiki>
 +
<nowiki>    intBiome=`wc -l <${strOSTmpDir}/angeldust.biomes.tmp`</nowiki>
 +
<nowiki>    if [ $intBiome -gt 0 ] ; then</nowiki>
 +
<nowiki>      printf "total matching biomes: " </nowiki>
 +
<nowiki>      echo $intBiome</nowiki>
 +
<nowiki>      awk -i inplace 'BEGIN { FS="biomes/"; } {print $2}' ${strOSTmpDir}/angeldust.biomes.tmp</nowiki>
 +
<nowiki>      echo "----------------------------------------"</nowiki>
 +
<nowiki>      awk 'BEGIN { FS=".txt:"; } {print $2 " is found in " $1}' ${strOSTmpDir}/angeldust.biomes.tmp</nowiki>
 +
<nowiki>    else</nowiki>
 +
<nowiki>      echo "----------------------------------------"</nowiki>
 +
<nowiki>      echo "No match! Try again."</nowiki>
 +
<nowiki>    fi</nowiki>
 +
<nowiki>    echo "----------------------------------------"</nowiki>
 +
<nowiki>  else</nowiki>
 +
<nowiki>    echo "whereis: too many arguments, aborting."</nowiki>
 +
<nowiki>    exit 127;</nowiki>
 +
<nowiki>  fi</nowiki>
 +
<nowiki>fi</nowiki>
 +
<nowiki></nowiki>
 +
<nowiki>rm ${strOSTmpDir}/angeldust.biomes.tmp</nowiki>
 +
<nowiki></nowiki>
 +
<nowiki>exit 0;</nowiki>

Revision as of 15:18, 22 March 2020

smart blocks

smart block logic

Smartblockfail01.png

Temporary Links

Search for a Creature in all Biome flat text data files

#!/bin/bash

#December 2019 Derek W
#assign path variables
#The path to your biome data files and your operating system temp directory
strBiomeDataFiles="/home/username/Documents/Angeldust/biomes"
strOSTmpDir="/tmp"

echo "whereis: Biome database search tool v0.10"
declare -i intBiome=0

if [ -z $1 ] ; then
   echo "whereis: too few arguments"
   echo "whereis creature name"
   echo " "
   echo "One or two argunments accepted, such as \"whereis Ocelot \" or  \"whereis Cave Bear \"."
   echo " "
   echo "arguments are not case sensitive. "
   exit 0

else
  if [ -z $3 ] ; then 
    if [ -z $2 ] ; then 
      grep -i $1 ${strBiomeDataFiles}/* > ${strOSTmpDir}/angeldust.biomes.tmp
    else
      grep -i "$1 $2" ${strBiomeDataFiles}/* > ${strOSTmpDir}/angeldust.biomes.tmp
    fi
    intBiome=`wc -l <${strOSTmpDir}/angeldust.biomes.tmp`
    if [ $intBiome -gt 0 ] ; then
      printf "total matching biomes: " 
      echo $intBiome
      awk -i inplace 'BEGIN { FS="biomes/"; } {print $2}' ${strOSTmpDir}/angeldust.biomes.tmp
      echo "----------------------------------------"
      awk 'BEGIN { FS=".txt:"; } {print $2 " is found in " $1}' ${strOSTmpDir}/angeldust.biomes.tmp
    else
      echo "----------------------------------------"
      echo "No match! Try again."
    fi
    echo "----------------------------------------"
  else
    echo "whereis: too many arguments, aborting."
    exit 127;
  fi
fi

rm ${strOSTmpDir}/angeldust.biomes.tmp

exit 0;