LUA coding style - to self or to hero - which shall it be?

As I was working my way through the Kithgard Dungeon campaign world using only LUA. (free account) I noticed that there were two distinct coding styles:

hero:moveUp()

and

self:moveUp()

Both seemed to work equally well. However the quick lookup for that level would default to using one or the other. So if you were used to typing self:moveUp() and used autocomplete on a level that was demonstrating hero:moveUp() it would autocomplete to self:hero:moveUp() requiring one to then fix their code or manually type all of the code. Or just change to the hero:moveUp() for the levels that demonstrate that kind of code.

This isn’t so bad, but for the fact that you could end up getting a hero or a self level without any source code and not realize it was one or the other, thus forcing you to correct the garbled autocomplete code. This inconsistency just detracts from the game play so I recommend one or the other.

 

So I ask either for a vote or an executive direction. Which should we use? I can then submit patches for all of the free to play levels from Kithgard Dungeon to keep everything the same

@nick @maka @Serg et all?

I wonder if it would be possible to grep the forum and code files to find out how many references exist for each in LUA and then take the dominant used style?

2 Likes

Hey Harry,

It should be hero to be consistent with Python and JavaScript.

We need a hero (do doo dooo doooooo) to update the LUA levels.

Maka

1 Like

@maka ok. so I will need to update the patches I did as they use the self:moveUp() and then I will locate all levels that are using self and update them.

I will post the list here if anyone else wants to help.

(Footloose was a good movie)

2 Likes

List of Kithgard Dungeon campaign levels and which style is used

Free Levels
.1. Dungeons of Kithgard - ( self ) ( hidden )
.2. Gems in the Deep ( self ) ( hidden )
.3. Shadow Guard ( self ) ( shown )
.4. Forgetful Gemsmith ( self ) ( shown )
.5. Signs and Portents ( self ) ( shown )
.6. True Names ( self ) ( shown )

.14. The Raised Sword ( self ) ( shown )
.15. Cell Commentary ( hero ) ( hidden )
.16. Kithgard Librarian ( self ) ( hidden )
.17. Lost in the Stacks ( hero ) ( hidden )
.18. Fire Dancing ( hero ) ( hidden )
.19. Loop Da Loop ( self ) ( hidden )
.20. Haunted Kithmaze ( self ) ( hidden )

.22. The Second Kithmaze ( hero ) ( hidden )
.23. Dread Door ( self ) ( hidden )
.24. Known Enemy ( self ) ( hidden )
.25. Cupboards of Kithgard ( self ) ( hidden )
.26. Cupboards of Kithgard A ( self ) ( hidden )

.28. Master of Names ( hero ) ( hidden )
.29. Mightier Than the Sword ( hero ) ( hidden )
.30. Lowly Kithmen ( self ) ( hidden )
.31. Closing the Distance ( self ) ( hidden )
.32. By Any Other Name ( hero ) ( hidden )
.33. A Mayhem of Munchkins ( self ) ( hidden )

.35. The Final Kithmaze ( self ) ( hidden )
.36. Kithgard Gates ( self ) ( hidden )
.37. The Gauntlet ( self ) ( hidden )
.38. The Gauntlet A ( self ) ( hidden )
.39. Kithgard Mastery ( self ) ( hidden )

.41. Cavern Survival ( hero ) ( hidden )
.42. The Gauntlet B ( self ) ( hidden )
.43. Cupboards of Kithgard B ( self ) ( hidden )

Paid Levels ( unknown as I do not have access )
.7. Kounter Kithwise
.8. Crawlways of Kithgard
.9. Enemy Mine
.10. Illusionary Interruption
.11. Favorable Odds
.12. The Prisoner
.13. Banefire
.21. Descending Further
.27. Hack and Dash
.34. Tactical Strike
.40. Radiant Aura


I have noticed that 4 of the levels show the hero: or self: along with the code part. Was this intentional? Or is there a setting to “not show” that part?

.4. Forgetful Gemsmith ( self ) ( shown )
.5. Signs and Portents ( self ) ( shown )
.6. True Names ( self ) ( shown )
.14. The Raised Sword ( self ) ( shown )

So instead of moveUp() we would see self:moveUp()

I will begin to convert all the levels to use hero: . What I noticed that was a bit odd was that some of the definitions will change from level to level when it comes to the gear. As if the level has a setting that will override to using “self” or “hero” ?

[ Question] Is this correct? Is there a setting to default to one or the other self/hero? And how would I change that?

1 Like

So the challenge gets a bit trickier. I have noticed in the translated versions of the game that “self” is being used a lot.

Should ALL of the references to this and self be updated to hero for all programming language versions as well as in all languages?

@maka @nick ?

English version (default)

Translated version

Since I am in the code at that point updating them all is about as much work as updating one.

1 Like

@nick @maka @Serg

So I will update coffee script as well for all the levels I can access in Kithgard Dungeon. The following is code scraped from the levels. Even though I cannot play coffee script on the levels at the moment it should be a trivial replacement based on the other languages.

Just to make sure of the code that we want replaced can you validate that the second method with hero. is correct?


Using the self/this notation in CoffeeScript:

```coffeescript
# A comment line
password = 'Secret Message'
@moveUp()
@moveDown()
while true
	@moveRight()
	@moveLeft()
	@say “This is a sentence”
@say password
@attack "Brak"
enemy1 = @findNearestEnemy()
@attack enemy1
@buildXY "fence", 36, 34

Using the Hero commands in CoffeeScript:

```coffeescript
# A comment line
password = 'Secret Message'
hero.moveUp()
hero.moveDown()
while true
	hero.moveRight()
	hero.moveLeft()
	hero.say(“This is a sentence”)
hero.say(password)
hero.attack(“Brak”)
enemy1 = hero.findNearestEnemy()
hero.attack(enemy1)
hero.buildXY("fence", 36, 34)
1 Like

So I have begun to patch each level replacing @, this, self with hero. I have updated each i18n as well that I could find.

I will also add CoffeeScript as I go and save under a different patch (if that works?)

Any level patched with LUA already, I will pull back that patch and add the changes with this update.

Patches:

  • Dungeons of Kithgard
  • Gems in the Deep
  • True Names
  • Kithgard Librarian ( submitter 58058fd8ea40a624000fc038, sorry that was me not logged in)
  • Lost in the Stacks
  • Fire Dancing
  • Loop Da Loop
  • Haunted Kithmaze
  • Dread Door
  • Known Enemy
  • Master of Names
  • Lowly Kithmen
  • Cavern Survival
  • Closing the Distance
  • The Final Kithmaze
  • A Mayhem of Munchkins
  • The Gauntlet
  • The Gauntlet A
  • The Gauntlet B
  • Cupboards of Kithgard
  • Cupboards of Kithgard A
  • Cupboards of Kithgard B
2 Likes

@nick @maka @Serg I believe this updates all of the levels for the Kithgard Dungeon Campaign. Or at least all the levels that I have access to on the free account. Each level should have LUA and Coffeescript added in the missing places as well as use “hero” for all the code. Including all i18n updates.

Please let me know if I need to fix anything and if this helps.

-Thanks
HW

2 Likes

Great! I’ll merge all these in next week as I go on a rampage playing through and tuning up all the levels.

1 Like

I think I’ve gotten all the ones in the dungeon except for the last few random levels that get unlocked later, which I’ll get next week. Thanks so much for fixing all these!

1 Like