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

Quick question about table indexes


Best Answer Deftsu , 27 January 2017 - 09:25

except for Game.Object and buffs everything start from 1 Go to the full post »


  • Please log in to reply
3 replies to this topic

#1
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Does GoS EXT API consistently follows lua index convention (start at 1) or does it follow C convention (start at 0) or there's no consistency and we should know with wich table we're dealing with?

 

example: unit:GetBuff(index). is index from 1 to buffCount?


  • 0

#2
Feretorix

Feretorix

    Administrator

  • Administrators
  • 3,177 posts
Hello, looping trought buffs is probably one of the least exceptions where you start from 0.
Because the Game has been coded in C++ and we need to follow their way.

An example taken directly from 8-official-Activator.lua
 
for i = 0, 63 do
		local buffData = myHero:GetBuff(i);
		if buffData.count > 0 then
			if (buffData.type == 13) or (buffData.type == 26) then --HealBuffType or Counter
				if (buffData.name == "ItemDarkCrystalFlask") or (buffData.name == "ItemCrystalFlaskJungle") or (buffData.name == "ItemCrystalFlask") or (buffData.name == "ItemMiniRegenPotion") or (buffData.name == "RegenerationPotion") then
					currentlyDrinkingPotion = true;
					break;
				end
			end
		end

On the other hand if you're working with lua tables and such, it suggest looping from 1.
  • 1

#3
Deftsu

Deftsu

    donthackourgames

  • Ex-Core Dev
  • PipPipPip
  • 4,812 posts
✓  Best Answer
except for Game.Object and buffs everything start from 1
  • 0

#4
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Thank you I'll try to remember those


  • 0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users