Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Before Characters (https://forums.graalonline.com/forums/showthread.php?t=134263951)

Astram 07-19-2011 03:50 AM

Before Characters
 
I'm trying to make a gani set, but its from the ganis folder. I need to know how to do:
PHP Code:

temp.foo fly.gani;
setani(temp.foo,NULL); 

This is just an example of the situation im in. I just need help on how to removed the .gani suffix from a string. If anyone can help PLEASE do. I am loading it from a folder. So I cant really edit the string (I think).

oo_jazz_oo 07-19-2011 03:59 AM

Quote:

Originally Posted by http://gscript.graal.net/substring
Usage
Syntax: string.substring(index[, length]);
Returns string.

Example
PHP Code:

function onCreated()
{
  
temp.foo "Hello World!";
  echo(
temp.foo.substring(1));
  echo(
temp.foo.substring(65));



This is a good starting point. If you know for a fact that the file being passed has .gani attached, you can just use substring. Otherwise, you might want to use a mix of http://gscript.graal.net/pos and substring.

fowlplay4 07-19-2011 04:05 AM

You could use substring, but it's so much easier just to use:

extractfilebase(str) - Extracts the base file name from a string. I.e: levels/file.nw would return file.

Usage:

PHP Code:

function onCreated() {
  
temp.filename "fly.gani";
  
temp.gani extractfilebase(temp.filename);
  echo(
temp.gani); // echos: fly



Astram 07-19-2011 04:10 AM

Quote:

Originally Posted by fowlplay4 (Post 1659361)
You could use substring, but it's so much easier just to use:

extractfilebase(str) - Extracts the base file name from a string. I.e: levels/file.nw would return file.

Usage:

PHP Code:

function onCreated() {
  
temp.filename "fly.gani";
  
temp.gani extractfilebase(temp.filename);
  echo(
temp.gani); // echos: fly



Thanks fowlplay4. Thats pretty good. ;)

oo_jazz_oo 07-19-2011 04:15 AM

Didn't even know of that function. :o

Learn something new every day...


All times are GMT +2. The time now is 01:27 PM.

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