• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 16:34
CEST 22:34
KST 05:34
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
ZeroSpace Early Access is Now Live!2Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters1Balance hotfix patch 5.0.16b (July 16)65Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters How would you feel about frequent/monthly balance patches for SC2? Balance hotfix patch 5.0.16b (July 16) Clem: "I don't have that much hope in Blizzard" [D] Wireframe Casting Removed
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
HORROR STARCRAFT MOVIE How Famous was FlaSh before his Debut? BW General Discussion Recent recommended BW games screpdb: new Starcraft reporting tool
Tourneys
[IPSL] Spring 2026 Grand Finals - This Weekend! [Megathread] Daily Proleagues Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies
Other Games
General Games
ZeroSpace Early Access is Now Live! ZeroSpace at Steam NextFest - Last free demo Path of Exile Nintendo Switch Thread Stormgate/Frost Giant Megathread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI UK Politics Mega-thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Movie Discussion! Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story Tennis[sport]
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Role of Gaming on Mental Hea…
TrAiDoS
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3232 users

The Big Programming Thread - Page 443

Forum Index > General Forum
Post a Reply
Prev 1 441 442 443 444 445 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Najda
Profile Joined June 2010
United States3765 Posts
February 13 2014 20:45 GMT
#8841
If my goal is to become proficient enough at programming that I can have some sort of sustainable income akin to a part-time job while going to school, what would be a good area of focus? It appeals to me because any sort of work experience like this is much more transferrable and rewarding than any low wage part time job like waiting tables would be.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-02-14 22:58:45
February 14 2014 22:57 GMT
#8842
One thing that has driven me nuts recently is JVM. For example, when I don't look at my program's window, memory according to task manager could be 60k, but when I open the program's window and then open another window (e.g. Firefox), memory starts growing, e.g. until 61k, 62k or 64k. After a few seconds, it goes back to 60k again. Is this how JVM works or have I messed up something? I really don't understand what is going on here. I sometimes wish Java had some ARC model like Objective-C, so I can at least know that JVM is not doing shit.
Manit0u
Profile Blog Joined August 2004
Poland17796 Posts
February 14 2014 23:00 GMT
#8843
On February 15 2014 07:57 darkness wrote:
One thing that has driven me nuts recently is JVM. For example, when I don't look at my program's window, memory according to task manager could be 60k, but when I open the program's window and then open another window (e.g. Firefox), memory starts growing, e.g. until 61k, 62k or 64k. After a few seconds, it goes back to 60k again. Is this how JVM works or have I messed up something? I really don't understand what is going on here. I sometimes wish Java had some ARC model like Objective-C, so I can at least know that JVM is not doing shit.


Wouldn't that be a spike in memory consumption when launching another program?
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-02-14 23:10:27
February 14 2014 23:07 GMT
#8844
On February 15 2014 08:00 Manit0u wrote:
Show nested quote +
On February 15 2014 07:57 darkness wrote:
One thing that has driven me nuts recently is JVM. For example, when I don't look at my program's window, memory according to task manager could be 60k, but when I open the program's window and then open another window (e.g. Firefox), memory starts growing, e.g. until 61k, 62k or 64k. After a few seconds, it goes back to 60k again. Is this how JVM works or have I messed up something? I really don't understand what is going on here. I sometimes wish Java had some ARC model like Objective-C, so I can at least know that JVM is not doing shit.


Wouldn't that be a spike in memory consumption when launching another program?


No, what I'm saying is that I monitor my program's memory usage. When I open my program's window quickly, then open some other window (e.g. Firefox), my program's memory keeps growing for a bit even though I don't look at that window or click anything, then that memory is more or less deallocated to go back to normal (I don't know if it goes back precisely to match bytes, but it's still e.g. 60k memory). It takes a few seconds for this to happen. I'm asking if that's standard from JVM's side to manipulate memory even if you do nothing but click on a program's window. Maybe JVM executes some event-driven code and allocates/deallocates memory?
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
February 14 2014 23:18 GMT
#8845
Hello everyone, reading week is this week! My classes are starting to require use of Objective C, so getting more practice with that is one of my goals for this week. Currently, the stage I am at is - I know what pointers are, how they function, and the basics of how to use them. In general, I don't use them on my own. So, if any of you have ideas for C projects that would require me to learn up/shore up on that front to do them, I would appreciate if you could share them. Thank you.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-02-15 00:14:47
February 15 2014 00:13 GMT
#8846
On February 15 2014 08:18 WarSame wrote:
Hello everyone, reading week is this week! My classes are starting to require use of Objective C, so getting more practice with that is one of my goals for this week. Currently, the stage I am at is - I know what pointers are, how they function, and the basics of how to use them. In general, I don't use them on my own. So, if any of you have ideas for C projects that would require me to learn up/shore up on that front to do them, I would appreciate if you could share them. Thank you.


So you need practice with pointers? One thing that may use pointers is some function to sort an array. I don't know why you stick with lower level stuff if you want to learn Objective-C though.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
February 15 2014 00:18 GMT
#8847
Apparently I may have used the wrong name for it. By Objective C I meant C non ++. I forget what that's called. What term do you use to clarify that it's original C you're talking about?
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
bangsholt
Profile Joined June 2011
Denmark138 Posts
February 15 2014 00:22 GMT
#8848
What term? You use C.

You want training with pointers - well, go make a C program that allocates memory to save N numbers and writes out the average - there you will need some pointers - then you can add on to it so you can choose different ways of sorting the numbers.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
February 15 2014 00:28 GMT
#8849
I was using the term C earlier, but it was causing some confusion when I was asking questions. I guess I'll just stick with it, then.

I'll give that a shot, thank you.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Cyx.
Profile Joined November 2010
Canada806 Posts
February 15 2014 00:29 GMT
#8850
On February 15 2014 09:22 bangsholt wrote:
What term? You use C.

You want training with pointers - well, go make a C program that allocates memory to save N numbers and writes out the average - there you will need some pointers - then you can add on to it so you can choose different ways of sorting the numbers.

One thing that really made me understand what was going on with my pointers was coding a doubly linked list that I then used in one of my projects extensively enough that I knew for DAMN sure there were no bugs in that code any more (well... I'm never sure. But I abused that thing lol). They're pretty tricky to debug, and looooots of pointers =D
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-02-15 00:56:51
February 15 2014 00:47 GMT
#8851
On February 15 2014 09:28 WarSame wrote:
I was using the term C earlier, but it was causing some confusion when I was asking questions. I guess I'll just stick with it, then.

I'll give that a shot, thank you.


C - a plain, procedural language
C++ - superset of C, it supports C *and* offers more stuff (not only object-oriented programming)
Objective-C - Apple's language, it supports C *and* offers object-oriented programming

A bit informal, but you should distinguish all three. You can program C stuff in both C++ and Objective-C, but it's considered low level in general.

Edit: The C Programming Language book
misirlou
Profile Joined June 2010
Portugal3306 Posts
February 15 2014 01:36 GMT
#8852
On February 15 2014 09:29 Cyx. wrote:
Show nested quote +
On February 15 2014 09:22 bangsholt wrote:
What term? You use C.

You want training with pointers - well, go make a C program that allocates memory to save N numbers and writes out the average - there you will need some pointers - then you can add on to it so you can choose different ways of sorting the numbers.

One thing that really made me understand what was going on with my pointers was coding a doubly linked list that I then used in one of my projects extensively enough that I knew for DAMN sure there were no bugs in that code any more (well... I'm never sure. But I abused that thing lol). They're pretty tricky to debug, and looooots of pointers =D


This is what got me started on pointers aswell, back when I was learning C. Linked lists (you can start with one way lists and then move to double), learn the operations on them (add, search, remove, sorting), and then maybe look into trees if you want. + Show Spoiler +
Pointers are really useful for making any data structure that isn't an array, even though you can use arrays to make stuff like binary trees.
The good thing about learning lists is that you will be using pointers inside a structure that is referenced by a pointer, so it gets tricky enough to give you some practice using them . More practice tips, when you're doing the functions that are supposed to do something, make them return a pointer, that way the functions will have much more uses and make you look at those beautiful "void* search(int value)" lines
Crazyeyes
Profile Blog Joined March 2008
Canada1342 Posts
February 15 2014 03:37 GMT
#8853
Hmm, so am I allowed to ask for programming help in this thread? I'm seeing a lot more discussion than "I have a problem, here pls help" but since Stack Overflow and Google have failed me I figured I'd try this thread out.
WeeEEeeEEEeeEEEeeeEEee!!
ThatGuy
Profile Blog Joined April 2008
Canada695 Posts
February 15 2014 03:39 GMT
#8854
It's most definitely allowed! A lot of the discussions spawn from someone stating a problem to begin with anyway .
Crazyeyes
Profile Blog Joined March 2008
Canada1342 Posts
Last Edited: 2014-02-15 03:47:59
February 15 2014 03:46 GMT
#8855
Great! Hopefully you guys can help me out cause this I'm really quite stumped here.

Here's the Stack Overflow thread:
http://stackoverflow.com/questions/21792708/corona-lua-unable-to-access-table-value-after-collision

And I'll copy the text over here in a spoiler for those of you who don't feel like leaving TL
+ Show Spoiler +

I'm trying to get some collision detection working but I can't seem to figure out what the problem is.

The error I'm getting is

...\main.lua:178:attempt to concatenate field 'name' (a nil value)


What I have is this: I have a box (the "ship") that stays at a fixed X coordinate, but moves up and down. It's meant to go through a "tunnel" made up of two rectangles with a gap between them, and I'm trying to detect a collision between the ship and the walls of the tunnel (ie the rectangles).

I get this error when the collision happens. A lot of my code is just modified versions of the official Corona documentation and I'm just not able to figure out what the problem is.

Here are the relevant pieces of code:

function playGame()
-- Display the ship
ship = display.newRect(ship);
shipLayer:insert(ship);
-- Add physics to ship
physics.addBody(ship, {density = 3, bounce = 0.3});

...

beginRun();
end

function beginRun()
...
spawnTunnel(1100); -- this just calls the createTunnel function at a specific location
gameListeners("add");
...
end

function gameListeners(event)
if event == "add" then
ship.collision = onCollision;
ship:addEventListener("collision", ship);
-- repeat above two lines for top
-- and again for bottom
end
end

-- Collision handler
function onCollision(self,event)
if ( event.phase == "began" ) then
-- line 178 is right below this line ----------------------------------
print( self.name .. ": collision began with " .. event.other.name )
end

-- Create a "tunnel" using 2 rectangles
function createTunnel(center, xLoc)
-- Create top and bottom rectangles, both named "box"
top = display.newRect(stuff);
top.name = "wall";
bottom = display.newRect(stuff);
bottom.name = "wall";

-- Add them to the middleLayer group
middleLayer:insert(top);
middleLayer:insert(bottom);

-- Add physics to the rectangles
physics.addBody(top, "static", {bounce = 0.3});
physics.addBody(bottom, "static", {bounce = 0.3});
end

I only get the error message once the two objects should collide, so it seems like the collision is happening, and it is being detected. But for some reason self.name and event.other.name are nil.


It's my first time using LUA so I'm probably doing some things wrong, and it is a bit sloppy but as a learning exercise I'm not too concerned about that. Although the main issue here is of course solving the problem, any small criticisms or tips are always welcome.
WeeEEeeEEEeeEEEeeeEEee!!
Oktyabr
Profile Joined July 2011
Singapore2234 Posts
February 15 2014 04:50 GMT
#8856
Hi guys, I'm required to propose a project title related to the topic of "semantic network for knowledge representation" and I have only started picking up Java recently. Does anyone have any ideas for a project that can be carried out over a course of a year?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2014-02-15 05:50:37
February 15 2014 05:17 GMT
#8857
--- Nuked ---
Crazyeyes
Profile Blog Joined March 2008
Canada1342 Posts
Last Edited: 2014-02-15 05:34:14
February 15 2014 05:32 GMT
#8858
On February 15 2014 14:17 Nesserev wrote:
Show nested quote +
On February 15 2014 12:46 Crazyeyes wrote:
Great! Hopefully you guys can help me out cause this I'm really quite stumped here.

Here's the Stack Overflow thread:
http://stackoverflow.com/questions/21792708/corona-lua-unable-to-access-table-value-after-collision

And I'll copy the text over here in a spoiler for those of you who don't feel like leaving TL
+ Show Spoiler +

I'm trying to get some collision detection working but I can't seem to figure out what the problem is.

The error I'm getting is

...\main.lua:178:attempt to concatenate field 'name' (a nil value)


What I have is this: I have a box (the "ship") that stays at a fixed X coordinate, but moves up and down. It's meant to go through a "tunnel" made up of two rectangles with a gap between them, and I'm trying to detect a collision between the ship and the walls of the tunnel (ie the rectangles).

I get this error when the collision happens. A lot of my code is just modified versions of the official Corona documentation and I'm just not able to figure out what the problem is.

Here are the relevant pieces of code:

function playGame()
-- Display the ship
ship = display.newRect(ship);
shipLayer:insert(ship);
-- Add physics to ship
physics.addBody(ship, {density = 3, bounce = 0.3});

...

beginRun();
end

function beginRun()
...
spawnTunnel(1100); -- this just calls the createTunnel function at a specific location
gameListeners("add");
...
end

function gameListeners(event)
if event == "add" then
ship.collision = onCollision;
ship:addEventListener("collision", ship);
-- repeat above two lines for top
-- and again for bottom
end
end

-- Collision handler
function onCollision(self,event)
if ( event.phase == "began" ) then
-- line 178 is right below this line ----------------------------------
print( self.name .. ": collision began with " .. event.other.name )
end

-- Create a "tunnel" using 2 rectangles
function createTunnel(center, xLoc)
-- Create top and bottom rectangles, both named "box"
top = display.newRect(stuff);
top.name = "wall";
bottom = display.newRect(stuff);
bottom.name = "wall";

-- Add them to the middleLayer group
middleLayer:insert(top);
middleLayer:insert(bottom);

-- Add physics to the rectangles
physics.addBody(top, "static", {bounce = 0.3});
physics.addBody(bottom, "static", {bounce = 0.3});
end

I only get the error message once the two objects should collide, so it seems like the collision is happening, and it is being detected. But for some reason self.name and event.other.name are nil.


It's my first time using LUA so I'm probably doing some things wrong, and it is a bit sloppy but as a learning exercise I'm not too concerned about that. Although the main issue here is of course solving the problem, any small criticisms or tips are always welcome.

Well, I have no personal experience with LUA, but luckily it's a straightforward and easy-to-read scripting lanugage, and well, this is a problem that can occur in every language. (It also looks a bit like python)
Check these things:
- To what class does the function 'function onCollision(self,event)' belong to; and is self.name initialized in its constructor?
(Check if you initialized a local variable called name instead of self.name)
- Does the object that collides even have a member called self.name? Check what the types are of the objects that collide.

Also, a nice way to debug, is to output information in every function.

There are no classes. All of my code is in main.lua, which includes onCollision.

I got the collision code from here, which also explains how it works in pretty simple terms. self should either be the ship or one of the walls (top/bottom), which have the .name property added right after creation.

Physics are only enabled on the ship and the walls, so those are the only things that can collide. Furthermore, the physics engine can only have collisions between "dynamic" objects + other objects (so dynamic + dynamic or dynamic + static). Since the ship is my only dynamic physics body, and since I'm pretty confident that there is a collision taking place, we know that the ship is at least one of the bodies colliding and that the ship definitely has its .name property set.

...
...

So while writing this post, or more specifically that last line, I thought "...wait, does it?"
Motherfucker. I've spent like SIX HOURS trying to debug this shit AND I FUCKING FORGOT TO SET THE .name PROPERTY? Fuuuuuuck that.

Thank you so much for responding. I had honestly given up at this point and was relying on someone fixing it for me. Jesus Christ I still can't believe what a stupid mistake that was. It works. After creating the ship, I give it a name now and that fixes it.

Goddammit.
WeeEEeeEEEeeEEEeeeEEee!!
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2014-02-15 06:19:42
February 15 2014 06:16 GMT
#8859
On February 15 2014 08:07 darkness wrote:
Show nested quote +
On February 15 2014 08:00 Manit0u wrote:
On February 15 2014 07:57 darkness wrote:
One thing that has driven me nuts recently is JVM. For example, when I don't look at my program's window, memory according to task manager could be 60k, but when I open the program's window and then open another window (e.g. Firefox), memory starts growing, e.g. until 61k, 62k or 64k. After a few seconds, it goes back to 60k again. Is this how JVM works or have I messed up something? I really don't understand what is going on here. I sometimes wish Java had some ARC model like Objective-C, so I can at least know that JVM is not doing shit.


Wouldn't that be a spike in memory consumption when launching another program?


No, what I'm saying is that I monitor my program's memory usage. When I open my program's window quickly, then open some other window (e.g. Firefox), my program's memory keeps growing for a bit even though I don't look at that window or click anything, then that memory is more or less deallocated to go back to normal (I don't know if it goes back precisely to match bytes, but it's still e.g. 60k memory). It takes a few seconds for this to happen. I'm asking if that's standard from JVM's side to manipulate memory even if you do nothing but click on a program's window. Maybe JVM executes some event-driven code and allocates/deallocates memory?

It's 4k memory. Are you having any performance issues because of this? Java has a gc, yes, so it's going to be fundamentally different than something like arc.

But seriously dude, 4k memory.

On February 15 2014 14:32 Crazyeyes wrote:


Thank you so much for responding. I had honestly given up at this point and was relying on someone fixing it for me. Jesus Christ I still can't believe what a stupid mistake that was. It works. After creating the ship, I give it a name now and that fixes it.

Goddammit.


Some amount of this is just par for the course while writing software. You can mitigate some of it by starting smaller, writing unit tests, etc. But you'll never completely get away from dumb-as-shit bugs, just lessen the frequency and change the type.

You can be glad that you have more tools to debug than LEDs and a oscilloscope at least, so it could be worse :p
Who after all is today speaking about the destruction of the Armenians?
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 15 2014 14:11 GMT
#8860
On February 15 2014 14:32 Crazyeyes wrote:
Show nested quote +
On February 15 2014 14:17 Nesserev wrote:
On February 15 2014 12:46 Crazyeyes wrote:
Great! Hopefully you guys can help me out cause this I'm really quite stumped here.

Here's the Stack Overflow thread:
http://stackoverflow.com/questions/21792708/corona-lua-unable-to-access-table-value-after-collision

And I'll copy the text over here in a spoiler for those of you who don't feel like leaving TL
+ Show Spoiler +

I'm trying to get some collision detection working but I can't seem to figure out what the problem is.

The error I'm getting is

...\main.lua:178:attempt to concatenate field 'name' (a nil value)


What I have is this: I have a box (the "ship") that stays at a fixed X coordinate, but moves up and down. It's meant to go through a "tunnel" made up of two rectangles with a gap between them, and I'm trying to detect a collision between the ship and the walls of the tunnel (ie the rectangles).

I get this error when the collision happens. A lot of my code is just modified versions of the official Corona documentation and I'm just not able to figure out what the problem is.

Here are the relevant pieces of code:

function playGame()
-- Display the ship
ship = display.newRect(ship);
shipLayer:insert(ship);
-- Add physics to ship
physics.addBody(ship, {density = 3, bounce = 0.3});

...

beginRun();
end

function beginRun()
...
spawnTunnel(1100); -- this just calls the createTunnel function at a specific location
gameListeners("add");
...
end

function gameListeners(event)
if event == "add" then
ship.collision = onCollision;
ship:addEventListener("collision", ship);
-- repeat above two lines for top
-- and again for bottom
end
end

-- Collision handler
function onCollision(self,event)
if ( event.phase == "began" ) then
-- line 178 is right below this line ----------------------------------
print( self.name .. ": collision began with " .. event.other.name )
end

-- Create a "tunnel" using 2 rectangles
function createTunnel(center, xLoc)
-- Create top and bottom rectangles, both named "box"
top = display.newRect(stuff);
top.name = "wall";
bottom = display.newRect(stuff);
bottom.name = "wall";

-- Add them to the middleLayer group
middleLayer:insert(top);
middleLayer:insert(bottom);

-- Add physics to the rectangles
physics.addBody(top, "static", {bounce = 0.3});
physics.addBody(bottom, "static", {bounce = 0.3});
end

I only get the error message once the two objects should collide, so it seems like the collision is happening, and it is being detected. But for some reason self.name and event.other.name are nil.


It's my first time using LUA so I'm probably doing some things wrong, and it is a bit sloppy but as a learning exercise I'm not too concerned about that. Although the main issue here is of course solving the problem, any small criticisms or tips are always welcome.

Well, I have no personal experience with LUA, but luckily it's a straightforward and easy-to-read scripting lanugage, and well, this is a problem that can occur in every language. (It also looks a bit like python)
Check these things:
- To what class does the function 'function onCollision(self,event)' belong to; and is self.name initialized in its constructor?
(Check if you initialized a local variable called name instead of self.name)
- Does the object that collides even have a member called self.name? Check what the types are of the objects that collide.

Also, a nice way to debug, is to output information in every function.

There are no classes. All of my code is in main.lua, which includes onCollision.

I got the collision code from here, which also explains how it works in pretty simple terms. self should either be the ship or one of the walls (top/bottom), which have the .name property added right after creation.

Physics are only enabled on the ship and the walls, so those are the only things that can collide. Furthermore, the physics engine can only have collisions between "dynamic" objects + other objects (so dynamic + dynamic or dynamic + static). Since the ship is my only dynamic physics body, and since I'm pretty confident that there is a collision taking place, we know that the ship is at least one of the bodies colliding and that the ship definitely has its .name property set.

...
...

So while writing this post, or more specifically that last line, I thought "...wait, does it?"
Motherfucker. I've spent like SIX HOURS trying to debug this shit AND I FUCKING FORGOT TO SET THE .name PROPERTY? Fuuuuuuck that.

Thank you so much for responding. I had honestly given up at this point and was relying on someone fixing it for me. Jesus Christ I still can't believe what a stupid mistake that was. It works. After creating the ship, I give it a name now and that fixes it.

Goddammit.


hahaha, the bittersweet release.
conspired against by a confederacy of dunces.
Prev 1 441 442 443 444 445 1032 Next
Please log in or register to reply.
Live Events Refresh
Monday Night Weeklies
16:00
#59
RotterdaM1206
TaKeTV 499
TKL 391
IndyStarCraft 221
SteadfastSC214
ZombieGrub142
BRAT_OK 135
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 1206
TKL 391
IndyStarCraft 221
SteadfastSC 214
ZombieGrub142
BRAT_OK 135
elazer 89
StarCraft: Brood War
Dewaltoss 96
Free 58
HiyA 28
IntoTheRainbow 12
Bale 11
League of Legends
KnowMe47
Counter-Strike
FalleN 2417
fl0m1664
ScreaM1586
minikerr1
Heroes of the Storm
Liquid`Hasu467
Other Games
tarik_tv3500
Grubby2810
shahzam531
uThermal400
Pyrionflax265
B2W.Neo242
UpATreeSC121
ROOTCatZ96
JuggernautJason65
Trikslyr61
Organizations
Other Games
gamesdonequick2409
BasetradeTV196
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 16 non-featured ]
StarCraft 2
• kabyraGe 227
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• blackmanpl 42
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota2989
League of Legends
• TFBlade1281
Other Games
• imaqtpie826
• Shiphtur556
Upcoming Events
PiGosaur Cup
1d 3h
The PondCast
1d 13h
Kung Fu Cup
1d 14h
OSC
2 days
CrankTV Team League
2 days
Replay Cast
3 days
CrankTV Team League
3 days
Korean StarCraft League
4 days
RSL Revival
4 days
Clem vs ByuN
Serral vs SHIN
Online Event
4 days
[ Show More ]
Replay Cast
5 days
RSL Revival
5 days
herO vs Solar
Rogue vs Lambo
WardiTV Weekly
6 days
Liquipedia Results

Completed

IPSL Spring 2026
HSC XXIX
Eternal Conflict S2 E3

Ongoing

Acropolis #4
CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.