-
What do you want to achieve? Keep it simple and clear!
To convert a string to a table so that it can be read by my other scripts. -
What is the issue?
The table is just showing up a nil and also not printing for some reason. Am I pulling a silly?
local osu_beatmap = "192,192,100,5,0,0:0:0:0:64,192,266,1,0,0:0:0:0:320,192,433,1,0,0:0:0:0:192,192,600,1,0,0:0:0:0:448,192,766,1,0,0:0:0:0:192,192,1100,1,0,0:0:0:0:64,192,1266,1,0,0:0:0:0:320,192,1433,1,0,0:0:0:0:192,192,1600,1,0,0:0:0:0:448,192,1766,128,0,2433:0:0:0:0:64,192,2433,1,0,0:0:0:0:320,192,2766,1,0,0:0:0:0:64,192,2933,1,0,0:0:0:0:320,192,3100,1,0,0:0:0:0:192,192,3266,1,0,0:0:0:0:448,192,3433,1,0,0:0:0:0:320,192,3766,1,0,0:0:0:0:64,192,3933,1,0,0:0:0:0:320,192,4100,1,0,0:0:0:0:192,192,4266,1,0,0:0:0:0:"
function songs:osuConverter(beatmap_string)
local notes = string.split(beatmap_string, "0:0:0:0:")
local beatmap = {}
for i, note in notes do
local note_data = string.split(note, ",")
if note_data[1] == "" then return end
local lane = note_data[1]
local time_position = note_data[3]
local hold_note = note_data[4]
local end_time = note_data[5]
if lane == "64" then
lane = 1
elseif lane == "192" then
lane = 2
elseif lane == "320" then
lane = 3
elseif lane == "448" then
lane = 4
end
time_position = tonumber(time_position)/100
if hold_note == "1" or "5" then
hold_note = 0
else
hold_note = 1
end
end_time = tonumber(end_time)/100
local FINAL_NOTE = {lane, time_position, hold_note, end_time}
table.insert(beatmap, FINAL_NOTE)
end
print(beatmap)
return beatmap
end
So I’m trying to convert an Osu Mania note data from a string to a table that is like this:
{
[1] = {lane, time_position, held, end_position},
[2] = {lane, time_position, held, end_position},
…
}
Now when I do this for some odd reason inside the for loop that goes through the string and sets up the note I am able to print from there and it will show up the thing getting done. But once I’m outside of the loop before the return, it doesn’t?
I hope you understand what I’m saying cause I suck at explaining things, any help is much appreciated. Thank you!