Can anyone help me with this code? My pet and I need to run faster than the ogre, but I cannot move until after my pet does. Is there a way for me and my pet to move at the same time? Any help would be appreciated.
This is the code I have right now:
var enemy = hero.findNearest(hero.findEnemies());
pet.moveXY(50, 21);
hero.jumpTo(enemy);
hero.moveXY(50,30);
The path to this is confusing me, and I think perhaps it is an overlooked quirk of the two account options. I am not currently signed up for the upgraded account (plan to, but not this month).
I played all the available levels in the forest world, and none of them were āThe Long Roadā, nor have I been able to find that level in any way other than to click the link in Harryās comment. I vaguely recall one previous level with a pet, but do not recall learning any specific commands for the pet, only that it could function as another person to be commanded other than āheroā in commands already used for the hero in previous levels.
I therefore conclude that either a) Iām blind (which is distinctly possible) and the non-upgraded account path didnāt require I complete The Long Road. or b) that level is not accessible to non-upgraded users unless they have a direct link (which seems an odd way to set it up).
It does seem (from my own perspective as an academic tutor) that if one is going to rely on information gained in that level (or group of levels - others seem to be referenced but not named here, but I couldnāt find them either) that one aught to require that level prior to relying on the student possessing that information.
Alternatively if one chooses to eliminate the training level from the un-upgraded accounts, then one aught not to require that game-specific information in order to progress in the un-upgraded path (which Fast and Furri-ous seems to do).
I am also confused because I seem to have a pet (because it has appeared in two levels), but I also seem not to have a pet in that it is grayed out. Also I can not click on it (like I can on my other tools) to find out what phrases it āgrantsā, which would be my usual workaround to solve this lack of information problem.
If I have missed an entire section, can someone please direct me to where I can find it?
Also, is there somewhere I can find a list of the available commands for the pet?
I am about to go play āThe Long Roadā in hopes that will solve my confusion.
UPDATE:
Even more confused.
Seem to be able to get to levels that require the pet (The Long Road via link and Fast and Furri-ous as a required part of the desert), but do not seem to have the .fetch(item) function available in either place.
@AuntJeanne, eventually a large portion of our Pet-based levels will be subscriber exclusive, we are currently testing their completion rates amongst the adventurous public. We have a long chain of Pet levels in the Forest designed to get players familiar with their familiars, and are now starting to expand Pet mechanics into further campaigns. Nearly all Pet levels are not required to advance through the game, and will be optional side-quests and levels for players. The few that will be required are going to be the first few of the Forest branch to demonstrate what players are missing out on by not being subscribers.
In our Classroom version this whole process will be streamlined so students will learn Event callbacks by the time they finish Course 2, and can use this knowledge to complete future levels we may include in further courses.
If youāre having trouble seeing the pet APIs, itād be great if you included a screenshot and expected behavior and submitted a bug report at our issue tracker on GitHub: https://github.com/codecombat/codecombat/issues
Iāve looked back to long-road, thatās actually a bit confusing to me as well: pet.on('spawn', fetchPotions) looks like a hook registry to me.
But I didnāt trigger the event my self.
Looks like itās registering the hook and triggering it at the same timeā¦
Or have I missed something?
Hey guys, yeah, the ones who know very well how to codeā¦
To us beginners who have only a few months of coding experience, all the knowledge that you take for granted is not very obvious.So please donāt be so cryptic
For the sake of our learning, can you please delineate what pet functions are available?
The fetchItem function is great, but that function is useless in the Fast and the Furry-ous because there is nothing for the pet to fetch.
I have tried using flags for the hero to move without the pet, and that didnt work
any other hints please?
# spoiler
# create a `petMove` function with `event` argument
# implement it with pet's `moveXY` method
# rigster `spawn` event with `petMove` function
If you canāt figure out with the above spoiler, please PM me and I can explain further.
@Sinogermany,
Thank you very much for this, I initially created a function for the pet to chase the enemy, and the one thing that I forgot to do was type āeventā in the parenthesis at the end of the function.
why is it important to have ātargetā or āeventā in the parenthesis of our functions?
@Chef9529 I do not see where the event is required when creating the function.
However it looks like the event object can have the following structure:
event {
type : "spawn",
target : Object
}
The event object gets passed to the function that is used for the call back. If we choose to have event in the parenthesis of the function, āa parameterā, then we can make use of the event object in our function.
For example in this particular case:
event.target would be the pet object. Like the hero object the pet object has a pos, health, id, type, etc.
When ever I play this level it keeps telling me that the function petMove is not defined.
-- Use an event handler so pet and hero will both run!
function petMove(event)
pet:moveXY(50, 21)
end
-- Use pet.on("spawn", petMove) instead of petMove().
-- This way your hero and pet will run at the same time.
-- ā Replace this with pet.on("spawn", petMove)
pet.on("spawn", petMove())
hero:moveXY(50, 12)
Please dont revive dead topics. If you have a problem create a new topic but anyway
Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!