Solved Read line (variable) in file

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Hyao

Active Member
Apr 1, 2017
73
4
8
33
This is my code

Code:
set {_npc} to npc from entity loop-entity
set {_npcId} to id of npc {_npc}
set {_line} to ({_npcId} + 1)
set {_name} to line {_line} in file "/plugins/chi/npcName.txt"

When I debug it, npcId returns 0 - good.
line returns 1 - good.
name returns.. <none>. I've tried parsing line as an int/number, but it always parses as <none>. Better, even, when I just write {_name} to line 1(or anything, a number) it actually works. Anyone know why this is? Or how to fix it? Using the bensku skript fork and I guess the latest "umbaska"? If that's still a thing? The latest before it became WildSkript.
 
Hey :emoji_slight_smile:

What do you want to store in that file?

In the text file, you could try this:
Code:
"Name"

You could give a shot this Skript line :emoji_wink:
code_language.skript:
 set {_name} to line "1" in file "/plugins/chi/npcName.txt"

Or you could use a .yml file instead :emoji_slight_smile:
 
Hey :emoji_slight_smile:

What do you want to store in that file?

In the text file, you could try this:
Code:
"Name"

You could give a shot this Skript line :emoji_wink:
code_language.skript:
 set {_name} to line "1" in file "/plugins/chi/npcName.txt"

Or you could use a .yml file instead :emoji_slight_smile:
Well I'm storing text in a text file, aren't I? I just need to get the line I need. Also, " doesn't work for the line number as that makes it a string and not a number - which it won't accept.

EDIT:
Also Yaml is the same, won't make a difference as the only doc. is on umbaska, as well.
[doublepost=1501943292,1501942346][/doublepost]Found a workaround!

Solution for the people wondering:

Code:
set {_npc} to npc from entity loop-entity
set {_npcId} to id of npc {_npc}
set {_line} to ({_npcId} + 1)
set {_var::*} to file contents of "plugins/chi/npcName.txt"
set {_name} to {_var::%{_line}%}
 
Status
Not open for further replies.