Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   arc system questions (https://forums.graalonline.com/forums/showthread.php?t=134256503)

racycle 10-16-2009 12:11 AM

arc system questions
 
Hey , im trying to better understand arc systems. How does a arc based system find the vars from inside the arc file? Is it case senstive?

On another note , whats the best way to do it for when all armor/weapons are unique? would it be a bunch of arc files or a list stored inside the arc NPC libary?

cbk1994 10-16-2009 12:18 AM

Some people (Ziro?) are going to tell you otherwise, but there's no reason to use an "arc" file. You might as well just use a text (.txt) file. Basically, what you're talking about is called a "MUDlib". I'd link you to a Wikipedia article, but I can't on these forums, so just go Google it.

Basically, it's a way to store unique items that can have custom properties. For example, you could easily create a sword with a custom name or stats.

They're traditionally used for RPG servers, but can also be used for other types.

You're going to want to do stuff like:
PHP Code:

temp.vars.loadVars("items/cb/cbk1994/item_1241242452345.txt");
// then you can access stuff like
echo(vars.item_name); 

also look into the functions loadVars and saveVars.

To save you'd do something like

PHP Code:

temp.item = new TStaticVar();
item.item_name "Super Sword";
item.item_weight 1.4;
item.item_power 50;
item.item_class "warrior";

item.saveVars("items/cb/cbk1994/item_random_id_here.txt"); 

You can open the file with File Browser (in RC) to see how it's formatted. Remember that to access files via script, you need to give the NPC-server folder rights, account "(npcserver)" and rights like "rw items/*/*/*".

There are tons of different ways to do it, and everyone likes to do it a different way. You might also want to look into SQLite for item storage.

racycle 10-16-2009 12:34 AM

ok so also to load the files stats i could do like

temp.new_item.strength = item.item.power;

for upgrades to change the file could i do something like

temp.new_item.strength = item.strength;
if(upgrade){
item.strength == item.strength+1;

and for the saveing for the new changes something like

temp.new_item.savevars("players/items/"@player.account@"/weapon1.file-format");

plz correct me if im wrong

fowlplay4 10-16-2009 12:41 AM

You may want to play around with Ziro's Item System in the Code Gallery, and get an idea how they typically work.

You're going find though that if you have to load text files for everything when they log on that it will be really slow, compared to one's using a Cache and/or SQL.

I imagine a lot of this is going to fly right over your head right now but it'll hopefully make more sense after some experience with one.

cbk1994 10-16-2009 01:00 AM

Let's say you have a class like 'item_functions' with a function like this:

PHP Code:

function loadItemByPath(path) {
  
temp.item = new TStaticVar();
  
item.loadVars(path);
  return 
item;


...then you can do stuff like

PHP Code:

function onCreated() {
  
this.join("item_functions");
  
  
temp.path "items/cb/cbk1994/item_1492032.txt";
  
temp.item loadItemByPath(path);
  
item.power += 5;
  
item.saveVars(pathfalse);


to update it.

racycle 10-16-2009 01:17 AM

thanks man , id leave rep if i knew how :P

Crow 10-16-2009 11:52 AM

Quote:

Originally Posted by racycle (Post 1530744)
id leave rep if i knew how :P

Click the http://forums.graalonline.com/forums...reputation.gif icon in the top right corner of his post :)

xXziroXx 12-23-2009 05:03 AM

Quote:

Originally Posted by cbk1994 (Post 1530725)
Some people (Ziro?) are going to tell you otherwise, but there's no reason to use an "arc" file.

Bit late reply, but here goes anyways! The only reason I ever used .arc to begin with, was because everyone else was doing it on Maloria (aka Maniaman, Zero and ShadowBlaze) - so it was rather natural for me to keep doing so. I always knew .arc was just a renamed .txt, and I've never recommended anyone to use the sooner above the latter. :)

coreys 12-23-2009 05:42 AM

Ini files are far superior :3

Kyranki 12-24-2009 12:03 AM

Quote:

Originally Posted by coreys (Post 1546455)
Ini files are far superior :3

ftw

Chompy 12-24-2009 12:05 AM

Quote:

Originally Posted by coreys (Post 1546455)
Ini files are far superior :3

:fro: Yes indeed.


All times are GMT +2. The time now is 11:30 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.