ID:149821
 
Ok here is my simple code for a read and write scroll if you meet the requirements. Can someone let me why when I write something to it, it never shows up??? Also I'd like to rename the name of the obj with a title input, anyone know what I need here to do that??

LJR


scroll
iw = 0.2
icon = 'items.dmi'
icon_state = "scroll"
var/message
verb
Read_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 1)
M << message
Write_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 2)
var/prompt_title = "Scroll"
var/help_text = "Enter what you would like to appear on the scroll."
var/default_value = null
message = input(help_text, prompt_title, default_value) as null|text</<>



scroll
iw = 0.2
icon = 'items.dmi'
icon_state = "scroll"
var/message
verb
Read_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 1)
M << message
Write_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 2)
var/prompt_title = "Scroll"
var/help_text = "Enter what you would like to appear on the scroll."
var/default_value = null
message = input(help_text, prompt_title, default_value) as null|text


Change the bold part to if(blah => blah) you need the equals sign.

-Sariat
In response to Sariat
Sariat wrote:
Change the bold part to if(blah => blah) you need the equals sign.

That's >=, not =>. As far as I know no language puts the = first.

Anyway that doesn't appear to be related to the problem, since he says he's being prompted for input, but it never appears to do anything past that point.

Lummox JR
In response to Lummox JR
And, also for future reference;

if(varname) is the same as if(varname >=1) and if(varname == TRUE)

if(!varname) is the same as if(varname <=0) and if(varname == FALSE)

1 = TRUE
0 = FALSE


In response to Nadrew
Nadrew wrote:
And, also for future reference;
if(varname) is the same as if(varname >=1) and if(varname == TRUE)
>
> if(!varname) is the same as if(varname <=0) and if(varname == FALSE)
>
> 1 = TRUE
> 0 = FALSE


This is actually incorrect. >=1 and <=0 are the wrong values here. if(varname) is equivalent to if(varname!=0), and if(!varname) is if(varname==0 || varname==null). (Actually I think the latter might also include "". But anyway, if(varname) usually means "if not 0 or null or some other default blank value".)

Lummox JR
Where does it now show up after you write it? When you try to read it, or when you try to write on it again or what?


scroll
iw = 0.2
icon = 'items.dmi'
icon_state = "scroll"
var/message
var/title = "Scroll"
verb
Read_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 1)
M << message
Write_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 2)
var/help_text = "Enter what you would like to appear on the scroll."
title = input("Title your scroll.", title, title) as text
message = input(help_text, title, message) as null|message
if(!message) message = "There is nothing written on the scroll."
In response to Sariat
Sariat wrote:
Change the bold part to if(blah => blah) you need the equals sign.

-Sariat

no thats not it.. I know this programming method well been using it for 15 years now.

LJR
In response to Foomer
When u select the write verb the write popup show up and I click on, it looks like it works, but then I try to read it and blank.

LJR
In response to Nadrew
Nice chat there, but still no one has solved my problem..:(
Weird... I worked up this, and it works flawlessly:
<small>
mob/verb
Read_Scroll()
if(readwrite > 1)
if(message)
usr << message
else
world << "NO MESSAGE" //dbg
else
world << "READWRITE TOO LOW:[readwrite]" //dbg

Write_Scroll()
if(usr.readwrite > 2)
var/prompt_title = "Scroll"
var/help_text = "Enter what you would like to appear on the scroll."
var/default_value = null
message = input(help_text, prompt_title, default_value) as null|text
else
world << "READWRITE TOO LOW: [readwrite]" //dbg
Set_ReadWrite(number as num)
readwrite = number
mob
var
message
title

readwrite = 0
</small>
In response to Vortezz
I tried your, but I'm also trying to prompt the usr for a name for the scroll. This compiles ok, but when I run it and try to write to the scroll, it skips the naming part and just ask me for what I want to write on the scroll. What ends up happening is I have a scroll in my inventory that has no verbs or any way to get rid of it.


Write_Scroll()
set src in usr
var/mob/pc/M = usr
if(M.readwrite > 2)
var/title = "Name Scroll"
var/help = null
var/default = "scroll"
name = input(help, title, default) as null|text
var/prompt_title = "Scroll"
var/help_text = "Enter what you would like to appear on the scroll."
var/default_value = null
message = input(help_text, prompt_title, default_value) as null|text
else
usr << "Your Read/Write skill is too low."
In response to LordJR
If you don't have any help text, then don't bother setting it to null. It could cause some screwy behavior. To fix it use:

name = input(title,default) as null|text