Giter VIP home page Giter VIP logo

scripting's People

Contributors

aawalton avatar branleaf avatar nickwalton avatar wauthethird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scripting's Issues

README typo

There is a "Go" word after the colon on the README. What does it mean? I suspect a typo.
image

worldInfo / worldEntries does not persist

When scripting, adding entries via addWorldEntry(tag,text,hidden) only persists for the current turn unless the information is added within the input script. It is heavily implied from the behaviour of the interface based world setup and elsewhere in the documentation that it is meant to be a persistent and globally available resource throughout an entire adventure.

Also, the hidden named parameter is undocumented; in the wiki it appears as isNotHidden which is literally the opposite intended use! Likewise there is ambiguity between worldEntries and worldInfo; the bug seems valid for both cases.

Could we get some clarification on this and a fix if it is indeed meant to be persistent.

Question about state.memory.context

Is there a maximum length for this variable? like how normal memory has a limit of 1,000 characters? Or can you set it to longer without (major) issues?

readme suggestion: where do you put the code?

For myself this question is relevant because I view JavaScript to make a website before and even dabbled around in a console. However I haven't the slightest clue where to paste example code.

I tried the developer console in chrome as well as just pasting it into the story.... I'm clueless. I like to imagine are not the only one… But maybe I am

Randomness and Text Length

I'd love to be able to change the user-level Randomness and Text Length parameters via JavaScript – sometimes I want more creativity, sometimes I want output to be terse (like a single name). Thanks!

Can we access the quest state while scripting?

Can we access quest state, add & mark as Completed & check if specific quest was completed within the script?

It would bring great possibilities into the game if we can do that, but I can't find any reference within offical documentation.

Modified Text not working.

So I wanted to try my hand at scripting a scenario and I made a test script based off of the default script for all scenarios. The first two are the test I guess "Scenes" as I referenced them in my script, and the third one is the control. The modified text showed up at first but when I reloaded my script, it stopped displaying the modified text and just displays the input text.

This is my script:

const Scene1 = (text) => {
let modifiedText = text
const lowered = text.toLowerCase()

if(lowered.includes('you are not king') || lowered.includes('you are no longer king')) {
state.isKing = false

console.log('Player is no longer the king!')

modifiedText = text + '\nYou are no longer the king!'

}
return { text: modifiedText }
}

Scene1(text)

const Scene2 = (text) => {
let modifiedText = text
const lowered = text.toLowerCase()

if(lowered.includes('you are king') || lowered.includes('you become king')) {
state.isKing = true

console.log('Player is the king!')

modifiedText = text + '\nYou are the king!'

}
return { text: modifiedText }
}

Scene2(text)

const Scene3 = (text) => {
let modifiedText = text
const lowered = text.toLowerCase()

if(lowered.includes('control line') || lowered.includes('controlled line')) {
state.isKing = true

console.log('Control')

modifiedText = text + '\nControl.'

}
return { text: modifiedText }
}

Scene3(text)

Scripted world info does not appear in the world info menu

Now that the world info is accessible mid-adventure, I decided to look at the world info of one of my scripted adventures, only to find that it was empty. The following code demonstrates that scripted world info does exist in memory when run in an adventure:

const modifier = (text) => {
  
  if (!state.worldInfoAdded) {
    state.worldInfoAdded = true
    addWorldEntry('foo', 'bar')
    return {text: JSON.stringify(worldEntries)}
  }

return {text: text}
}

modifier(text)

However, it will not show up in the world info menu, even after setting world info to be shown in the scenario settings.

Update: It looks like the problem is a missing variable. Running the the above code in a test scenario produced the following:

[{"keys":"You","entry":"You are a cool dude.","isNotHidden":true},{"id":"0.23626612215539655","keys":"foo","entry":"bar"}]

The left entry was added through the world info menu, and the right was added through the script. It seems addWorldEntry has not been updated to use isNotHidden, which means scripted world info will never appear in the menu.

Access the `characters` and `died` variables.

It would be great if scripts could have access (Read- only is sufficient) to the characters variable that's relevant for third- person mode and multiplayer as to know the exact name of characters despite them not making their presence known. This would permit more creative interactions for multiplayer sessions such as attributing certain characteristics to a corresponding worldEntry with ease, but the primary reason I'd like access is to solidify my whitelisting script to prevent griefing in semi- public sessions.

In addition to that, being able to toggle the died state of the client / player would allow for timeouts, resurrections, blocking inputs (without having to place specific code logic) etc. and improve the possibilities of managing the sessions.

Randomness and Text Length

I'd love to be able to change the user-level Randomness and Text Length parameters via JavaScript – sometimes I want more creativity, sometimes I want output to be terse (like a single name). Thanks!

addWorldEntry examples not provided

I get an error when I try to use the addWorldEntry function. None of the example scripts make use of the function, so I can't tell what I'm doing wrong. Can someone post an example of how to use the function properly?

My code:

const modifier = (text) => {
    if (!state.worldInfoAdded) {
      state.worldInfoAdded = true
      addWorldEntry(['foo'], 'bar')
    }
    else {}
    return {text: text}
}

modifier(text)

The error:

TypeError: Cannot read property 'push' of undefined
TypeError: Cannot read property 'push' of undefined
    at addWorldEntry (file:///app/sandbox/Sandbox.js:28:18)
    at Object.base.apply (/app/node_modules/vm2/lib/contextify.js:620:32)
    at modifier (vm.js:4:7)
    at vm.js:10:1
    at Script.runInContext (vm.js:142:20)
    at /app/node_modules/vm2/lib/main.js:851:53
    at timeout_bridge.js:1:1
    at Script.runInContext (vm.js:142:20)
    at doWithTimeout (/app/node_modules/vm2/lib/main.js:467:17)
    at VM.run (/app/node_modules/vm2/lib/main.js:849:10)
    at Object.stringModifier (file:///app/sandbox/Sandbox.js:54:23)
    at testCustomFunction (file:///app/gql/resolvers/Scripts.js:7:28)
    at resolveFieldValueOrError (/app/node_modules/graphql/execution/execute.js:486:18)
    at resolveField (/app/node_modules/graphql/execution/execute.js:444:16)
    at /app/node_modules/graphql/execution/execute.js:250:18
    at /app/node_modules/graphql/jsutils/promiseReduce.js:23:10
    at Array.reduce (<anonymous>)
    at promiseReduce (/app/node_modules/graphql/jsutils/promiseReduce.js:20:17)
    at executeFieldsSerially (/app/node_modules/graphql/execution/execute.js:247:37)
    at executeOperation (/app/node_modules/graphql/execution/execute.js:225:55)
    at executeImpl (/app/node_modules/graphql/execution/execute.js:102:14)
    at execute (/app/node_modules/graphql/execution/execute.js:62:63)
    at /app/node_modules/subscriptions-transport-ws/dist/server.js:199:68

I reckon the error is saying that worldEntries is undefined, but I'm not sure.

reimplementAuthorsNote.js truncation at the end is nonsensical/bugged.

Towards the end of the context modifier example reimplementAuthorsNote.js some code tries to truncate the output so as to not exceed info.memoryLength or info.maxChars, but ends up needlessly truncating the most recent actions instead.

Edit Note: (Fixed an issue with my reasoning. The bug is there, but for a different set of reasons)

// Make sure the new context isn't too long, or it will get truncated by the server.
const combinedLines = lines.join("\n").slice(-(info.maxChars - info.memoryLength))
const finalText = [contextMemory, combinedLines].join("")
return { text: finalText }

So at this point the function has split the incoming text into contextMemory and context where context is the length of memoryLength representing the AI's memory window. lines.join("\n") is context with the author's notes injected (3 lines back from front). It's assumed that the input text was an arbitrary length that could have exceeded maxChars. I believe the above code is trying to truncate the modified output text so that finalText is truncated from the front (ie oldest player actions) to maxChars. (otherwise the server would truncate the back losing the newest actions).

So the mistakes it makes are that it assumes lines.join("\n") is already info.memoryLength, which is false because it is context (which is length memoryLength) with the author's notes injected, pushing it over. Further, truncation is only happening on the context portion of the text when the intent here is to truncate all of text; context portion should be untouched. Last, truncation is weird when maxChars is greater than memoryLength. Like, if memoryLength is 20 and maxChars is 21, that's slice(-1) which results in the very last char of the most recent player actions making it through. Why would we throw away the most recent actions right? We want to truncate the oldest actions.

Below is the fixed code that should replace the above.

// Make sure the final context isn't too long, or it will get truncated by the server.
const finalText = (contextMemory + lines.join("\n")).slice(-info.maxChars);
return { text: finalText }

Color property of state.displayStats

Enjoying the state.displayStats functionality!

The current color property accepts standard html5 color names, but I can't get it to function with either hex equivalents or the rgb() syntax.

Am I missing something obvious? If not, would it be possible to enable either the #000000 format, or the rgb() syntax (as strings in the property field is fine, or 0x hex format, or arrays of 8bit values, whatever works), so that it is easier to generate random colors?

I worked around this by creating a shared array of the names and randomly pulling by index, but I'd like something less hacky/space consuming.

If I am indeed missing something obvious, let me know, and I'll document the property on the wiki.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.