My fist attemot at writing my own Lua API - need guidance

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
pal4
Swooper
Swooper
Posts: 63
Joined: Wed Dec 23, 2015 7:57 pm

My fist attemot at writing my own Lua API - need guidance

Postby pal4 » Mon Feb 06, 2017 6:27 pm

I notice a lot of NPCs and their AI have been created by various expert programmers and opened to the public via these forums. I was hoping to try my own hand at writing one of my own, one of the simpler Mario enemies to make an API for: the Thwimp. But I'm no expert. I'm still working on understanding the codes LunaLua has to offer and how to work them. (That wiki is really unreliable, man.) So if somebody would like to help via guidance I would really appreciate that.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9877
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: My fist attemot at writing my own Lua API - need guidance

Postby Emral » Mon Feb 06, 2017 6:34 pm

Thwimp's pretty simple. I made it for 2.0 a while ago but don't be discouraged as I think it's a pretty good place to start.
There's a tutorial on making an API here:
http://wohlsoft.ru/pgewiki/How_To:_Make ... custom_API
It only covers the fundamental basics of how an API is set up, but understanding this as the framework is pretty important.

If you're working with NPCs you have to be somewhat careful - their speedX and speedY cannot be modified if vanilla SMBX also modifies them. The workaround is:
x = x - speedX + customSpeedX (negating vanilla speed and adding your own). Here's some stuff NPCs can do:
http://wohlsoft.ru/pgewiki/NPC_(class)
Try to pick a simple NPC with not too much AI to negate. A spiny sounds ideal for the base for a thwimp.
You'll also wanna make use of pnpc to store variables like timers per npc object:
http://wohlsoft.ru/pgewiki/Pnpc.lua


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari