Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Lua Questions

Author
Message
Jimanji
10
Years of Service
User Offline
Joined: 4th Jan 2014
Location: Montana
Posted: 4th Jan 2014 08:52
Hey all,

I am starting a project I attempted over a year ago because it was sloppy and not working out. I made a client / server small rpg with the server having special functions to add content. For example creating new classes, weapons, monsters, or areas. I was basically just using numbers to change the damages or life and stuff, I could not customize it much.

So...

Is Lua something that would help with this. I want to be able to program files while my server is live so I dont have to reset to have the changes update. And how hard is it to add lua to vc++ 2008? cause I havent found much online about it. Is it as simple as linking an unzipped folder of lua to my project and then include the files?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Jan 2014 22:04
Wouldn't it be better to use data files for something like that?
But yes, lua would work if you actually need to be able to do customizable programming. You would need to set your server up to discard the old script and load the new one when the files get updated though. Also it is pretty dangerous to change the operation of a server while it is live; you probably want to try out the changes in a safe environment first, lest your server may crash or start doing things it isn't supposed to.


"Why do programmers get Halloween and Christmas mixed up?"
Jimanji
10
Years of Service
User Offline
Joined: 4th Jan 2014
Location: Montana
Posted: 5th Jan 2014 04:58
What do you mean by data files? I used a flat file system to store data but my data only held numbers so a weapon file might have number 1 for weapon type 1 and a second number like 3 for get life on hit for example. But I have to hard code what these weapons do in the server. I want to be able to be inside my server program in a text area and type a file that can understand code. So i can be like players health += damage done or something like that and save the file to the local system and click update which sends the new information to all of the clients. This way I do not have to hardcode inside the client and server all I have to do is load these files. That is why I was thinking lua would be a good choice if lua can do this.

How would you set the system up for this with data files?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Jan 2014 12:05
Usually you would just define some weapon types (in your server's "hard" code) and have variable settings lige damage potency, reload time, ammunition capacity etc. that you can read from datafiles. I can see the allure in doing it the way you're describing but you usually don't implement completely new weapon types often enough that it warrants the permanent slowdown that would be caused by running a script (most of the time such will be significantly slower than having the command codes in your compiled server application). You will also have to update the clients to visually represent the new weapon anyway so it whouldn't be a huge deal to take the server offline for a bit while you update it.

A faster approach if you really want to have separate code modules that can be swapped at runtime would be compiling dll files that your server can load / unload as needed. This gives much better performance if the "script" functions need to be called a lot. I believe that is also how Unity implements its C# "scripting" system, although don't quote me on that.


"Why do programmers get Halloween and Christmas mixed up?"
Jimanji
10
Years of Service
User Offline
Joined: 4th Jan 2014
Location: Montana
Posted: 5th Jan 2014 16:03
Thanks for the advice. I might try data files a second time and see how it goes. On top of me disliking the data files method, my object oriented programming was rather poor last year which made it more difficult to work with the game. Maybe I am associating that with the way I was handling the data from the files. I'll give it a shot and see what happens.

Thanks.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 6th Jan 2014 01:10
Quote: "Usually you would just define some weapon types (in your server's "hard" code) and have variable settings lige damage potency, reload time, ammunition capacity etc. that you can read from datafiles."


That is what I have been doing, my program loops through each subfolder in, for example, in a folder called "Weapons" and loads each data file with stats for each weapon so I don't have to hard code everything.

If you want I can post some of my code, don't expect it to look to pretty though
Jimanji
10
Years of Service
User Offline
Joined: 4th Jan 2014
Location: Montana
Posted: 11th Jan 2014 05:46
Hey Mr Bigglesworth,

if you dont mind posting some code I would like to look at it. I think my old system had something similar to what you are talking about. I had one file that had the file names of every other file, and I would read that file to open all the filenames in the folder. Im thinking if I am going to redo it again, I might shoot for a SQL solution to do the same thing so I can create a website to go with the game, and have the data easily accessible. This is kind of going off topic, but do you know how you would do the same flat file system to have items like diablo games that are randomly generated. I gave it a good attempt but using the flat file system I didnt know how to record all the information unless I hard coded every type of item name, and things started getting complex which is kinda related to the original question. I thought lua would make it easier to do this because I could just code a new weapon if I wanted right from lua and not have to go in and code in the server files. Thanks.
The Tall Man
11
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 11th Jan 2014 09:30
Come Mr Bigglesworth!

(been wantin' to say that ever since I saw your name in the forum hehe )

Q: ...you mean computer imagery was still based on the paradigm that the world was flat? Even into the 21st century??? Talk about doing something the hard way!

A: Yep! Back then people would render simple shapes with complex meshes of thousands of flat little triangles. Next to the bottleneck processors they used, it's the main reason why their computers were so slow. In the last days of the religious atmosphere of centralization and trade, corporate dogmas had people believing that flat was faster.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 17th Jan 2014 21:23 Edited at: 17th Jan 2014 21:25
So how I do it is have a class for each item that has all the required data in it ready to be instanced into individual items. I have a manager class that loops through all the subfolders in a folder containing a config file for the item and any art assets the item needs. The manager class first loads the config file for each item and parses it then instances a new 'item' class for each item in the items folder.

I achieve that by using std::vector which allows me to make a dynamic list of the item classes:



I gave a manager class a function 'Update()' which is run every game cycle to update the items. If the give your item class an 'Update()' function you can loop through the item list (vector) and call that function every time the manager class updates:




So to load the items you loop through each subfolder containing the item data:

Login to post a reply

Server time is: 2024-11-18 21:39:53
Your offset time is: 2024-11-18 21:39:53