Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

It has been awhile!

Sign in to follow this  
Mayan Obsidian


Hey. I'm still alive an kickin'. I'm not using my gamedev.net subscription to it's fullest however - but I guess not having a lot of time to dedicate to personal projects due to college is understandable. Right?
My new theme!

Oh and I did some things with the templates on my journal? You like? It took me around 2 hours of messing around with dreamweaver and learning how gamedev does their templates. I got my inspiration from Trapper Zoid and Mushu's good looking journals. Hopefully, the work that I put into it today will encourage me to post more updates.

Plus, CSS is just awesome! Except .. for when you're dealing with IE. Speaking of internet browsers I'm really loving Firefox 2.0. I like how it has some of the best extensions (Session saver, X in all tabs, etc) built right into it! Plus the spell checker in text boxes is a major help :)

Game Development

Last time I was super pissed at Lua. Last week sometime I had some kind of revelation with the coroutines and I now have something fairly decent working. It took a lot of digging in the lua mailing lists and various forums and books to find out how exactly they work and how to incorporate them into my project.

So here is the code:


Scheduler = {}

function Scheduler:init()
self.actions = {}

function Scheduler:asScript(obj)
if type(obj) == "thread" then
return obj
elseif type(obj) == "function" then
return coroutine.create(obj)
elseif type(obj) == "table" then
return coroutine.create(function() obj() end)
return coroutine.create(function() end)

function Scheduler:register(condition, script)
{cond=condition, script=self:asScript(script)}

function Scheduler:start(script)

function Scheduler:activate(script)
local status,nextCond = coroutine.resume(script)
if status then
if nextCond ~= nil then
self:register(nextCond, script)

function Scheduler:step()
for i, rule in ipairs(self.actions) do
if rule.cond==true or rule.cond() then
return true
return false

function Scheduler:run()
if table.getn(self.actions) > 0 then

It is basically a scheduler that steps through coroutines and then checks a condition to see if it is time to rerun the script.


function wait(seconds)
local wo = Game:wait(seconds)
local txt = "Eventid: " .. wo

function() return Game:checkEvent(wo) end)

function script1()
Game:logMessage("In Script 1!")
Game:logMessage("What, out of it!")

function script2()
for i=0,5 do
Game:logMessage("In script 2 .. will loop 5 times!")


And then in this piece of lua code. I have in my wait function a C++ call that will tell my event manager to create a timed event (Game:wait(seconds)) to wait for so many seconds, and then I yield the coroutine and then pass a condition. The Game:Checkevent(wo) function is another C++ call that will poll my Event Manager to see if that event happened or not. So far an Event can only be a passing of time, but I plan on extending it so that it could be when an object is in a certain location, or a button is pressed, or a door is opened, or even when another event completed.

Anyway, the next two functions are two scripts, and then the block of code after that initializes the scheduler and adds the two scripts to it's internal table (or queue) and then starts running them both at the same time. So basically I can have two actors just walk around and do their own thing. Pretty damn cool.
So what about the game?

Yeah. The game is still moving along. No, that's a lie. It's moving at a slooow speed. I work on it furiously for about 5-6 hours, and then I can't get back to it for like another week. Not the way I would like to be making it.

Today I just finished reorganizing my code so that everything is in gameplay states (intro state, main menu state, options state, playing state, credits state, etc) and this made it considerably easier to read. What I'm working on now is action mapping.

Right now I have an Actor class and an Actor Controller class. And the Actor will poll it's controller class for information on what to do whether it be jumping or moving forward or serving a customer, etc. The controller can be Input driven, or Network or AI driven. At least that's the plan so far. I haven't implemented the AI or Network part .. but the actor polling the controller works fairly well.

I've thought of a tentative project title - mainly because I'm sick of calling it "my project". I'm planning/hoping on calling it Tangent. I choose that name because my project is essentially a relationship building sim that takes place in a restaurant that the main character works at. Although the main character finds working there a little miserable, little jobs like that are just looked at as tangents in life. A minor detour from what she truly wants to do. We've all had jobs like this, right?

Although, I think that "Tangent" might sound a little too technical. Any opinions?
Sign in to follow this  


Recommended Comments

Yay! I knew I subscribed to this journal for a reason. [grin]

I'll have to read up more on Lua; I've been neglecting my scripting core in favour of stubbing out the renderer for my game.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!