Author Topic: Pulling out pieces of a tag  (Read 411 times)

Legacy_Sarcose

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Pulling out pieces of a tag
« on: February 09, 2012, 06:40:42 pm »


               If I understand tags correctly, it is possible to grab items by referring to only parts of their tags, starting from left to right.

Now let's say I have a node-based climb system already in place, and I want to add a randomized-landing element to it. All the nodes already land to two specific spots - one fall and one success, linked to that specific node by its tag. But all the nodes and waypoint landings also have the same tagging convention and only are separated by coordinate numbers.

Is it possible to pull a partial string out of a tag already retrieved, such as the string sTag or the OBJECT_SELF's tag itself? Can I for instance make a switch statement that checks if a certain part of the tag is == X, or is there perhaps a function that can simply check the number of characters in a string and interact with it by removing any of nY characters from the string starting from the end and working your way back?

Edit: In other words, once I get the tag from OBJECT_SELF that is normally used to determine the landing coordinates for pass/fail, I subtract the end few characters (leaving only the floor coordinate) to create a base tag from which I can then randomize the landing, without adding new waypoints and minimal new checks.
               
               

               


                     Modifié par Sarcose, 09 février 2012 - 06:43 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Pulling out pieces of a tag
« Reply #1 on: February 09, 2012, 07:00:48 pm »


                Yes, check out GetSubString  and FindSubstring for processing the string (parsing) into smaller pieces. You'll want to use a delimiter like "_" or "." or "*" or whatever.

I wrote a few string parse functions that work for me, but don't have access to them right now. I do however have a pastebin example which include examples of how to parse a string. You may have to stare at them a bit however to figure out what is going on. Sorry.
               
               

               
            

Legacy_eeriegeek

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-0
Pulling out pieces of a tag
« Reply #2 on: February 09, 2012, 08:53:02 pm »


               If your node tags are something like:

climb_node_1
climb_node_2
climb_node_3
You can simply use something like this:

int nTagNo = StringToInt(GetSubString(GetTag(oNode),11,1));

to get the node number from the tag. To pick a random node to fall to:

string sFallPointTag = "climb_node_" + IntToString(Random(3)+1);

               
               

               


                     Modifié par eeriegeek, 09 février 2012 - 08:53 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Pulling out pieces of a tag
« Reply #3 on: February 09, 2012, 09:17:45 pm »


               In eeriegeek's example in which only the last character matters

You would get the integer as follows:
string sTagString = GetTag(OBJECT_SELF);
string sFallNode  = GetStringRight(sTagString, 1);
// if the integer matters..
int nFallNode      = StringToInt(sFallNode);
               
               

               
            

Legacy_Sarcose

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Pulling out pieces of a tag
« Reply #4 on: February 09, 2012, 10:26:53 pm »


               Okay I am consistently impressed with the expediency with which I get replies on this forum for a game that is 10 years old and has had a sequel and several more advanced RPGs by Bioware to draw away fans.

Thanks a lot, guys. I will get to work checking out your advice and report back, as usual.

Also I wanna say that I've never scripted before so heavily, though I have tried in many games. Something about the NWN scripting system is just really really workable it seems.
               
               

               


                     Modifié par Sarcose, 09 février 2012 - 10:36 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Pulling out pieces of a tag
« Reply #5 on: February 10, 2012, 01:56:06 am »


               I'd really like to see your climbing script in full form when it's completed.

FP!
               
               

               
            

Legacy_Sarcose

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Pulling out pieces of a tag
« Reply #6 on: February 10, 2012, 02:01:33 am »


               I'll definitely post it on the vault. However there are a lot of issues I have with its style that I'll have to make a large pass on the whole document, probably with help from the community, before I post it.

Also, the reason I'm implementing the random-fall feature is that one of my players is going to play a pixie, and because I want to give the rest of the players something to do with the big climb area in the module once they've already passed it - I'm implementing a flight override system that enables me to set each node with a variable to determine how easily the wind can splat the character '<img'>

Some of the things I wanna do before I end up posting it:
1. Finish this flight override /randomized flinging the character around system
2. Turn the passive Iron Spikes DC change I implemented into a time-consuming activity that can be interrupted by combat, resulting in the player falling (taking time to pound the spikes into the wall)
3. More options for items (so far I have a grappling rope and boots of climbing which give +2 each, with the rope being able to break, and iron spikes which can be consumed to change a check to DC 15 on stable walls)

Edit numero dos: here's the pastebin I posted in the earlier thread, which does not contain full item implementation, has really sloppy variable declaration, and has a bug in dying players not jumping to the fall destination (all of which are fixed in my own copy, as I implement this flight system on top of it all).
http://pastebin.com/pnAx9Mk8 -- said sloppy variable declaration, which was pretty much done almost entirely stream of consciousness (and I'm still not sure why to do it before void main{} except that it seemed like a good idea to not have thirty or more variables that don't get dumped at the end of the script), is one of the things I wanna clean up before posting the completed work.
               
               

               


                     Modifié par Sarcose, 10 février 2012 - 02:08 .