Commit 22885ca8 authored by Alex Gleason's avatar Alex Gleason

Always use ipairsgit add data/scripts/ Now that I know the difference

parent ceb3f46e
......@@ -15,7 +15,7 @@ local font, font_size = "minecraftia", 8
function item_select:on_started()
-- Set items the player has
player_items = {}
for i, v in pairs(game_items) do
for i, v in ipairs(game_items) do
if sol.main.game:has_item(v) then
table.insert(player_items, v)
end
......@@ -29,7 +29,7 @@ function item_select:on_started()
self.cursor = 0
local slot_1 = sol.main.game:get_item_assigned(1)
if slot_1 then
for i, v in pairs(player_items) do
for i, v in ipairs(player_items) do
if v == slot_1:get_name() then
self.cursor = i break
end
......@@ -39,7 +39,7 @@ end
function item_select:on_draw(dst_surface)
self.menu:draw(dst_surface, 50, 20)
for i, v in pairs(player_items) do
for i, v in ipairs(player_items) do
if sol.main.game:has_item(v) then
local text = sol.text_surface.create({text=v, font=font, font_size=font_size})
if self.cursor == i then
......
......@@ -93,7 +93,7 @@ function popup:on_draw(dst_surface)
-- Draw options
local font, font_size = "minecraftia", 8
for i, v in pairs(self.options) do
for i, v in ipairs(self.options) do
local text = sol.text_surface.create({text_key=v, font=font, font_size=font_size})
if popup.cursor == i then
text:set_color({255, 255, 255})
......
  • Total stupidity. I wrote Always use ipairs!! Now that I know the difference and Bash took my two exclamation points as a bang command.

    Edited by Alex Gleason
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment