Open atesin opened 2 months ago
could you please teach me how to submit pull requests (have to fork before?)?? ... i have some ideas, i want you to code them and show you, and if you like them merge them
my email is like my username, but in gmail
could you please teach me how to submit pull requests (have to fork before?)?? ... i have some ideas, i want you to code them and show you, and if you like them merge them
Yes, you need to make a fork (your copy of the project), edit it and make a pull request when you agree. Your pull request is updated at the same time as your fork edit. And don't worry, you need approval before merging.
You can do cat lib.lua >> tmp_cart.lua in lua
function cat(lib, tmp_cart)
end
I will do parsing for use your function each time it see:
--import lib.lua
in game lua cart.
And use
--cart tmp_cart.lua
for set cart output name.
for this to work i think we need some info before:
also i suggest to change config variable names from xxx.tic80 to tic80.xxxx instead, going from general to particular, this way is more easier to group/find more future tic80 related variables
this can be done even with an ms-dos batch!
while working a tic80 project with zbs, in parallel, supposing we are in <tic80-fs-folder>\merge-test
subfolder:
type > mergedlua.tmp
type *.lua >> mergedlua.tmp
if exist mycart.tic (
F:\Games\tic80\tic80.exe mycart.tic --cmd="import code merge-test/mergedlua.tmp & save & run"
) else (
F:\Games\tic80\tic80.exe --cmd="new lua & import code merge-test/mergedlua.tmp & save merge-test/mycart & run"
)
del mergedlua.tmp
i am using this and it works flawlesly... question is, how to convert this batch to a zbs lua package, to make it easy for everyone
we must know previously:
--cmd
argument are relative to tic80 filesystem folder, no matter the host system current work dir (i.e. chrooted) (see -fs
arg and folder
cmd) (not the case for embedded lua interpreter that inherits sysenv, see https://github.com/nesbox/TIC-80/issues/2426#issuecomment-1879215018 just as example because merging files makes require()
unnecesary)-cmd
argumentsmycart.tic
for each project (with many files opened, zbs just take the file name of the SELECTED TAB)mergedlua.tmp
limitations:
del mergedlua.tmp
waits execution until tic80 closesthis can be done even with an ms-dos batch! i am using this and it works flawlesly... question is, how to convert this batch to a zbs lua package, to make it easy for everyone
Batch work only for window, you need this functions for translate in lua.
function string.cmp(str,str2) -- string is egal
if str:len() ~= str2:len() then
return false
end
for ic=1,#str do
if str:byte(ic) ~= str2:byte(ic) then
return false
end
end
return true
end
function getos()
local BinaryFormat = package.cpath:match("%p[\\|/]?%p(%a+)")
if BinaryFormat == "dll" then
return "Windows"
elseif BinaryFormat == "so" then
return "Linux"
elseif BinaryFormat == "dylib" then
return "MacOS"
end
BinaryFormat = nil
return ""
end
function scandir(directory) -- get array of file name
local i, t, popen = 0, {}, io.popen
local pfile
if string.cmp(getos(),"Linux")==true or string.cmp(getos(),"MacOS")==true then
pfile = popen('ls -a "'..directory..'"')
else
pfile = popen('dir '..directory)
end
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end
function is_fileext(path,ext) -- check file extension
local extsize = ext:len()-1
local extstring = path:sub(path:len()-extsize,path:len())
if string.cmp(extstring,ext)==true then
return true
end
return false
end
function is_dir(path)
local f = io.open(path, "r")
local ok, err, code = f:read(1)
f:close()
return code == 21
end
function is_file(path)
local f = io.open(path, "r")
if f~=nil then
f:close()
return true
end
return false
end
function create_file(path)
local fic = io.open(path,"w")
fic:write("")
fic:close()
end
function del_file(path)
if not is_dir(path)==true then
if string.cmp(getos(),"Linux")==true or string.cmp(getos(),"MacOS")==true then
popen('rm '..path)
else
popen('del '..path)
end
end
end
function cat_file(src,out)
if is_file(src)==true and is_file(out)==true then
popen('cat '..src..' >> '..out)
end
end
an example
local d = scandir('.') -- array of file name
for i=1,#d do
if is_fileext(d[i],'.lua')==true then
-- print only lua file
print(d[i])
end
end
calls the command and returns a string with the result
all files must/will be in the same folder (luas and tic) neverless they are opened or not (works with saved version)
it need to define tic80.libpath in config file
also i suggest to change config variable names from xxx.tic80 to tic80.xxxx instead, going from general to particular, this way is more easier to group/find more future tic80 related variables
i have a general idea on how this new feature could work, but i am boiling my head since many days in front of my editor trying to figure out how to do this (i suck at programming, augmented with an awful documentation xD )... maybe you know how to do it:
-fs PROJECT_DIR
option, anyway we will use zbs+plugin to develop TIC-80 carts instead playing them finished :) *.lua
files to another temporary file other type to avoid merging itself :) :echo: 2>CART_NAME.lua.tmp & type *.lua >> CART_NAME.lua.tmp
(source = https://ss64.com/nt/echo.html )echo -n > CART_NAME.lua.tmp ; cat *.lua >> CART_NAME.lua.tmp
tic80.exe -fs PROJECT_DIR -cmd="new lua & import code CART_NAME.lua.tmp & save CART_NAME & run"
tic80.exe -fs PROJECT_DIR -cmd="load CART_NAME & import code CART_NAME.lua.tmp & save & run"
what do you think?.. do you think is possible?, do you have an idea on how to achieve these?... do you like them ? :)
some resources i could have found: official ZBS plugin documentation (from homepage) = https://studio.zerobrane.com/doc-plugin , there are some info like:
onInterpreterLoad
|...Close
when select/deselect some interpreter from menu project > interpreter for exampleide.config.path.projectdir
, but i am sure there are many ways maybe better to get itsome simplifications:
i honestly tried to modify the plugin by myself, but i bumped with lack of documentation... for example there is an ID()
function that i have no idea what it does, also this function seems to accepts constant-looking parameters that are specified nowhere... i searched for definitions in zbs code with dngrep and in zbs and wxwidgets documentation but i found nothing related, i am very frustrated with this :(
look at this ... maybe we can use some of the tools mentioned here, some are written in lua:
https://github.com/nesbox/TIC-80/issues/2426#issuecomment-2397252479
you read this discussion in tic80 issues page: https://github.com/nesbox/TIC-80/issues/2668 ... i better keep analisys there and move technical questions here
i have some ideas on how to implement this, i hope they were not so hard, maybe the most practical woule be to let the package do all the work for us everytime, merging project files in a temp thus killing the need for
require()
's also... something like:but you need some way to specify project cart name before: maybe right click on on project > set cart name, or menu project > properties > esit cart name, or whatever (i dont know how, i a not a plugin/package developer nor have experience with zbs)