Jump to content

Welcome to Gaming On Steroids Forums
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account
Photo

for loop stops after first Champion


  • Please log in to reply
7 replies to this topic

#1
Swagoverflow

Swagoverflow

    Member

  • Members
  • 28 posts
OnLoad(function()
	for _,enemy in pairs(GetEnemyHeroes()) do
	    PrintChat(GetObjectName(enemy))
	end
end)

This print's the first Champion (e.g.: Shen) in the list and then stops printing. I tried it in various places (just to check also in OnTick) and also tried printing i(/"_"). 

Same Result everytime. Am i missing something here? 


  • 0

#2
Noddy

Noddy

    Surrender The Throne

  • Scripts Developer
  • 500 posts

Its bit weird but add a small delay and see if it helps.

OnLoad(function()

 DelayAction(function()
    for _,enemy in pairs(GetEnemyHeroes()) do
     PrintChat(GetObjectName(enemy))
    end
 end,1)

end)


  • 0

#3
Swagoverflow

Swagoverflow

    Member

  • Members
  • 28 posts

Its bit weird but add a small delay and see if it helps.

OnLoad(function()

 DelayAction(function()
    for _,enemy in pairs(GetEnemyHeroes()) do
     PrintChat(GetObjectName(enemy))
    end
 end,1)

end)

 

 

Yeah, that worked. Thanks!

Any Idea why you need to do it like this? Doens't make sense to me. Or "Just GoS Things"? 


  • 0

#4
Noddy

Noddy

    Surrender The Throne

  • Scripts Developer
  • 500 posts

I think bcs GetEnemyHeroes() is a custom function that needs to be looped aswell. So if you use that function before it adds all champions into the table it will break


  • 0

#5
Fl0at

Fl0at

    Reseller

  • Members
  • 604 posts

GetEnemyHeroes is being populated at the same time as you try to loop through it. Delay it by one tick (put 0 in the DelayAction) and it should all work fine


Edited by Fl0at, 25 June 2017 - 08:53 .

  • 0

#6
Swagoverflow

Swagoverflow

    Member

  • Members
  • 28 posts

GetEnemyHeroes is being populated at the same time as you try to loop through it. Delay it by one tick (put 0 in the DelayAction) and it should all work fine

 

50124d2d7c1f56bddefb7c4884f4b206.png

 

55003dd81b5f845fb27b14a3283d71e3.png


  • 0

#7
Fl0at

Fl0at

    Reseller

  • Members
  • 604 posts

50124d2d7c1f56bddefb7c4884f4b206.png

 

55003dd81b5f845fb27b14a3283d71e3.png

"GetEnemyHeroes is being populated at the same time as you try to loop through it." and now be grateful people try to help you


  • 0

#8
Swagoverflow

Swagoverflow

    Member

  • Members
  • 28 posts

"GetEnemyHeroes is being populated at the same time as you try to loop through it." and now be grateful people try to help you

 

3ee11aa4727c27a082a6776fcf1aaef3.png


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users