Search found 260 matches

by sphyrth
Mon Sep 11, 2017 10:00 am
Forum: General
Topic: get the key of the smallest value in a table ?
Replies: 13
Views: 7534

Re: get the key of the smallest value in a table ?

My dirty solution is that you get the value of the first table item.

Code: Select all

table = {763, 365, 2010, 433}
min = table[1]
Key = 1

for i=2, #table do
   if table[i] < min then
      min = table[i]
      key = i
   end
end
by sphyrth
Wed Sep 06, 2017 1:24 am
Forum: Games and Creations
Topic: Korean Chess
Replies: 15
Views: 21548

Re: Korean Chess

Here's some update: 1. I put out the Save and Load functions because they were "hidden" in the previous one. These functionalities are very clunky . For example, you have no limit as to how many games you can save, so it might mess up the UI. Be wary of that. 2. I'm now trying to learn Ink...
by sphyrth
Tue Sep 05, 2017 1:20 am
Forum: Games and Creations
Topic: Korean Chess
Replies: 15
Views: 21548

Re: Korean Chess

Looks cool. Found a small bug though: I reached a point where "the red general cannot be saved", then I pressed the rewind button and both generals flew off the board. Also, neither of the .love files work using drag and drop, it works only after extracting them to a folder (windows 10 x6...
by sphyrth
Mon Sep 04, 2017 12:52 am
Forum: Games and Creations
Topic: Korean Chess
Replies: 15
Views: 21548

Re: Korean Chess

Thanks for the info and the compliment! I'm gonna replace those assets with my own if I have the time, but for now they'll be in the OP.

One of the bugs I have to fix is that you can "pass" your turn even though you're under Check.
by sphyrth
Sat Sep 02, 2017 6:10 am
Forum: Games and Creations
Topic: Korean Chess
Replies: 15
Views: 21548

Re: Korean Chess

I revamped the code and the UI. I got the new pieces from these guys. But I'm not sure how "proper attribution" actually works. Where should I put these in the code? Jasmin Scharrer (original artwork, http://jasminscharrer.com/), Sebastian Pipping (post-processing, https://blog.hartwork.or...
by sphyrth
Thu Aug 31, 2017 4:09 am
Forum: Support and Development
Topic: [Answered] I Want to Save a File Right Where My .Love File is
Replies: 3
Views: 2692

Re: I Want to Save a File Right Where My .Love File is

xNick1 wrote: Thu Aug 31, 2017 2:29 am Yes you can do that in lua but you don't want to do that, cause doing it would make your game working only on Windows or whatever you're using.
zorg wrote: Thu Aug 31, 2017 2:32 am - Concede defeat and use the save folder.
Point taken. Thanks for the info! :awesome:
by sphyrth
Wed Aug 30, 2017 11:56 pm
Forum: Support and Development
Topic: [Answered] I Want to Save a File Right Where My .Love File is
Replies: 3
Views: 2692

[Answered] I Want to Save a File Right Where My .Love File is

Suppose that I have a .love file on "C:\Games\MyGame" and I want to save a text file in that same folder, is it possible? I've been trying to study the Love2d Filesystem API , finding a way if I can save a text file right in the folder where my .love file is. Couldn't find much tutorial ab...
by sphyrth
Tue Aug 29, 2017 2:07 am
Forum: Support and Development
Topic: Absolute beginner to programming
Replies: 2
Views: 2786

Re: Absolute beginner to programming

If there's an error message, can you post a screenshot of it?
by sphyrth
Sun Aug 20, 2017 5:31 am
Forum: General
Topic: A Question on Emptying Tables on Lua
Replies: 3
Views: 2337

Re: A Question on Emptying Tables on Lua

Thanks for the reply guys!

I guess I'll just go with the laziest bet and rely on Lua's Garbage Collector for small games, and do something else for the more ambitious projects.
by sphyrth
Fri Aug 18, 2017 11:14 pm
Forum: General
Topic: A Question on Emptying Tables on Lua
Replies: 3
Views: 2337

A Question on Emptying Tables on Lua

So, I usually clear my tables just by doing this. sample_table = {} But I think I should be doing something like this. while #sample_table > 0 do table.remove(sample_table, 1) end Creating small games might not be an issue with the former but I assume that it produces some memory leaks or something,...