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.


Topics - AvianIsTheTerm

Pages: [1]
1
Introduce Yourself! / Hello - AvianIsTheTerm
« on: August 20, 2013, 01:43:05 am »
So yeah.

I basically made an account to get a bit of help with an nSpire programming question.

I've been aware of the existence of this site for a few years, but I've never really needed to do more than lurk up until now.

So, hi, I guess!

2
Lua / Converting a Text Adventure from nSpire BASIC to Lua
« on: August 18, 2013, 04:51:28 am »
Hello!

I haven't used these forums before, though I have lurked here occasionally to look for solutions to bugs etc. while debugging calculator programs.

I've gotten into a little bit of casual programming on TI Calculators, having used them for school, and being interested in programming more generally. Most of what I've done is on nSpire calculators, and as such I have an nSpire CX CAS model.

I've got a fair amount of experience using the built-in nSpire-BASIC language to do mathematical things and the like. I've only done minimal coding in Lua, though I know the general syntax of it, and I am familiar with other interpreter-based languages (by which I mean Python, mostly), in addition to C# and certain other compiled languages.

-----

Basically, I have the following scenario, and I'm just wondering if anyone has any particular ideas about how I could go about this.

Over the past couple of years, every now and again while bored I'll do a bit of development in a silly text adventure thing in the form of a 'Choose Your Own Adventure' story, made in nSpire-BASIC. The structure of it is really poorly done, since it wasn't planned at all. Basically, it just pops up dialogs with each bit of text in it, with Yes / No questions (done within a subroutine using RequestStr, accepting 1 as yes, 0 as no) at particular points. Each Yes / No decision sets the variable 'qa' to either 1 (for yes) or 0 (for no), and an IF statement then 'splits' the story into two paths.

As it's been developed haphazardly over a few years, there's no particular structure to the 'tree' of decisions - paths just split off with their own nested IF statements, and the 'story' is quite large - while I haven't counted the number of decisions and path splits that exist, I'd venture to say that there's well over a hundred of them in total (some paths are split off into their own subroutines so as not to lag out the device when developing on-handheld).

I'm interested in converting / rewriting this in Lua for reasons mainly related to the complete and utter lack of real I/O functions in nSpire-BASIC. I would like to be able to have the game run in such a way that you can actually quit the game while it's running - the dialog box popups prevent you from interacting with the OS interface. In addition, I'd like a better laid out UI - with buttons for yes / no rather than typing 1 or 0 into a dialog.

Now, here's the issue:

I'm sure I'm competent enough to be able to make a functional UI etc. in Lua. My problem is more general: since Lua is primarily event-based rather than imperative as nSpire-BASIC is, how can I convert my tree of decisions such that they will function, and can be simply and quickly added to at any time?

To explain further:

The BASIC version of my game essentially freezes the OS, and the entire thing is within a single subroutine (with subroutines splitting off from that). In Lua, I can't simply do that and maintain a functional UI that the user can interact with. Everything has to go through timer events, the UI is drawn in the paint event etc.

Hence, I can't simply just store the content of my text adventure in a massive nested tree of IF-ELSE statements.

Other solutions I've thought of either would be tricky to build in such a way that the user could interact with it, or alternately with these solutions it would be difficult to add new content at any point in the tree.

If I store the tree content within any 'indexed' data structure (like nested tables) then once I've set a path into that table I can't just easily go and 'split' that path into two subpaths at any given point.

So, to stop waffling on, my basic question is, in this scenario, how would you manage the storage of the game content in such a way that it can be played by the user and edited/modified easily and elegantly?

Thanks for any help you guys can provide!

Pages: [1]