Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jim Bauwens

Pages: 1 ... 5 6 [7] 8 9 ... 125
91
Lua / Re: Converting a Text Adventure from nSpire BASIC to Lua
« on: August 20, 2013, 03:08:58 pm »
I think I'd probably extend it into multiple tables for the purposes of my program, since there are several hundred 'lines'. I guess I would have a variable denoting which table I'm currently in, and have some sort of syntax in a line, say:

Code: [Select]
[5] = {"Going to next table...","jumpTableExample2"}
And then modify the table parser to recognise that line[2] is a string, and then jump to that table.

Yes, of course you should modify it to your needs. My code is really more of a concept showing how I would do it. Anyway, glad that I could help :)

92
TI Calculators / Re: Nspire Screen rotated 180 degrees
« on: August 19, 2013, 04:40:59 pm »
That wouldn't help, the issue is also when starting up. It might be a jumper (a little resistor for example) that is loose or bad that sets the rotation of the display. That is of course just speculation though, but I can't see how it could be a software problem.

93
TI Calculators / Re: Nspire Screen rotated 180 degrees
« on: August 19, 2013, 02:20:57 pm »
Very strange, judging those versions I don't think it's a prototype.
If you slightly tap your device, does that do anything? (Just seeing if it could be a hardware problem with a jumper or similar)

94
TI Calculators / Re: Nspire Screen rotated 180 degrees
« on: August 19, 2013, 01:19:17 pm »
That wouldn't make sense if the (entire?) startup screen is rotated. Maybe there is something with the display controller, although I don't see a direct way to instruct the controller to rotate the display.

Is it possible to provide a picture of the device, and the OS version + the boot 1 and 2 versions?
You can find the OS version in [Settings -> Status] and the boot 1 / 2 versions in [Settings -> Status -> About].

95
Lua / Re: Converting a Text Adventure from nSpire BASIC to Lua
« on: August 19, 2013, 06:08:52 am »
What about something like this?

Code: [Select]
local jumpTable = {
    [1]  = {"Choose your own adventure!"},
    [2]  = {"You wake up."},
    [3]  = {"Get out of bed?", {y=4, n=11}},
    [4]  = {"You get out of bed"},
    [5]  = {"Eat some breakfast?", {y=6, n=8}},
    [6]  = {"You eat some delicious breakfast."},
    [7]  = {"You win! You ate delicious breakfast.", "END"},
    [8]  = {"You go without breakfast."},
    [9]  = {"You should always start your day with breakfast!"},
    [10] = {"You lose!", "END"},
    [11] = {"You stay in bed all day."},
    [12] = {"You lose. You shouldn't be so lazy", "END"}
   
}

local position = 1
local question = false
local input = ""

local lines = {}

function printLine(str)
    table.insert(lines, str)
end

function drawLines(gc)
    local height = platform.window:height()
    local lineHeight = 14
    local linesMax = math.floor(height / lineHeight) - 1
    local linesTotal = #lines
    local startLine = math.max(linesTotal - linesMax, 0)
    local line = startLine
    for y=1, math.min(linesMax, linesTotal)  do
        line = line + 1
        gc:drawString(lines[line] or "", 2, y * lineHeight - lineHeight, "top")
    end
end

function jump()
    local text
    local data
    local line
   
    while not data do
        line = jumpTable[position]
        text = line[1]
        data = line[2]
       
        printLine(text)
        position = position + 1
    end
   
    if type(data) == "table" then
        position = position - 1
        question = true
        printLine(">")
    end
   
    platform.window:invalidate()
end

function on.charIn(ch)
    if question then
        input = input .. ch:lower()
        lines[#lines] = ">" .. input
        platform.window:invalidate()
    end
end


function on.enterKey()
    if question then
        if input == "y" or input == "yes" then
            position = jumpTable[position][2].y
        else
            position = jumpTable[position][2].n
        end
        input = ""
        question = false
        jump()
    end
end

function on.paint(gc)
    drawLines(gc)
end

function on.construction()
    jump()
end


You got a jumpTable containing all the statements and locations where you need to jump to in case something happens. Of course you still could extend it to make other stuff happen in other cases, this is just an example.
You could also easily add something so that if you would have a line such as {123} it would jump to 123. That way you can combine join and do lot's of other fun stuff. Maybe add a stack so you can have subroutine like stuff where you put your current location on the stack, jump to another spot and then return back when finished.

96
Lua / Re: Converting a Text Adventure from nSpire BASIC to Lua
« on: August 18, 2013, 06:32:59 pm »
Could you give a 'schematic' on how it's structured? That would help me get a better idea :)
Also, it is possible to still have a loop (so non-event based) if you use coroutines. That would make a port very easy I suppose. But it's of course still better to try and use the event system.

97
Very nice work ExtendeD! I'm looking forward to seeing the stuff in the Ndless API :)

98
Art / Re: HAMA/Perler beads
« on: August 17, 2013, 06:59:07 am »
Yeah, it's the wrong side. But I don't have those anymore, I send them to someone in the Netherlands.

99
Art / Re: HAMA/Perler beads
« on: August 17, 2013, 05:00:27 am »
Looks nice!
I've made some before, it's fun indeed.

Spoiler For A picture:


Yes, ponies..

100
TI-Nspire / Re: Minecraft 2D for TI-Nspire
« on: August 16, 2013, 04:15:08 pm »
There are events for the tab and esc keys, so maybe you could use those.

101
Lua / Re: Updating WZGUILib
« on: August 16, 2013, 10:52:59 am »
Let us analyse your code a bit to identify the problem. First let's replace bt[3] by 'myfunc' and bt[4] by 'params'.
That would give us the following code:

Code: [Select]
local fCall = assert(loadstring(myfunc.."("..params..")"))
a, b = fCall()
self:addHistoryEntry("Returned: "..tostring(a).." and "..tostring(b))

Now, what does loadstring do? Create a chunk from the given data. Basically, create a function with the contents that you pass to loadstring. So if we evaluate what actually happens, we get something like this:
Code: [Select]
function fCall()
   myfunc(params)
end

As you can see, the function will never return anything because it doesn't contain a return statement. So there is your problem ;)

Now, about the code itself, do not use loadstring for this. It will significantly slow down your script. Rather do something like this:
Code: [Select]
local params = {}
for i = 4, #bt do
   table.insert(params, bt[i])
end
local myfunc = _G[bt[3]] -- if it's a global function that is
a, b = myfunc(unpack(params))
self:addHistoryEntry("Returned: "..tostring(a).." and "..tostring(b))

Now, this is code for the situation that you have now. If possible, just pass the function as a reference, not as a string. Then put all the parameters in a table so that you don't need to copy them in a new one. Something like this:
{data, data, functionreference, {param1, param2}}
Then you could do a, b = bt[3](unpack(bt[4]))

102
Lua / Re: Updating WZGUILib
« on: August 16, 2013, 02:56:00 am »
Can you post your code? So far I never have had a problem with it.

103
General Calculator Help / Re: Semi-broken Nspire Touchpad calculator
« on: August 15, 2013, 03:54:51 pm »
The TI-Nspire doesn't have any buzzer, so it must be something malfunctioning. Could you try connecting your Nspire to the batteries while it's open? Maybe you could identify the component/location where the sound is coming from.

104
General Calculator Help / Re: Semi-broken Nspire Touchpad calculator
« on: August 15, 2013, 12:13:54 pm »
I would open it up and see if there are any sign of a shortcircuit or damage.

105
Lua / Re: Numstrat - Stumbling into Lua
« on: August 15, 2013, 06:03:17 am »
Well, you should always try to avoid that your script throws errors to the user level (so that you need to catch it with registerErrorHandler). Of course it's not bad to implement it in case that something goes wrong unexpectedly, but still a well designed script should never actually be able to arrive to that point.

Pages: 1 ... 5 6 [7] 8 9 ... 125