• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Lua : assigning a string to a variable containing a number ?

Status
Not open for further replies.
Level 12
Joined
Jan 30, 2020
Messages
875
Hello there, it's me again about Lua.

I am asking this because I have not found the answer to this question, and before messing up my whole map for testing this, I just want to know if it is possible.

As variables don't have types in Lua and only values have types, can I do this :

a=5
a="Hello"

will it be allowed or will it bug ?
 
Level 12
Joined
Jan 30, 2020
Messages
875
Thanks for the answer !

Oh I definitely will, trust me I feel exactly the same about type safety!!!

This said I don't think I will convert this current map to TS. Or I might if it seems I can never stop working on it. I was planning to use TS when working on my next map, a big development of my current project, to create something that has never been made before. I mean I want to go even further away from the usual TD concept.

Anyways, the fact is, as the framework for TS you linked me is transpiling to Lua, so I though finishing working on my map & optimizing it would be a very good way to have a better understanding of Lua before making the switch.

The current challenge for me is to change the way I store the Balls in my map. For the moment I store the 4 different kind of Balls (6 normal or flying balls or 1 Giant Ball or 1 Flying Giant Ball per level and per player) in 4 separate arrays. I am exploring the best way to store all these balls in a single Table. I might keep the combined player and ball number in a single integer, and add a string key for the type of ball.

I suppose it is not worth to start creating an object "Ball" as there would not be many parameters or methods associated. Or it might...
 
Level 12
Joined
Jan 30, 2020
Messages
875
A base class of balls could be used as type for a list or array of balls.

I am still considering it to be honest.

But at the moment I have kept the 4 arrays as I am fighting with a "ReviveHero" issue as I changed the way I store the Balls between levels.

Anyways, a Ball object would be nice if I attached the current triggers and ball functions I currently use as methods, and of course the properties as parameters.
Then the type of ball would just be a parameter like the others.
 
Status
Not open for further replies.
Top