Jump to content

Bomb Bloke

Member Since 25 May 2013
Offline Last Active Jun 29 2019 07:22 AM

Posts I've Made

In Topic: TechCorp 5: World of Corporations II

29 June 2019 - 07:22 AM

Post the mod list, please.

In Topic: JSON API v2.0.1 for ComputerCraft

01 June 2019 - 04:30 AM

Sounds like you're after a pairs loop.

In Topic: Weird program error on reboot

25 May 2019 - 07:07 AM

Remember that scripts execute from top to bottom. When you initially run your script on boot, the first thing it tries to do is build your ACTIONS table: but none of the variables you're trying to copy into it contain anything yet, so you "fill" the table with a bunch of nils.

Your script then proceeds to define all of your functions into the global scope, where they remain even when your script terminates. This is why re-running your script then allows you to assign some actual data into the ACTIONS table - the global scope only clears when you reboot your computer.

Note that in later versions of ComputerCraft, the global scope is cleared when a script ends. Generally you should be localising everything you can.


It may also help to know that Lua always assigns by value, never by reference. Confusingly, when you attempt to assign a function/table/coroutine you end up assigning a pointer value leading to the relevant area in memory, but working with that pointer value in the variable is not the same as being able to use a variable as a reference.

In Topic: Overriding fs functionality

22 May 2019 - 04:39 PM

View PostMrObsidy, on 22 May 2019 - 03:29 PM, said:

To do this I override every single function in fs to prefix the root directory.

Just glancing through the fs API, this looks like it'll at least break fs.combine() and fs.complete().

It's very difficult to comment on your issue without seeing the relevant lines in OneOS in addition to your own code.

In Topic: Endless nan errors in calculator program (+ WarpDrive Integration)

22 May 2019 - 07:58 AM

View PostSquidDev, on 18 May 2019 - 06:39 AM, said:

Tables are compared by reference, which means that tables with the same entries aren't always equal.

To clarify, the values you're comparing are your table pointers, as opposed to what's in your tables (their contents). Unless you compare a table pointer to itself you won't ever find an "equal match" that way; whether your tables contain the "same entries" isn't at all relevant.

A primitive but simple example of a check that looks at table contents might look like this:

local function compareTables(table1, table2)
  for i = 1, #table1 do
    if table1[i] ~= table2[i] then return false end

  return true

if compareTables(disp, {0, 0, 0}) then ...

It'd be helpful to know what values you're actually expecting to get out of your script. Providing example input alongside the "correct" output would make it a lot easier to figure out which alterations need to be made.