Skip to content

Commit 318f7f4

Browse files
authored
Merge pull request #4 from nPoseTeam/Leona_fix_for_#3
nPose V3Beta2
2 parents 175d5b5 + 5475dd7 commit 318f7f4

File tree

4 files changed

+139
-54
lines changed

4 files changed

+139
-54
lines changed

Tools/UpdateTool nPose 2 to nPose 3.lsl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ key MyId;
3434
list CardsList;
3535
list FinishedCardsList;
3636

37+
integer PropsOldSyntax;
38+
integer PropsUsed;
39+
3740
string deleteNode(string path, integer start, integer end) {
3841
return llDumpList2String(llDeleteSubList(llParseStringKeepNulls(path, [":"], []), start, end), ":");
3942
}
@@ -74,6 +77,7 @@ default {
7477
//add .init file
7578
state stage10 {
7679
state_entry() {
80+
llOwnerSay("This script analyses your nPose object in 3 steps. You have to follow the instructions given in each step to continue.");
7781
llOwnerSay("Step1 (Default card analysis) ...");
7882
MyId=llGetInventoryKey(llGetScriptName());
7983

@@ -120,10 +124,10 @@ state stage10 {
120124
);
121125
if(DefaultCardName!=newDefaultCardName) {
122126
llOwnerSay(
123-
"Then rename the card " + DefaultCardName + " to " + newDefaultCardName +
124-
"\n Click when finished."
127+
"Then rename the card " + DefaultCardName + " to " + newDefaultCardName
125128
);
126129
}
130+
llOwnerSay("\n Click when finished.");
127131
}
128132
}
129133
touch_start(integer num_detected) {
@@ -208,6 +212,7 @@ state stage20 {
208212

209213
state stage30 {
210214
state_entry() {
215+
llOwnerSay("Step3 (NC content) ...");
211216
llOwnerSay("Step3 (NC content) ...");
212217
integer length=llGetInventoryNumber(INVENTORY_NOTECARD);
213218
integer index;
@@ -426,6 +431,14 @@ llOwnerSay("Parsing: " + ncName);
426431
deleteIf(ncName, index-2, data, "the old RLV timer plugin");
427432
}
428433
}
434+
else if(cmd=="PROP") {
435+
PropsUsed=TRUE;
436+
string propParam2=llList2String(parts, 2);
437+
string propParam4=llList2String(parts, 4);
438+
if(~llSubStringIndex(propParam2, "=die") || propParam4=="explicit") {
439+
PropsOldSyntax=TRUE;
440+
}
441+
}
429442
}
430443
if(CardsList) {
431444
FinishedCardsList+=ncName;
@@ -446,6 +459,10 @@ llOwnerSay("Parsing: " + ncName);
446459
}
447460
state stage40{
448461
state_entry() {
462+
if(PropsUsed) {
463+
llOwnerSay("Notice: You are using props. With nPose V3 there will be a new prop script. You may want to check the wiki for the PROP and PROPDIE command.");
464+
}
465+
llOwnerSay("nPose V3 wiki: https://github.com/nPoseTeam/nPose-V3/wiki");
449466
llOwnerSay("FINISHED");
450467
}
451468
on_rez(integer start_param) {

nPose Scripts/Adjuster/nPose Adjuster.lsl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
integer chatchannel = 0;
22
integer slotid = 0;
3+
integer iMoved;
34

45
float timeout = 0.1;
56
vector pos = ZERO_VECTOR;
@@ -13,7 +14,8 @@ default
1314
{
1415
if (param)
1516
{
16-
chatchannel = param;
17+
chatchannel = (integer)((0x00FFFFFF & (param >> 8)) + 0x7F000000);
18+
iMoved = param & 0x000000FF;
1719
pos = llGetPos();
1820
rot = llGetRot();
1921
llListen(chatchannel, "", "", "");
@@ -27,6 +29,9 @@ default
2729

2830
listen(integer channel, string name, key id, string message)
2931
{
32+
list msg = llParseString2List(message, ["|"], []);
33+
string cmd = llList2String(msg,0);
34+
vector vDelta = (vector)llList2String(msg, 1);
3035
//only pay attention of obj owner is my owner
3136
if (llGetOwnerKey(id) == llGetOwner())
3237
{
@@ -51,6 +56,18 @@ default
5156
llDie();
5257
}
5358
}
59+
if (cmd == "MOVEPROP" ){
60+
if (llList2String(msg,1) == llGetObjectName() && (llVecMag(vDelta) < 0.1)){
61+
if (iMoved == 0){
62+
// move it
63+
vector vPosition = (vector)llList2String(msg,2);
64+
llSetRegionPos( vPosition );
65+
pos = llGetPos();
66+
rot = llGetRot();
67+
}
68+
iMoved = 1;
69+
}
70+
}
5471
}
5572

5673
timer()
@@ -79,7 +96,7 @@ default
7996

8097
if (chat_out)
8198
{
82-
llSay(chatchannel, (string)pos + "|" + (string)rot);
99+
llRegionSay(chatchannel, (string)pos + "|" + (string)rot);
83100
}
84101
}
85102
}

nPose Scripts/nPose Core.lsl

Lines changed: 61 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ integer Cur2default; //default action to revert back to default pose when last
7171

7272
string NC_READER_CONTENT_SEPARATOR="%&§";
7373

74+
//PluginCommands=[string name, integer num, integer sendToProps]
7475
list PluginCommands=[
75-
"PLUGINCOMMAND", PLUGIN_COMMAND_REGISTER,
76-
"DEFAULTCARD", DEFAULT_CARD,
77-
"OPTION", OPTIONS,
78-
"UDPBOOL", UDPBOOL,
79-
"UDPLIST", UDPLIST,
80-
"MACRO", MACRO
76+
"PLUGINCOMMAND", PLUGIN_COMMAND_REGISTER, 0,
77+
"DEFAULTCARD", DEFAULT_CARD, 0,
78+
"OPTION", OPTIONS, 0,
79+
"UDPBOOL", UDPBOOL, 0,
80+
"UDPLIST", UDPLIST, 0,
81+
"MACRO", MACRO, 0
8182
];
8283

8384

@@ -104,7 +105,7 @@ list SeatedAvs(){
104105
return avs;
105106
}
106107

107-
assignSlots(){
108+
assignSlots(string cardName){
108109
list avqueue = SeatedAvs();
109110
/*clean up the Slots list with regard to AV key's in the list by
110111
removing extra AV keys from the Slots list, they are no longer seated.
@@ -184,7 +185,7 @@ assignSlots(){
184185
}
185186
}
186187
LastStrideCount = SlotMax;
187-
llMessageLinked(LINK_SET, SEAT_UPDATE, llDumpList2String(Slots, "^"), NULL_KEY);
188+
llMessageLinked(LINK_SET, SEAT_UPDATE, llDumpList2String(Slots, "^"), cardName);
188189
}
189190

190191
SwapTwoSlots(integer currentseatnum, integer newseatnum) {
@@ -193,8 +194,9 @@ SwapTwoSlots(integer currentseatnum, integer newseatnum) {
193194
integer OldSlot;
194195
integer NewSlot;
195196
for(; slotNum < SlotMax; ++slotNum) {
196-
integer z = llSubStringIndex(llList2String(Slots, slotNum*8+7), "§");
197-
string strideSeat = llGetSubString(llList2String(Slots, slotNum * 8+7), z+1,-1);
197+
list tempSeat = llParseStringKeepNulls(llList2String(Slots, slotNum*STRIDE+7), ["§"], []);
198+
string strideSeat = llList2String(tempSeat, 1);
199+
tempSeat =[];
198200
if(strideSeat == "seat" + (string)(currentseatnum)) {
199201
OldSlot= slotNum;
200202
}
@@ -238,13 +240,13 @@ ProcessLine(string sLine, key av, string ncName, string path, integer page) {
238240
if(action == "ANIM") {
239241
if(SlotMax<LastStrideCount) {
240242
Slots = llListReplaceList(Slots, [llList2String(params, 1), (vector)llList2String(params, 2),
241-
llEuler2Rot((vector)llList2String(params, 3) * DEG_TO_RAD), llList2String(params, 4), llList2Key(Slots, (SlotMax)*STRIDE+4),
242-
"", "",llGetSubString(llList2String(params, 5), 0, 12) + "§" + "seat"+(string)(SlotMax+1)], (SlotMax)*STRIDE, (SlotMax)*STRIDE+7);
243+
llEuler2Rot((vector)llList2String(params, 3) * DEG_TO_RAD), llList2String(params, 4), llList2Key(Slots, (SlotMax)*STRIDE+4), "", "",
244+
llGetSubString(llList2String(params, 5), 0, 12) + "§" + "seat"+(string)(SlotMax+1) + "§" + action + "§" + ncName], (SlotMax)*STRIDE, (SlotMax)*STRIDE+7);
243245
}
244246
else {
245247
Slots += [llList2String(params, 1), (vector)llList2String(params, 2),
246248
llEuler2Rot((vector)llList2String(params, 3) * DEG_TO_RAD), llList2String(params, 4), "", "", "",
247-
llGetSubString(llList2String(params, 5), 0, 12) + "§" + "seat"+(string)(SlotMax+1)];
249+
llGetSubString(llList2String(params, 5), 0, 12) + "§" + "seat"+(string)(SlotMax+1) + "§" + action + "§" + ncName];
248250
}
249251
SlotMax++;
250252
}
@@ -268,6 +270,7 @@ ProcessLine(string sLine, key av, string ncName, string path, integer page) {
268270
if(action == "SCHMOE" || (action == "SCHMO" && llList2Key(Slots, slotNumber * STRIDE + 4) == av)) {
269271
integer index=2;
270272
integer length=llGetListLength(params);
273+
string seatName=llList2String(llParseStringKeepNulls(llList2String(params, 7), ["§"], []), 0);
271274
for(; index<length; index++) {
272275
if(index==2) {
273276
Slots=llListReplaceList(Slots, [llList2String(params, index)],
@@ -289,48 +292,61 @@ ProcessLine(string sLine, key av, string ncName, string path, integer page) {
289292
slotNumber * STRIDE + 3, slotNumber * STRIDE + 3);
290293
}
291294
else if(index==6) {
292-
Slots=llListReplaceList(Slots, [llList2String(params, index) + "§seat" + (string)(slotNumber+1)],
293-
slotNumber * STRIDE + 7, slotNumber * STRIDE + 7);
295+
seatName=llList2String(params, index);
294296
}
295297
}
298+
Slots=llListReplaceList(Slots,
299+
[
300+
llDumpList2String([seatName, "seat"+ (string)(slotNumber+1), action, ncName], "§")
301+
],
302+
slotNumber * STRIDE + 7, slotNumber * STRIDE + 7);
296303
}
297304
}
298305
SlotMax = LastStrideCount;
299306
}
300307
else if (action == "PROP") {
301308
string obj = llList2String(params, 1);
302309
if(llGetInventoryType(obj) == INVENTORY_OBJECT) {
310+
//the old die command for explicit props. should be removed soon.
303311
list strParm2 = llParseString2List(llList2String(params, 2), ["="], []);
304312
if(llList2String(strParm2, 1) == "die") {
305313
llRegionSay(ChatChannel,llList2String(strParm2,0)+"=die");
306314
}
307315
else {
308-
ExplicitFlag = 0;
309-
if(llList2String(params, 4) == "explicit") {
310-
ExplicitFlag = 1;
316+
//the rezzing
317+
string propGroupString=llList2String(params, 4);
318+
integer propGroup=(integer)propGroupString;
319+
if(propGroupString=="explicit") {
320+
propGroup=1;
311321
}
312322
//This flag will keep the prop from chatting out it's moves. Some props should move but not spam owner.
323+
integer quietMode;
313324
if(llList2String(params, 5) == "quiet") {
314-
ExplicitFlag += 2;
325+
quietMode=TRUE;
315326
}
327+
//calculate pos and rot of the prop
316328
vector vDelta = (vector)llList2String(params, 2);
317329
vector pos = llGetPos() + (vDelta * llGetRot());
318330
rotation rot = llEuler2Rot((vector)llList2String(params, 3) * DEG_TO_RAD) * llGetRot();
319-
integer sendToPropChannel = (ChatChannel << 8);
320-
sendToPropChannel = sendToPropChannel | ExplicitFlag;
331+
332+
//build the rez paremeter. Upper 3 Bytes for the chatchannel, lower Byte for data
333+
integer rezParam = (ChatChannel << 8);
334+
rezParam=rezParam | (quietMode << 1) | ((propGroup & 0x2F) << 2);
321335
if(llVecMag(vDelta) > 9.9) {
322336
//too far to rez it direct. need to do a prop move
323-
llRezAtRoot(obj, llGetPos(), ZERO_VECTOR, rot, sendToPropChannel);
337+
llRezAtRoot(obj, llGetPos(), ZERO_VECTOR, rot, rezParam);
324338
llSleep(1.0);
325339
llRegionSay(ChatChannel, llDumpList2String(["MOVEPROP", obj, (string)pos], "|"));
326340
}
327341
else {
328-
llRezAtRoot(obj, llGetPos() + ((vector)llList2String(params, 2) * llGetRot()),
329-
ZERO_VECTOR, rot, sendToPropChannel);
342+
llRezAtRoot(obj, pos, ZERO_VECTOR, rot, rezParam);
330343
}
331344
}
332345
}
333346
}
347+
else if(action=="PROPDIE") {
348+
llRegionSay(ChatChannel, llList2Json(JSON_ARRAY, [llList2Json(JSON_ARRAY, params)]));
349+
}
334350
else if(action=="PAUSE") {
335351
llSleep((float)llList2String(params, 1));
336352
}
@@ -382,7 +398,12 @@ ProcessLine(string sLine, key av, string ncName, string path, integer page) {
382398
integer index=llListFindList(PluginCommands, [action]);
383399
if(~index) {
384400
integer num=llList2Integer(PluginCommands, index+1);
385-
llMessageLinked(LINK_SET, num, llDumpList2String(llDeleteSubList(params, 0, 0), "|"), "");
401+
string str=llDumpList2String(llDeleteSubList(params, 0, 0), "|");
402+
llMessageLinked(LINK_SET, num, str, "");
403+
if(llList2Integer(PluginCommands, index+2)) {
404+
//this should also be send to props
405+
llRegionSay(ChatChannel, llList2Json(JSON_ARRAY, [llList2Json(JSON_ARRAY, ["LINKMSG", num, str, ""])]));
406+
}
386407
}
387408
else {
388409
llMessageLinked(LINK_SET, UNKNOWN_COMMAND, sLine, av);
@@ -441,6 +462,10 @@ default{
441462
str = "";
442463
//allData: [ncName, paramSet1, "", contentLine1, contentLine2, ...]
443464
string ncName=llList2String(allData, 0);
465+
if(ncName==DefaultCardName && num == DOPOSE_READER) {
466+
//props (propGroup 0) die when the default card is read
467+
llRegionSay(ChatChannel, "die");
468+
}
444469
list paramSet1List=llParseStringKeepNulls(llList2String(allData, 1), ["|"], []);
445470
string path=llList2String(paramSet1List, 0);
446471
integer page=(integer)llList2String(paramSet1List, 1);
@@ -458,7 +483,7 @@ default{
458483
//reset the slots
459484
LastStrideCount = SlotMax;
460485
SlotMax = 0;
461-
//handle the Adjuster
486+
//props (propGroup 0) die if there is an ANIM line inside the NC
462487
llRegionSay(ChatChannel, "die");
463488
slotResetFinished=TRUE;
464489
run_assignSlots = TRUE;
@@ -482,7 +507,7 @@ default{
482507
}
483508
}
484509
if(run_assignSlots) {
485-
assignSlots();
510+
assignSlots(ncName);
486511
if (llGetInventoryType(ncName) == INVENTORY_NOTECARD){ //sanity
487512
LastAssignSlotsCardName=ncName;
488513
LastAssignSlotsCardId=llGetInventoryKey(LastAssignSlotsCardName);
@@ -534,9 +559,11 @@ default{
534559
//new seat# occupant will then occupy the old seat# of menu user.
535560
//usage: LINKMSG|210|3 Will swap menu user to seat3 and seat3 occupant moves to existing menu user's seat#
536561
//this is intended as an internal call for ChangeSeat button but can be used by any plugin, LINKMSG, or SAT/NOTSATMSG
537-
integer slotIndex = llListFindList(Slots, [id]);
538-
integer z = llSubStringIndex(llList2String(Slots, slotIndex + 3), "§");
539-
string strideSeat = llGetSubString(llList2String(Slots, slotIndex + 3), z+1,-1);
562+
integer slotIndex = llListFindList(Slots, [id])/STRIDE;
563+
list tempSeat = llParseStringKeepNulls(llList2String(Slots, slotIndex*STRIDE+7), ["§"], []);
564+
string strideSeat = llList2String(tempSeat, 1);
565+
tempSeat =[];
566+
540567
integer oldseat = (integer)llGetSubString(strideSeat, 4,-1);
541568
if (oldseat <= 0) {
542569
llWhisper(0, "avatar is not assigned a slot: " + (string)id);
@@ -575,9 +602,10 @@ default{
575602
list parts=llParseString2List(str, ["|"], []);
576603
string action=llList2String(parts, 0);
577604
integer index=llListFindList(PluginCommands, [action]);
578-
if(!~index) {
579-
PluginCommands+=[action, (integer)llList2String(parts, 1)];
605+
if(~index) {
606+
PluginCommands=llDeleteSubList(PluginCommands, index, index+2);
580607
}
608+
PluginCommands+=[action, (integer)llList2String(parts, 1), (integer)llList2String(parts, 2)];
581609
}
582610
else if(num == DIALOG_TIMEOUT) {
583611
if(Cur2default && (llGetObjectPrimCount(llGetKey()) == llGetNumberOfPrims()) && (DefaultCardName != "")) {
@@ -676,7 +704,7 @@ default{
676704
}
677705
if(change & CHANGED_LINK) {
678706
llMessageLinked(LINK_SET, SEND_CHATCHANNEL, (string)ChatChannel, NULL_KEY); //let our scripts know the chat channel for props and adjusters
679-
assignSlots();
707+
assignSlots(LastAssignSlotsCardName);
680708
if(Cur2default && (llGetObjectPrimCount(llGetKey()) == llGetNumberOfPrims()) && (DefaultCardName != "")) {
681709
llMessageLinked(LINK_SET, DOPOSE, DefaultCardName, NULL_KEY);
682710
}

0 commit comments

Comments
 (0)