mirror of
https://github.com/Oreolek/ink-instead.git
synced 2024-04-26 06:09:29 +03:00
trying to make an ink module
This commit is contained in:
parent
e494c4f855
commit
2ef587bd68
44
main3.lua
Normal file
44
main3.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
--$Author:Alexander Yakolev, 2018
|
||||
--$Version:1.0
|
||||
local pink = require('pink.pink')
|
||||
require "noinv"
|
||||
|
||||
local story = pink.getStory('test.ink')
|
||||
--[[
|
||||
while true do
|
||||
-- 2) Game content, line by line
|
||||
while story.canContinue do
|
||||
pn (story.continue())
|
||||
end
|
||||
-- 3) Display story.currentChoices list, allow player to choose one
|
||||
for i = 1, #story.currentChoices do
|
||||
print(i .. "> " .. story.currentChoices[i].text)
|
||||
end
|
||||
if #story.currentChoices == 0 then break end -- cannot continue and there are no choices
|
||||
local answer=io.read()
|
||||
print (story.currentChoices[tonumber(answer)].choiceText)
|
||||
story.chooseChoiceIndex(answer)
|
||||
end]]
|
||||
|
||||
main = room {
|
||||
nam = "Ink module",
|
||||
decor = function()
|
||||
while story.canContinue do
|
||||
pn (story.continue())
|
||||
end
|
||||
stead.deref('main').obj = {}
|
||||
for i = 1, #story.currentChoices do
|
||||
table.insert(main.obj, {
|
||||
nam = i;
|
||||
dsc = story.currentChoices[i].text;
|
||||
choiceText = story.currentChoices[i].choiceText;
|
||||
index = i;
|
||||
act = function(this)
|
||||
story.chooseChoiceIndex(this.index)
|
||||
walk('main')
|
||||
return this.choiceText
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
-- FIXME clean up
|
||||
|
||||
if not arg[1] and not (...) then error("Usage: `require` this file from a script or call `lua pink/pink.lua parse game.ink`") end
|
||||
local folderOfThisFile = arg[1] and string.sub(..., 1, string.len(arg[1]))==arg[1] and arg[0]:match("(.-)[^/\\]+$") or (...):match("(.-)[^%.]+$")
|
||||
-- if not arg[1] and not (...) then error("Usage: `require` this file from a script or call `lua pink/pink.lua parse game.ink`") end
|
||||
-- local folderOfThisFile = arg[1] and string.sub(..., 1, string.len(arg[1]))==arg[1] and arg[0]:match("(.-)[^/\\]+$") or (...):match("(.-)[^%.]+$")
|
||||
local folderOfThisFile = './pink/'
|
||||
local getParser = function () return require(folderOfThisFile .. 'parser') end
|
||||
local runtime = require(folderOfThisFile .. 'runtime')
|
||||
|
||||
|
@ -79,10 +80,10 @@ end
|
|||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
if arg[1] == 'parse' and arg[2] then
|
||||
print(dump(parse(arg[2])))
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
return api
|
||||
|
|
Loading…
Reference in a new issue