Confusion about script in POS
3 posts • Page 1 of 1
Confusion about script in POS
When I enter X and Y coords into pos using a local variable, Thyme will accept it if I enter it manually.
This is the script: { [_Xpos, 1.5] }
But if I enter exactly the same script with a keys.isDown command, then Thyme will reject it.
This is the script in onKey:
keys.isDown("Ctrl") ? {
pos = {
[_Xpos, 1.5]
}
} : {}
Also, if I use a numeric value (1.5) for the X-coord instead of using the local variable (_Xpos), then Thyme accepts the script!
What's going on here?
This is the script: { [_Xpos, 1.5] }
But if I enter exactly the same script with a keys.isDown command, then Thyme will reject it.
This is the script in onKey:
keys.isDown("Ctrl") ? {
pos = {
[_Xpos, 1.5]
}
} : {}
Also, if I use a numeric value (1.5) for the X-coord instead of using the local variable (_Xpos), then Thyme accepts the script!
What's going on here?
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Confusion about script in POS
Problem is in the scope of executing code. To run it into box's scope add this:
- Code: Select all
onKey := (e) => {
keys.isDown("Ctrl") ? {
e.this -> {pos = {[_Xpos, 1.5]}}
} : {}
}
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Confusion about script in POS
Ah... yes! I sometimes forget about the scope in which the code is executing. Your code does work exactly as desired. THANKS VERY MUCH! 
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests



