stackie.lua, A stack library for Lua

Feel free to showcase your own projects!
Post Reply
User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 31 Mar 2012, 21:20

Ok there is a few thing I need to say before I start:
I am posting it here not the love2d forums because it is a working prototype, I am making it multi-stack based (more than one stack).

What is a stack?
Think of a stack as a set of cards. The value of the stack is the card on top. If you "push" a card, it will go on top of the stack, if you "pop" a card, it will go to the bottom.

How to use:

Set of functions:

getStackValue() - returns the value of the stack.
push(value) - Pushes a value
pop(value) - Pops a value
isError(expression) - This is something I added for my own use, it returns true if a value is nil and vice versa.

Here is an example (lua only):

Code: Select all

require("stackie")

push("hi")
print(getStackValue())
Here is a set of errors:
Stack is empty - there was no string pushed. (gets called in getStackValue())
Stack instance does not exist - you were messing about with the main file and you deleted the stack. (gets called in getStackValue())

Download:
It is hosted on Github: https://github.com/rokitboy/stackie


Please give me ideas for this project! Do you think I should continue?

User avatar
Lawnboy
Posts: 836
Joined: 03 Feb 2012, 02:24

Post » 31 Mar 2012, 23:38

Can I see a .love example of this?

User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 31 Mar 2012, 23:55

I can give a code example:

Code: Select all

function getHeroName()
if selection = 1 then
push("Bob Marley")
else if selection = 2 then
push("Bill Raizer")
end

heroname = getStackValue()
This will make more sense when I make it mult stack.

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 02 Apr 2012, 00:33

IMO befunge is the ultimate way to use stacks. try it, it's fun.

User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 02 Apr 2012, 00:47

This is outdated, I finished my stack system, not releasing yet though.

User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 02 Apr 2012, 14:47

NOTHING TO SEE HERE! OUTDATED!

Post Reply