Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
hpf3

recieving multiple entities nbt with debug card or commandblockdriver

Question

a mod that uses entities as its marker for where it should spawn special mobs isn't working so i decided to write a script that does the spawning for it, unfortunately i need to set nbt flags for the spawned entities to tell them where the thing they were spawned from is. i have everything working but i am having problems when it comes to getting the nbt of more than one entity as here is the thngs i have found

debug card unclaimed - dosn't return required text

debug card claimed - works great as long as i'm OK with it stopping if i'm offline(which i'm not)

command_block - only returns text for last entity found

also im using while loops instead of for loops because for some reason they weren't executing more than once

command execution code:

local function commandLogger(command)
  writelog("executed command: " .. command)
  commandBlock.setCommand(command)
  local numb,result = commandBlock.executeCommand()
  writelog(tostring(numb) .. tostring(result))
  return numb,result
end

entity counting and cord getting:

local function coordget(rawinfo)
--print(rawinfo)
  local entities = {}
  local segmented = string.gsub(rawinfo,","," ")
  local seperated = text.tokenize(segmented)
  local count = 0
  local i = 1
  while i <= #seperated do
    if seperated[i] == "The" then count = count + 1 end
    if string.sub(seperated[i],1,2) == "x:" then 
      entities[count] = {}
      entities[count][1] = string.sub(seperated[i],3)
    end
    if string.sub(seperated[i],1,2) == "y:" then entities[count][2] = string.sub(seperated[i],3) end
    if string.sub(seperated[i],1,2) == "z:" then 
      entities[count][3] = string.sub(seperated[i],3)
      writelog("found entity at ".. entities[count][1] .." ".. entities[count][2]  .." ".. entities[count][3])
    end
    i = i+1
  end
  writelog("found ".. tostring(#entities))
  return entities
end

spawning code:

local function fairy_circle()
if config[2] then
  commandLogger("/scoreboard players set @e[type=roots:fairy_circle] fairycount 0")
  writelog("fairycount zeroed")
  os.sleep(0.1)
  commandLogger("/execute @e[type=roots:fairy] ~ ~ ~ /scoreboard players add @e[type=roots:fairy_circle,r=20] fairycount 1")
  writelog("counted fairy's")
  os.sleep(0.1)
	local _,raw = commandLogger("/entitydata @e[type=roots:fairy_circle] {}")
	os.sleep(0.1)
	if raw ~= nil then
	  local entities = coordget(raw)
	  local i=1
	  while i <= #entities do
	    writelog("starting fairy spawn for pool: " .. tostring(#entities) .. " at: ".. entities[i][1] .." ".. entities[i][2]  .." ".. entities[i][3])
        local rand = math.random(3)
	    local nbt = "{variant:".. rand ..",spawnX:".. entities[i][1] ..",spawnY:".. entities[i][2] ..",spawnZ:".. entities[i][3] .."}"
	    writelog("summoning fairy with nbt: " .. nbt)
	    commandLogger("/execute @e[score_fairycount=50] ~ ~ ~ /summon roots:fairy ~ ~ ~ " .. nbt)
    	i=i+1
	  end
	end
  end
end

my last log file:

log start
loaded object data: {{"test",true},{"test2",true}}
2 objects loaded
clicked button: fairycircle
executed command: /scoreboard players set @e[type=roots:fairy_circle] fairycount 0
2.0[09:10:38] Set score of fairycount for player b74ae6cb-3bc8-4f9c-8f70-3a32f9fdb4d4 to 0
fairycount zeroed
executed command: /execute @e[type=roots:fairy] ~ ~ ~ /scoreboard players add @e[type=roots:fairy_circle,r=20] fairycount 1
0.0
counted fairy's
executed command: /entitydata @e[type=roots:fairy_circle] {}
0.0[09:10:38] The data tag did not change: {Motion:[0:0.0d,1:0.0d,2:0.0d],ForgeData:{SpongeData:{Creator:{UUIDMost:3587601093716626784L,UUIDLeast:-5463341182647024187L}}},UUIDLeast:-8110918938277333804L,Invulnerable:0b,Air:0s,OnGround:0b,Dimension:0,idList:[],PortalCooldown:0,Rotation:[0:0.0f,1:0.0f],UpdateBlocked:0b,FallDistance:0.0f,UUIDMost:-5239121455936417892L,Pos:[0:-330.0d,1:60.0d,2:-954.0d],repList:[],Fire:0s,x:-330,ForgeCaps:{llibrary:extendedentitydatacapability:{}},y:60,z:-954,time:681414,initedPosition:1b}
found entity at -330 60 -954
found 1
starting fairy spawn for pool: 1 at: -330 60 -954
summoning fairy with nbt: {variant:2.0,spawnX:-330,spawnY:60,spawnZ:-954}
executed command: /execute @e[score_fairycount=50] ~ ~ ~ /summon roots:fairy ~ ~ ~ {variant:2.0,spawnX:-330,spawnY:60,spawnZ:-954}
2.0[09:10:39] Object successfully summoned

here is the full script if anybody needs it:

autorun.lua

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

sofar i have managed to get arround this by repeatedly retrieving and storing data from

commandLogger("/scoreboard players tag @e[type=" .. targetentity .. ",tag=!scanned,c=1] add scanning")
_,result = commandLogger("/entitydata @e[type=" .. targetentity .. ",tag=scanning] {}")
commandLogger("/scoreboard players tag @e[tag=scanning] add scanned")
commandLogger("/scoreboard players tag @e[tag=scanning] remove scanning")

 

but this is far from optimal

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.