SphereCommunity
[SOLVED] Strange BUG in the STRING read - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: [SOLVED] Strange BUG in the STRING read (/Thread-SOLVED-Strange-BUG-in-the-STRING-read)



[SOLVED] Strange BUG in the STRING read - Jhobean - 11-20-2019 12:43 PM

It's look like 56d not able to read a string on a string..

I don't know how explain the bug but here the code. and the GITHUB issue too

Thx for your help.


https://github.com/Sphereserver/Source/issues/214

In 56d the resuslt is 0

In X, the result is 500


Code:
[DEFNAME achievement_def]

achievement_1_1_palier20 = 500


[FUNCTION test]
src.clearctags
src.ctag0.achievement_1_1_palier = 20
src.sysmessage <eval <DEF.achievement_1_1_palier<src.ctag0.achievement_1_1_palier>>>



RE: Strange BUG in the STRING read - golfin - 11-20-2019 01:52 PM

Because I don't know what the resulting sysmessage message should look like, I tried it like this:
PHP Code:
[DEFNAME achievement_def]
achievement_1_1_palier20    "500"

[FUNCTION test]
src.clearctags
src
.ctag0.achievement_1_1_palier 20
src
.sysmessage <eval <src.def.achievement_1_1_palier20>><eval <Src.ctag0.achievement_1_1_palier>> 

I typed DEFNAME in quotation marks and missed 20 in def.achievement_1_1_palier. I also added a src to the DEF link: def.achievement_1_1_palier

The result is: 50020

Should it be like this?


*


Edit last: Hi, I'm testing it, and I understand what you want to do. Oddly, it doesn't want to retrieve a number from DEFNAME. It always throws zero. Text displays correctly, numbers not yet. I count now in other scripts and I look for who invented it.


RE: Strange BUG in the STRING read - Jhobean - 11-20-2019 10:47 PM

Thx for the try but it's not what i'm looking to do.

maybe look at this code it's more evident that the <2> can not be place in a <def.>

Code:
[DEFNAME achievement_def]
achievement_1_1_palier2    500

[FUNCTION test]
src.sysmessage <eval <src.def.achievement_1_1_palier<2>>>



RE: [SOLVED] Strange BUG in the STRING read - Jhobean - 11-20-2019 11:50 PM

THX, the answer is we must use an eval becaus the systeme return a value in hex with a 0 in front.

THX!

Why on X it,s work? I don't know HAHAHA


RE: [SOLVED] Strange BUG in the STRING read - golfin - 11-20-2019 11:52 PM

PHP Code:
[DEFNAME achievement_def]
achievement_1_1_palier_20    "500"

[FUNCTION test]
src.clearctags
src
.ctag0.achievement_1_1_palier 20
sysmessage  
<eval <src.def.achievement_1_1_palier<eval <Src.ctag0.achievement_1_1_palier>>>> 

Jhobean already solved it, we were writing on the discord. But Coruja, isn't that weird? Why Eval twice? Due to the nature of the numerical number, I would not give the Eval function. Which gave zero. I do not get it.


RE: [SOLVED] Strange BUG in the STRING read - Coruja - 11-22-2019 02:59 AM

You're not really using double eval on the same value, but using eval on 2 different values

Sphere return TAG/CTAG/VAR/LOCAL/ARGS/etc values in hex by default, so if you set SRC.CTAG0.achievement_1_1_palier=20, <SRC.CTAG0.achievement_1_1_palier> will return 014 (which is 20 in hex)

And this will turn <DEF0.achievement_1_1_palier<SRC.CTAG0.achievement_1_1_palier>> into <DEF0.achievement_1_1_palier014> (which will be 0 because this DEF doesn't exist) and not <DEF0.achievement_1_1_palier20> (which is 500). So to make it work you must read the tag using eval to turn <DEF0.achievement_1_1_palier014> into <DEF0.achievement_1_1_palier20>

Probably experimental build return 500 even without the eval because it automatically eval values by default. Its easy to make sphere return values in dec instead hex but maybe its better leave it returning hex to preserve script compatibility because sphere always had returned hex values since decades ago. But anyway deal with dec values is much more readable than hex, so I will take a better look to check if this can be changed without cause any drawbacks