Jump to content


Oddstr13's Content

There have been 3 items by Oddstr13 (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#227820 Shurtle Preview

Posted by Oddstr13 on 27 July 2015 - 06:36 AM in General

View Postflaghacker, on 26 July 2015 - 05:26 PM, said:

Hmmm... It looks to me that this language is more complex and less readable than plain Lua... Doesn't it make stuff harder in the end?

The primary usage of this language is as a replacement for the CraftOS buildt in program, go.

go forward 3 right forward 2
vs.
g 3fr2f

A slightly more advanced example; while turtle can mine upwards, mine forward and move forward:
g #U$m{mf}



#226177 cc-require: Standards compatible require for ComputerCraft

Posted by Oddstr13 on 18 July 2015 - 01:38 AM in APIs and Utilities

View PostMKlegoman357, on 17 July 2015 - 07:55 PM, said:

Very nice! You should probably add compatibility with Lua 5.2 though, because CC is already starting to convert to it and it will be updated in later CC versions. I'd recommend supporting both: Lua 5.1 and Lua 5.2.
What exactly is missing before this is Lua 5.2 compatable?
If there is anything missing, please create a issue on Bitbucket, with details outlining what the problem is, and how to correct it.



View Postawsumben13, on 17 July 2015 - 07:57 PM, said:

Very nice, I've always wanted require() in computercraft. My one suggestion is that you don't require people to download the resource pack, maybe make a single file that can be downloaded that adds the necessary globals when run? If I were on a server, or wanted to make a program that used this and distribute it, needing a custom resource pack wouldn't work.
The resource pack is provided as a convinience, as it is needed for server(and client)-wide install of the require function.
You can allways just download and run the require.lua file (raw file).
I'll consider making a pastebin that downloads and installs the function into the global environment.



#226121 cc-require: Standards compatible require for ComputerCraft

Posted by Oddstr13 on 17 July 2015 - 07:43 PM in APIs and Utilities

cc-require

A standards compatible implementation of require,
and part of the package library, as specified by the Lua Manual

Allows for compatability with many non-CC Lua programs and API.

Examples

Standards compatible:

local api = {}
function api.hello(what)
    print("Hello, " .. what .. "!")
end

return api

The ComputerCraft way:

function hello(what)
    print("Hello, " .. what .. "!")
end

The main difference is that with standard require, APIs return a table
containing the API, where as in ComputerCraft's os.loadAPI, the global
environment of the API file is put into _G[api_filename].

This implementation of require allows you to import either type API.
It will however not place it in the global environment.

-- API file: /lib/api.lua
local api = require("api")

api.hello("World")

-- API file: /lib/test/api.lua
local api = require("test.api")

api.hello("ComputerCraft")

The search paths, where require looks for the API, can be found at the top of require.lua

Contribute

Download and installation
Resource pack can be downloaded from the Bitbucket download section.
Put the downloaded zip into the directory resourcepacks/, innside your minecraft directory, creating it if needed.