XenoBot Forums - Powered by vBulletin

User Tag List

Page 4 of 6 FirstFirst ... 23456 LastLast
Results 31 to 40 of 51

Thread: [Discussion] Scripter: Variables, Functions, and Events

  1. #31
    Lifetime Subscriber Efren's Avatar
    Join Date
    Dec 2010
    Location
    Mexico NL, Monterrey
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raphael View Post
    You don't get the fucking id using isTarget(). That only proves they're different things.
    You can't lie to the code, an this proves is the same thing...
    Code:
    function Creature:isTarget()
    	return self._id == getSelfTargetID()
    end
    Quote Originally Posted by Raphael View Post
    What I meant is, find the name of your target WITHOUT directly using getTargetId().
    getTargetId() Doesn't exist, Probably you meant to say getSelfTargetID()

    As I say before "getById(isTarget())" would be the way to get the name of your current target.

    getById() is used to get their name by their id, so writing an id inside the "()" will tell you the name.
    isTarget() will return the id of your current target.

    This can also be written like the following codes.
    Code:
    GetByID(getSelfTargetID())
    --or
    getCreatureNameById(getSelfTargetID())
    --or
    GetByID(isTarget())
    --or
    getCreatureNameById(isTarget())
    an example implemented on a script would be.
    (examples taken from @sirmate all credits for him)
    Code:
    local target = Creature.GetByID(getSelfTargetID())
    --or just the one I made
    local targetname = Creature.GetByID(isTarget())

  2. #32
    Technical Support jo3bingham's Avatar
    Join Date
    Dec 2010
    Posts
    697
    Mentioned
    107 Post(s)
    Tagged
    0 Thread(s)
    Stop arguing before I throw infractions out like a blind squirrel! It doesn't matter if I documented it or not, yet. It's in the Creature class so that means it exists, but I haven't documented it. Calm down, both of you! Good grief, you're like a bunch of babies. Get offline, go ween yourself off your mother's teet, then come back when you've grown up...

  3. #33
    Lifetime Subscriber Efren's Avatar
    Join Date
    Dec 2010
    Location
    Mexico NL, Monterrey
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jo3Bingham View Post
    Stop arguing before I throw infractions out like a blind squirrel! It doesn't matter if I documented it or not, yet. It's in the Creature class so that means it exists, but I haven't documented it. Calm down, both of you! Good grief, you're like a bunch of babies. Get offline, go ween yourself off your mother's teet, then come back when you've grown up...
    It's Done

  4. #34

    Join Date
    Dec 2011
    Posts
    164
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Efren View Post
    You can't lie to the code, an this proves is the same thing...
    Code:
    function Creature:isTarget()
    	return self._id == getSelfTargetID()
    end


    getTargetId() Doesn't exist, Probably you meant to say getSelfTargetID()

    As I say before "getById(isTarget())" would be the way to get the name of your current target.

    getById() is used to get their name by their id, so writing an id inside the "()" will tell you the name.
    isTarget() will return the id of your current target.

    This can also be written like the following codes.
    Code:
    GetByID(getSelfTargetID())
    --or
    getCreatureNameById(getSelfTargetID())
    --or
    GetByID(isTarget())
    --or
    getCreatureNameById(isTarget())
    an example implemented on a script would be.
    (examples taken from @sirmate all credits for him)
    Code:
    local target = Creature.GetByID(getSelfTargetID())
    --or just the one I made
    local targetname = Creature.GetByID(isTarget())
    No dude, one returns a boolean and the other returns a integer. Creature.GetByID(isTarget()) simply won't work.

    @Jo3

    Sorry, I can't help it. Plus, I see no bad, seeing as we're arguing without flaming or bad words.

  5. #35

    Join Date
    Dec 2011
    Posts
    55
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    really, reading the post http://forums.xenobot.net/showthread...ons-and-Events
    and the discussion above, we need a "creature loop".

    One solution "not good" to find the target is:

    Code:
    function targetid()
    	local creature
    	for i = 1, 100000 do
    		creature = Creature.GetByID(i)
    		if creature and creature:isTarget() then
    			return i
    		end
    	end
    	return false
    end
    
    function targetname()
    	local target = targetid()
    	return (target and Creature.GetByID(target):Name)
    end
    PS: not tested because i haven't xenobot.

  6. #36
    Technical Support jo3bingham's Avatar
    Join Date
    Dec 2010
    Posts
    697
    Mentioned
    107 Post(s)
    Tagged
    0 Thread(s)
    @Efren, @Raphael is correct. isTarget() returns a boolean (yes/no), getSelfTargetID() returns the actual ID of your character's target.

    @Blequi, that's a bad, bad way to get it. Just use getSelfTargetID()
    Code:
    local Target = Creature.GetByID(getSelfTargetID())
    ----then use Target:Name() to return your target's name

  7. #37

    Join Date
    Dec 2011
    Posts
    55
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i didn't know the existence of getSelfTargetID(), at least you didn't post.

  8. #38
    Technical Support jo3bingham's Avatar
    Join Date
    Dec 2010
    Posts
    697
    Mentioned
    107 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Blequi View Post
    i didn't know the existence of getSelfTargetID(), at least you didn't post.
    It's in the Creature.lua file that comes with XenoBot when you install it. I just haven't gotten around to adding it to the main post. I apologize, I'm just lazy, haha.

  9. #39

    Join Date
    Dec 2011
    Posts
    55
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jo3Bingham View Post
    It's in the Creature.lua file that comes with XenoBot when you install it. I just haven't gotten around to adding it to the main post. I apologize, I'm just lazy, haha.
    now, I'm very curious to own and read this file.

  10. #40
    Technical Support jo3bingham's Avatar
    Join Date
    Dec 2010
    Posts
    697
    Mentioned
    107 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Blequi View Post
    now, I'm very curious to own and read this file.
    I'm mistaken. DarkstaR, I think, accidentally included it with a previous version of XenoBot, but you can view it here: http://pastebin.com/3vDpZWL3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •