ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Wed Aug 12, 2020 3:25 pm

All times are UTC

Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Addon making
PostPosted: Tue Jun 19, 2018 11:08 am 

Joined: Tue Jun 19, 2018 11:04 am
Posts: 1
So i was really tempted to make addons for this game as i really like the current ones being posted and the ones that i am using but i have looked it up and how to make said addons but i dont know where to get started, so my question to you guys(addon makers) what programming language(i write in C) would i need for addon making.

 Post subject: Re: Addon making
PostPosted: Tue Jun 19, 2018 8:51 pm 

Joined: Sun Dec 10, 2017 12:27 am
Posts: 79
The actual engine is written in C, but the development environment is all in Lua. I came into Lua cold in November (from C++ and java) and estimate it took me five weeks or so to grok Lua and maybe another couple of months to have the paradigms for the Tome Engine mostly down. The T-Engine implementation of Lua treats it like an object oriented language, with inheritance and so on. The two fundamental first-class composite types that you need to mess with are functions and tables (tables consist of an array-like indexable section plus a hash table spliced together). Everything is effectively passed by value, but 'table and function variables are references' (as Lua folk seem to like saying). The variable actually behaves as if it contained a pointer, but treated it as a value, so that if you pass a table/function/table-but-pretending-its-an-object to a function it will modify the original, but if you re-assign it won't overwrite the original. That is to say:
local x = 0 - primitives are passed by value
local foo = {bar = "baz"}  -- make a hash table with key["bar"] containing value "baz", this will be passed 'by value' but the 'value' is actually a pointer (ish)

function wipeFoo(x, foo)
  x = 1 = 10
  foo = {}

wipeFoo(x, foo)
print(x) -- spits out 0, the local x from the function is out of scope now
print( -- spits out 10, because the function modified a value inside the table.
               -- The locally-assigned empty table from the function is out of scope, but the original table wasn't overwritten by foo = {}
               -- instead, a new empty table was instantiated, and its pointer was assigned to the local variable foo inside the function
               -- leaving the original table alone (and effectively out of scope of the function at that point)

 Post subject: Re: Addon making
PostPosted: Wed Jun 20, 2018 1:28 am 

Joined: Mon Jan 27, 2014 10:40 am
Posts: 715
having never done ANY coding before, I managed to learn to make tome addons exclusively by looking at existing mods and doing lots of copy pasting and editing. It's pretty easy to deal with! :)

 Post subject: Re: Addon making
PostPosted: Wed Jun 20, 2018 3:36 am 

Joined: Fri Oct 10, 2014 4:00 pm
Posts: 907
Lua does allow calling C code, but in general the game logic is written in Lua. The language is designed to be user friendly so it shouldn't take too long to learn for an experienced programmer. I would say the more time-consuming parts is getting familiar with the ToME/T-Engine code base. Most of it is reasonably well documented, but it does take a while to get used to.

As Lokean said, Lua has first-class functions and tables, which are awesome by the way. You can assign functions to variables and pass as arguments (including anonymous functions) without the ugly syntax of C function pointers. Tables are the primary data structure, which can behave as either 1-indexed arrays or hash maps with mixed-type keys, or a combination of the two. The language isn't object-oriented by default, but the T-Engine implements its own class system. It's a shame Lua isn't more popular because it's a really powerful language with nice syntax and is relatively performant for an interpreted language; I suspect the lack of a built-in class system and its minimalist standard library makes it less popular than Python and comparable languages.

The ToME IRC channel is a good place to hang out and ask questions about making addons and Lua in general. Apparently there's an official ToME Discord channel as well, although I haven't be in there yet.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group