WarWolf
March 6th, 2003, 04:56 AM
I want to let a script call functions and manage properties in my program. As i understand this is inpossible if i not create my own script engine. Any ideas?
//B4N WarWolf
//B4N WarWolf
|
Click to See Complete Forum and Search --> : Script to manage code objects? WarWolf March 6th, 2003, 04:56 AM I want to let a script call functions and manage properties in my program. As i understand this is inpossible if i not create my own script engine. Any ideas? //B4N WarWolf pareshgh March 6th, 2003, 10:56 AM are you talking about this script at runtime or design time. if its a design time issue then you need to work on PropertyManager. which manages the property etc. you can save it also on I/O file as XML or so and later you can retrive it... thanx Paresh ShadowGopher March 6th, 2003, 12:45 PM Originally posted by WarWolf I want to let a script call functions and manage properties in my program. As i understand this is inpossible if i not create my own script engine. Any ideas? //B4N WarWolf WarWolf, Do you mean scripting languages like Javascript and VBScript? pareshgh March 6th, 2003, 03:28 PM well we should wait for his answer and guess thinking :confused: WarWolf March 8th, 2003, 03:47 PM Well i want to expose methods and propeties in runtime ex i can pass parameters to a script function at certin events or something like that. Kind of triggers on certin events. ShadowGopher March 10th, 2003, 10:53 AM I still don't understand what you're asking. Are you trying to execute methods in a dll or exe from within a scripting language like Javascript or VBScript? pareshgh March 10th, 2003, 11:18 AM warwolf, you would be better-off looking in dynamic loading of assembley. u will need to search MSDN on that. its a big topic though ! WarWolf March 10th, 2003, 04:29 PM Let's say i got this game, an RPG the game data is stored in a database that contains items such as characters weapons and the world. Say some user want to implemet a sword that steal life whithout to recompile the whole game. Ex this script function that runs for all events. void ScriptEventHandler (int nEvent,CChar sender,CChar target,CObject object) { if(nEvent=WEAPON_HIT) { target.hp -=10; sender.hp +=10; } } so this functions is in some kind of script that i can call from my game. Functions checks what kind of event is rised, and if you hit someone it takes 10 life from victim and adds to your health. P.S. Im open for more suggestions how to make the game more dynamical. I want to be able to implement some special functions for weapons and NPC's without recompile every time i got a new idea. "When was the last time you did something for the first time" //B4N WarWolf pareshgh March 10th, 2003, 04:33 PM you simply need to design your Objects and give them a suitable method. for example if Object is Person then you can have property which says HasSword() which returns true if that character has sword. this is known as method invocation. your object desing, polymorphism etc will help you do this. when you make a method move sword then you will have sword object a member of person and it will be initialized only if person has a sword and will have methods that describes your script. actually the word script was mistaken. Paresh;) pareshgh March 10th, 2003, 04:34 PM also forgot to mention that, raising events can be done by using delegates and event calling, from mouse movements or some thing else. Paresh WarWolf March 12th, 2003, 04:45 PM Allredy know about this, the problem is that the objects such as characters and weapons data are in a database and i wan't to be able to add new "effects" to weapons and npc's that you can talk to without the need to compile the object. Is't the script idea possible i gonna fall back to make it thru interfaces and polymorthism. And make a compile for special objects and just add the libary path in database for dynamical linking. /Thanks alot for your answer anyhows :P //WarWolf pareshgh March 12th, 2003, 04:55 PM Ah ! I got your point, what you will need to do is, Make a general Interface and make a dll of it, the Class who ever implements that will be candidate to paint or render the character, Now what you do is when you load the game or your program you fetch for dlls in particular folder who is implementing the interface, (in this way you can create new dlls on the fly and still you don't need to modify the original exe) you can use Assembley members and check out reflection for more information. collecting the dlls at runtime gives you the ability to do dynamic stuffs like scripting etc. for example, consider a senario where you have a image and you need to provide various drawing methods at runtime, now the fact that you can't hardcode the Paint method and render image, what you will eventually do is 1) make interfaces 2) make classes which will implement this 3) load all the dlls with dynamic load 4) create a list of objects and have the user call any paint from the list now in this way if client requests the new paint method you just provide the new class and dll for that suitable Paint method which will render the Image differently, so you provide the dlls to clients at runtime and still your main exe application stays intact. hope this helps a bit Paresh codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |