Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-16-2009, 12:11 AM
racycle racycle is offline
smooth as eggs
racycle's Avatar
Join Date: Jul 2008
Location: Chanko
Posts: 136
racycle will become famous soon enough
Send a message via AIM to racycle
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?
__________________

Reply With Quote
  #2  
Old 10-16-2009, 12:18 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #3  
Old 10-16-2009, 12:34 AM
racycle racycle is offline
smooth as eggs
racycle's Avatar
Join Date: Jul 2008
Location: Chanko
Posts: 136
racycle will become famous soon enough
Send a message via AIM to racycle
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/"@[email protected]"/weapon1.file-format");

plz correct me if im wrong
__________________

Reply With Quote
  #4  
Old 10-16-2009, 12:41 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #5  
Old 10-16-2009, 01:00 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #6  
Old 10-16-2009, 01:17 AM
racycle racycle is offline
smooth as eggs
racycle's Avatar
Join Date: Jul 2008
Location: Chanko
Posts: 136
racycle will become famous soon enough
Send a message via AIM to racycle
thanks man , id leave rep if i knew how :P
__________________

Reply With Quote
  #7  
Old 10-16-2009, 11:52 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by racycle View Post
id leave rep if i knew how :P
Click the icon in the top right corner of his post
__________________
Reply With Quote
  #8  
Old 12-23-2009, 05:03 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by cbk1994 View Post
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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #9  
Old 12-23-2009, 05:42 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Ini files are far superior :3
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 12-24-2009, 12:03 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by coreys View Post
Ini files are far superior :3
ftw
__________________
Stan.
Reply With Quote
  #11  
Old 12-24-2009, 12:05 AM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by coreys View Post
Ini files are far superior :3
Yes indeed.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:34 AM.


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