SexScripts : addition issues - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=740 Page 1 of 1

addition issues

lifeinplymouth [ Sun Jan 14, 2018 10:46 pm ]

having issues with the following
Code:
def a=0,b=0,c=0,d=0,e=1,f=1,g=1,h=1
code=receiveString("script.x")        ( x is held as "1^1^1^1")
(a,b,c,d) = code.tokenize("^")
a=a+e
b=b+f
c=c+g
d=d+h
code=a+"^"+b+"^"+c+"^"+d
send("script.x",code)

I'm expecting code to end as 2^2^2^2
but I get 11^11^11^11
where have I gone wrong?

I'm assuming the tokenise command is resetting a - d as strings but using 'as int' doesn't help

Re: addition issues

doti [ Mon Jan 15, 2018 12:15 pm ]

code.tokenize("^") is a function that returns an array of strings, not an array of integers (even if those strings contains some digits)
This would work :
Code:
def a=0,b=0,c=0,d=0,e=1,f=1,g=1,h=1
code=receiveString("script.x")        ( x is held as "1^1^1^1")
(a,b,c,d) = code.tokenize("^")
a=a.toInteger()+e
b=b.toInteger()+f
c=c.toInteger()+g
d=d.toInteger()+h
code=a+"^"+b+"^"+c+"^"+d
send("script.x", code)

Re: addition issues

lifeinplymouth [ Mon Jan 15, 2018 9:53 pm ]

That’s great thanks, I’m using tokenize to try to do everything in one call rather than repeating for each item.

Page 1 of 1 All times are UTC + 1 hour [ DST ]
https://ss.deviatenow.com:443/
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2011